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()
239 uint16_t mode; in xchk_dinode() local
241 flags = be16_to_cpu(dip->di_flags); in xchk_dinode()
242 if (dip->di_version >= 3) in xchk_dinode()
243 flags2 = be64_to_cpu(dip->di_flags2); in xchk_dinode()
248 mode = be16_to_cpu(dip->di_mode); in xchk_dinode()
249 switch (mode & S_IFMT) { in xchk_dinode()
257 /* mode is recognized */ in xchk_dinode()
265 switch (dip->di_version) { in xchk_dinode()
276 if (dip->di_onlink != 0) in xchk_dinode()
279 if (dip->di_mode == 0 && sc->ip) in xchk_dinode()
282 if (dip->di_projid_hi != 0 && in xchk_dinode()
286 prid = be16_to_cpu(dip->di_projid_lo); in xchk_dinode()
294 prid |= (prid_t)be16_to_cpu(dip->di_projid_hi) << 16; in xchk_dinode()
297 * di_uid/di_gid -- -1 isn't invalid, but there's no way that in xchk_dinode()
300 if (dip->di_uid == cpu_to_be32(-1U) || in xchk_dinode()
301 dip->di_gid == cpu_to_be32(-1U)) in xchk_dinode()
305 * project id of -1 isn't supposed to be valid, but the kernel didn't in xchk_dinode()
308 if (prid == -1U) in xchk_dinode()
312 switch (dip->di_format) { in xchk_dinode()
314 if (!S_ISCHR(mode) && !S_ISBLK(mode) && in xchk_dinode()
315 !S_ISFIFO(mode) && !S_ISSOCK(mode)) in xchk_dinode()
319 if (!S_ISDIR(mode) && !S_ISLNK(mode)) in xchk_dinode()
323 if (!S_ISREG(mode) && !S_ISDIR(mode) && !S_ISLNK(mode)) in xchk_dinode()
327 if (!S_ISREG(mode) && !S_ISDIR(mode)) in xchk_dinode()
337 xchk_dinode_nsec(sc, ino, dip, dip->di_atime); in xchk_dinode()
338 xchk_dinode_nsec(sc, ino, dip, dip->di_mtime); in xchk_dinode()
339 xchk_dinode_nsec(sc, ino, dip, dip->di_ctime); in xchk_dinode()
343 * the VFS such as the upper bit being set and zero-length in xchk_dinode()
346 isize = be64_to_cpu(dip->di_size); in xchk_dinode()
351 if (!S_ISDIR(mode) && !S_ISREG(mode) && !S_ISLNK(mode) && isize != 0) in xchk_dinode()
355 if (S_ISDIR(mode) && (isize == 0 || isize >= XFS_DIR2_SPACE_SIZE)) in xchk_dinode()
359 if (S_ISLNK(mode) && (isize == 0 || isize >= XFS_SYMLINK_MAXLEN)) in xchk_dinode()
366 * overly large offsets, flag the inode for admin review. in xchk_dinode()
368 if (isize >= mp->m_super->s_maxbytes) in xchk_dinode()
379 * best we can do without cross-referencing with the in xchk_dinode()
382 if (be64_to_cpu(dip->di_nblocks) >= in xchk_dinode()
383 mp->m_sb.sb_dblocks + mp->m_sb.sb_rblocks) in xchk_dinode()
386 if (be64_to_cpu(dip->di_nblocks) >= mp->m_sb.sb_dblocks) in xchk_dinode()
390 xchk_inode_flags(sc, dip, ino, mode, flags); in xchk_dinode()
392 xchk_inode_extsize(sc, dip, ino, mode, flags); in xchk_dinode()
399 switch (dip->di_format) { in xchk_dinode()
415 if (XFS_DFORK_APTR(dip) >= (char *)dip + mp->m_sb.sb_inodesize) in xchk_dinode()
417 if (naextents != 0 && dip->di_forkoff == 0) in xchk_dinode()
419 if (dip->di_forkoff == 0 && dip->di_aformat != XFS_DINODE_FMT_EXTENTS) in xchk_dinode()
423 if (dip->di_aformat != XFS_DINODE_FMT_LOCAL && in xchk_dinode()
424 dip->di_aformat != XFS_DINODE_FMT_EXTENTS && in xchk_dinode()
425 dip->di_aformat != XFS_DINODE_FMT_BTREE) in xchk_dinode()
430 switch (dip->di_aformat) { in xchk_dinode()
444 if (dip->di_version >= 3) { in xchk_dinode()
445 xchk_dinode_nsec(sc, ino, dip, dip->di_crtime); in xchk_dinode()
446 xchk_inode_flags2(sc, dip, ino, mode, flags, flags2); in xchk_dinode()
447 xchk_inode_cowextsize(sc, dip, ino, mode, flags, in xchk_dinode()
467 if (!sc->sa.fino_cur || xchk_skip_xref(sc->sm)) in xchk_inode_xref_finobt()
470 agino = XFS_INO_TO_AGINO(sc->mp, ino); in xchk_inode_xref_finobt()
476 error = xfs_inobt_lookup(sc->sa.fino_cur, agino, XFS_LOOKUP_LE, in xchk_inode_xref_finobt()
478 if (!xchk_should_check_xref(sc, &error, &sc->sa.fino_cur) || in xchk_inode_xref_finobt()
482 error = xfs_inobt_get_rec(sc->sa.fino_cur, &rec, &has_record); in xchk_inode_xref_finobt()
483 if (!xchk_should_check_xref(sc, &error, &sc->sa.fino_cur) || in xchk_inode_xref_finobt()
495 if (rec.ir_free & XFS_INOBT_MASK(agino - rec.ir_startino)) in xchk_inode_xref_finobt()
496 xchk_btree_xref_set_corrupt(sc, sc->sa.fino_cur, 0); in xchk_inode_xref_finobt()
510 if (xchk_skip_xref(sc->sm)) in xchk_inode_xref_bmap()
514 error = xfs_bmap_count_blocks(sc->tp, sc->ip, XFS_DATA_FORK, in xchk_inode_xref_bmap()
519 xchk_ino_xref_set_corrupt(sc, sc->ip->i_ino); in xchk_inode_xref_bmap()
521 error = xfs_bmap_count_blocks(sc->tp, sc->ip, XFS_ATTR_FORK, in xchk_inode_xref_bmap()
526 xchk_ino_xref_set_corrupt(sc, sc->ip->i_ino); in xchk_inode_xref_bmap()
529 if (count + acount != be64_to_cpu(dip->di_nblocks)) in xchk_inode_xref_bmap()
530 xchk_ino_xref_set_corrupt(sc, sc->ip->i_ino); in xchk_inode_xref_bmap()
533 /* Cross-reference with the other btrees. */
544 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) in xchk_inode_xref()
547 agno = XFS_INO_TO_AGNO(sc->mp, ino); in xchk_inode_xref()
548 agbno = XFS_INO_TO_AGBNO(sc->mp, ino); in xchk_inode_xref()
550 error = xchk_ag_init_existing(sc, agno, &sc->sa); in xchk_inode_xref()
561 xchk_ag_free(sc, &sc->sa); in xchk_inode_xref()
566 * either flag an error (shared extents w/ no flag) or a preen (flag set w/o
575 struct xfs_mount *mp = sc->mp; in xchk_inode_check_reflink_iflag()
582 error = xfs_reflink_inode_has_shared_extents(sc->tp, sc->ip, in xchk_inode_check_reflink_iflag()
587 if (xfs_is_reflink_inode(sc->ip) && !has_shared) in xchk_inode_check_reflink_iflag()
589 else if (!xfs_is_reflink_inode(sc->ip) && has_shared) in xchk_inode_check_reflink_iflag()
602 * If sc->ip is NULL, that means that the setup function called in xchk_inode()
604 * and a NULL inode, so flag the corruption error and return. in xchk_inode()
606 if (!sc->ip) { in xchk_inode()
607 xchk_ino_set_corrupt(sc, sc->sm->sm_ino); in xchk_inode()
612 xfs_inode_to_disk(sc->ip, &di, 0); in xchk_inode()
613 xchk_dinode(sc, &di, sc->ip->i_ino); in xchk_inode()
614 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) in xchk_inode()
619 * iflag. We already checked the iflag against the file mode when in xchk_inode()
622 if (S_ISREG(VFS_I(sc->ip)->i_mode)) in xchk_inode()
623 xchk_inode_check_reflink_iflag(sc, sc->ip->i_ino); in xchk_inode()
625 xchk_inode_xref(sc, sc->ip->i_ino, &di); in xchk_inode()