Lines Matching +full:mode +full:- +full:flag

1 // SPDX-License-Identifier: GPL-2.0+
37 * in raw mode. in xchk_setup_inode()
43 case -EFSCORRUPTED: in xchk_setup_inode()
44 case -EFSBADCRC: in xchk_setup_inode()
51 sc->ilock_flags = XFS_IOLOCK_EXCL | XFS_MMAPLOCK_EXCL; in xchk_setup_inode()
52 xfs_ilock(sc->ip, sc->ilock_flags); in xchk_setup_inode()
56 sc->ilock_flags |= XFS_ILOCK_EXCL; in xchk_setup_inode()
57 xfs_ilock(sc->ip, XFS_ILOCK_EXCL); in xchk_setup_inode()
72 uint16_t mode, in xchk_inode_extsize() argument
76 uint32_t value = be32_to_cpu(dip->di_extsize); in xchk_inode_extsize()
78 fa = xfs_inode_validate_extsize(sc->mp, value, mode, flags); in xchk_inode_extsize()
88 * device. Flag this as an administrative warning since we will clean in xchk_inode_extsize()
93 value % sc->mp->m_sb.sb_rextsize > 0) in xchk_inode_extsize()
108 uint16_t mode, in xchk_inode_cowextsize() argument
114 fa = xfs_inode_validate_cowextsize(sc->mp, in xchk_inode_cowextsize()
115 be32_to_cpu(dip->di_cowextsize), mode, flags, in xchk_inode_cowextsize()
127 uint16_t mode, in xchk_inode_flags() argument
130 struct xfs_mount *mp = sc->mp; in xchk_inode_flags()
137 if ((flags & XFS_DIFLAG_REALTIME) && !mp->m_rtdev_targp) in xchk_inode_flags()
140 /* new rt bitmap flag only valid for rbmino */ in xchk_inode_flags()
141 if ((flags & XFS_DIFLAG_NEWRTBM) && ino != mp->m_sb.sb_rbmino) in xchk_inode_flags()
144 /* directory-only flags */ in xchk_inode_flags()
149 !S_ISDIR(mode)) in xchk_inode_flags()
152 /* file-only flags */ in xchk_inode_flags()
154 !S_ISREG(mode)) in xchk_inode_flags()
172 uint16_t mode, in xchk_inode_flags2() argument
176 struct xfs_mount *mp = sc->mp; in xchk_inode_flags2()
182 /* reflink flag requires reflink feature */ in xchk_inode_flags2()
187 /* cowextsize flag is checked w.r.t. mode separately */ in xchk_inode_flags2()
189 /* file/dir-only flags */ in xchk_inode_flags2()
190 if ((flags2 & XFS_DIFLAG2_DAX) && !(S_ISREG(mode) || S_ISDIR(mode))) in xchk_inode_flags2()
193 /* file-only flags */ in xchk_inode_flags2()
194 if ((flags2 & XFS_DIFLAG2_REFLINK) && !S_ISREG(mode)) in xchk_inode_flags2()
231 struct xfs_mount *mp = sc->mp; in xchk_dinode()
237 uint16_t mode; in xchk_dinode() local
239 flags = be16_to_cpu(dip->di_flags); in xchk_dinode()
240 if (dip->di_version >= 3) in xchk_dinode()
241 flags2 = be64_to_cpu(dip->di_flags2); in xchk_dinode()
246 mode = be16_to_cpu(dip->di_mode); in xchk_dinode()
247 switch (mode & S_IFMT) { in xchk_dinode()
255 /* mode is recognized */ in xchk_dinode()
263 switch (dip->di_version) { in xchk_dinode()
273 if (dip->di_onlink != 0) in xchk_dinode()
276 if (dip->di_mode == 0 && sc->ip) in xchk_dinode()
279 if (dip->di_projid_hi != 0 && in xchk_dinode()
289 * di_uid/di_gid -- -1 isn't invalid, but there's no way that in xchk_dinode()
292 if (dip->di_uid == cpu_to_be32(-1U) || in xchk_dinode()
293 dip->di_gid == cpu_to_be32(-1U)) in xchk_dinode()
297 switch (dip->di_format) { in xchk_dinode()
299 if (!S_ISCHR(mode) && !S_ISBLK(mode) && in xchk_dinode()
300 !S_ISFIFO(mode) && !S_ISSOCK(mode)) in xchk_dinode()
304 if (!S_ISDIR(mode) && !S_ISLNK(mode)) in xchk_dinode()
308 if (!S_ISREG(mode) && !S_ISDIR(mode) && !S_ISLNK(mode)) in xchk_dinode()
312 if (!S_ISREG(mode) && !S_ISDIR(mode)) in xchk_dinode()
322 xchk_dinode_nsec(sc, ino, dip, dip->di_atime); in xchk_dinode()
323 xchk_dinode_nsec(sc, ino, dip, dip->di_mtime); in xchk_dinode()
324 xchk_dinode_nsec(sc, ino, dip, dip->di_ctime); in xchk_dinode()
328 * the VFS such as the upper bit being set and zero-length in xchk_dinode()
331 isize = be64_to_cpu(dip->di_size); in xchk_dinode()
336 if (!S_ISDIR(mode) && !S_ISREG(mode) && !S_ISLNK(mode) && isize != 0) in xchk_dinode()
340 if (S_ISDIR(mode) && (isize == 0 || isize >= XFS_DIR2_SPACE_SIZE)) in xchk_dinode()
344 if (S_ISLNK(mode) && (isize == 0 || isize >= XFS_SYMLINK_MAXLEN)) in xchk_dinode()
351 * overly large offsets, flag the inode for admin review. in xchk_dinode()
353 if (isize >= mp->m_super->s_maxbytes) in xchk_dinode()
364 * best we can do without cross-referencing with the in xchk_dinode()
367 if (be64_to_cpu(dip->di_nblocks) >= in xchk_dinode()
368 mp->m_sb.sb_dblocks + mp->m_sb.sb_rblocks) in xchk_dinode()
371 if (be64_to_cpu(dip->di_nblocks) >= mp->m_sb.sb_dblocks) in xchk_dinode()
375 xchk_inode_flags(sc, dip, ino, mode, flags); in xchk_dinode()
377 xchk_inode_extsize(sc, dip, ino, mode, flags); in xchk_dinode()
380 nextents = be32_to_cpu(dip->di_nextents); in xchk_dinode()
382 switch (dip->di_format) { in xchk_dinode()
398 if (XFS_DFORK_APTR(dip) >= (char *)dip + mp->m_sb.sb_inodesize) in xchk_dinode()
400 if (dip->di_anextents != 0 && dip->di_forkoff == 0) in xchk_dinode()
402 if (dip->di_forkoff == 0 && dip->di_aformat != XFS_DINODE_FMT_EXTENTS) in xchk_dinode()
406 if (dip->di_aformat != XFS_DINODE_FMT_LOCAL && in xchk_dinode()
407 dip->di_aformat != XFS_DINODE_FMT_EXTENTS && in xchk_dinode()
408 dip->di_aformat != XFS_DINODE_FMT_BTREE) in xchk_dinode()
412 nextents = be16_to_cpu(dip->di_anextents); in xchk_dinode()
414 switch (dip->di_aformat) { in xchk_dinode()
428 if (dip->di_version >= 3) { in xchk_dinode()
429 xchk_dinode_nsec(sc, ino, dip, dip->di_crtime); in xchk_dinode()
430 xchk_inode_flags2(sc, dip, ino, mode, flags, flags2); in xchk_dinode()
431 xchk_inode_cowextsize(sc, dip, ino, mode, flags, in xchk_dinode()
451 if (!sc->sa.fino_cur || xchk_skip_xref(sc->sm)) in xchk_inode_xref_finobt()
454 agino = XFS_INO_TO_AGINO(sc->mp, ino); in xchk_inode_xref_finobt()
460 error = xfs_inobt_lookup(sc->sa.fino_cur, agino, XFS_LOOKUP_LE, in xchk_inode_xref_finobt()
462 if (!xchk_should_check_xref(sc, &error, &sc->sa.fino_cur) || in xchk_inode_xref_finobt()
466 error = xfs_inobt_get_rec(sc->sa.fino_cur, &rec, &has_record); in xchk_inode_xref_finobt()
467 if (!xchk_should_check_xref(sc, &error, &sc->sa.fino_cur) || in xchk_inode_xref_finobt()
479 if (rec.ir_free & XFS_INOBT_MASK(agino - rec.ir_startino)) in xchk_inode_xref_finobt()
480 xchk_btree_xref_set_corrupt(sc, sc->sa.fino_cur, 0); in xchk_inode_xref_finobt()
494 if (xchk_skip_xref(sc->sm)) in xchk_inode_xref_bmap()
498 error = xfs_bmap_count_blocks(sc->tp, sc->ip, XFS_DATA_FORK, in xchk_inode_xref_bmap()
502 if (nextents < be32_to_cpu(dip->di_nextents)) in xchk_inode_xref_bmap()
503 xchk_ino_xref_set_corrupt(sc, sc->ip->i_ino); in xchk_inode_xref_bmap()
505 error = xfs_bmap_count_blocks(sc->tp, sc->ip, XFS_ATTR_FORK, in xchk_inode_xref_bmap()
509 if (nextents != be16_to_cpu(dip->di_anextents)) in xchk_inode_xref_bmap()
510 xchk_ino_xref_set_corrupt(sc, sc->ip->i_ino); in xchk_inode_xref_bmap()
513 if (count + acount != be64_to_cpu(dip->di_nblocks)) in xchk_inode_xref_bmap()
514 xchk_ino_xref_set_corrupt(sc, sc->ip->i_ino); in xchk_inode_xref_bmap()
517 /* Cross-reference with the other btrees. */
528 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) in xchk_inode_xref()
531 agno = XFS_INO_TO_AGNO(sc->mp, ino); in xchk_inode_xref()
532 agbno = XFS_INO_TO_AGBNO(sc->mp, ino); in xchk_inode_xref()
534 error = xchk_ag_init_existing(sc, agno, &sc->sa); in xchk_inode_xref()
545 xchk_ag_free(sc, &sc->sa); in xchk_inode_xref()
550 * either flag an error (shared extents w/ no flag) or a preen (flag set w/o
559 struct xfs_mount *mp = sc->mp; in xchk_inode_check_reflink_iflag()
566 error = xfs_reflink_inode_has_shared_extents(sc->tp, sc->ip, in xchk_inode_check_reflink_iflag()
571 if (xfs_is_reflink_inode(sc->ip) && !has_shared) in xchk_inode_check_reflink_iflag()
573 else if (!xfs_is_reflink_inode(sc->ip) && has_shared) in xchk_inode_check_reflink_iflag()
586 * If sc->ip is NULL, that means that the setup function called in xchk_inode()
588 * and a NULL inode, so flag the corruption error and return. in xchk_inode()
590 if (!sc->ip) { in xchk_inode()
591 xchk_ino_set_corrupt(sc, sc->sm->sm_ino); in xchk_inode()
596 xfs_inode_to_disk(sc->ip, &di, 0); in xchk_inode()
597 xchk_dinode(sc, &di, sc->ip->i_ino); in xchk_inode()
598 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) in xchk_inode()
603 * iflag. We already checked the iflag against the file mode when in xchk_inode()
606 if (S_ISREG(VFS_I(sc->ip)->i_mode)) in xchk_inode()
607 xchk_inode_check_reflink_iflag(sc, sc->ip->i_ino); in xchk_inode()
609 xchk_inode_xref(sc, sc->ip->i_ino, &di); in xchk_inode()