Home | History | Annotate | Download | only in e2fsck

Lines Matching full:inode

2  * pass1.c -- pass #1 of e2fsck: sequential scan of the inode table
12 * and applies the following tests to each inode:
14 * - The mode field of the inode must be legal.
15 * - The size and block count fields of the inode are correct.
16 * - A data block must not be used by another inode
31 * other passes should not need to read in the inode information
34 * inode to fix it.)
89 struct ext2_inode *inode;
97 struct ext2_inode inode;
125 * Check to make sure a device inode is real. Returns 1 if the device
133 struct ext2_inode *inode)
141 if (inode->i_flags & EXT2_INDEX_FL)
147 * inode's additional i_block fields, there are some rare
148 * occasions when a legitimate device inode will have non-zero
155 if (inode->i_flags & (EXT2_IMMUTABLE_FL | EXT2_APPEND_FL)) {
157 if (inode->i_block[i])
164 * Check to make sure a symlink inode is real. Returns 1 if the symlink
168 struct ext2_inode *inode, char *buf)
177 if ((inode->i_size_high || inode->i_size == 0) ||
178 (inode->i_flags & EXT2_INDEX_FL))
181 if (inode->i_flags & EXT4_EXTENTS_FL) {
182 if (inode->i_size > fs->blocksize)
184 if (ext2fs_extent_open2(fs, ino, inode, &handle))
203 blocks = ext2fs_inode_data_blocks(fs, inode);
205 if ((inode->i_size >= fs->blocksize) ||
207 (inode->i_block[0] < fs->super->s_first_data_block) ||
208 (inode->i_block[0] >= fs->super->s_blocks_count))
212 if (inode->i_block[i])
215 if (io_channel_read_blk(fs->io, inode->i_block[0], 1, buf))
222 if (inode->i_size >= sizeof(inode->i_block))
225 len = strnlen((char *)inode->i_block, sizeof(inode->i_block));
226 if (len == sizeof(inode->i_block))
229 if (len != inode->i_size)
235 * If the immutable (or append-only) flag is set on the inode, offer
241 if (!(pctx->inode->i_flags & BAD_SPECIAL_FLAGS))
247 pctx->inode->i_flags &= ~BAD_SPECIAL_FLAGS;
248 e2fsck_write_inode(ctx, pctx->ino, pctx->inode, "pass1");
257 struct ext2_inode *inode = pctx->inode;
259 if ((inode->i_size == 0) && (inode->i_size_high == 0))
265 inode->i_size = 0;
266 inode->i_size_high = 0;
267 e2fsck_write_inode(ctx, pctx->ino, pctx->inode, "pass1");
273 struct ext2_inode_large *inode;
279 inode = (struct ext2_inode_large *) pctx->inode;
281 inode->i_extra_isize;
282 start = ((char *) inode) + EXT2_GOOD_OLD_INODE_SIZE +
283 inode->i_extra_isize + sizeof(__u32);
284 end = (char *) inode + EXT2_INODE_SIZE(ctx->fs->super);
315 /* e_value_block must be 0 in inode's ea */
325 /* e_hash may be 0 in older inode's ea */
346 e2fsck_write_inode_full(ctx, pctx->ino, pctx->inode,
353 struct ext2_inode_large *inode;
357 inode = (struct ext2_inode_large *) pctx->inode;
359 /* this isn't large inode. so, nothing to check */
364 printf("inode #%u, i_extra_size %d\n", pctx->ino,
365 inode->i_extra_isize);
368 min = sizeof(inode->i_extra_isize) + sizeof(inode->i_pad1);
374 if (inode->i_extra_isize &&
375 (inode->i_extra_isize < min || inode->i_extra_isize > max)) {
378 inode->i_extra_isize = min;
379 e2fsck_write_inode_full(ctx, pctx->ino, pctx->inode,
384 eamagic = (__u32 *) (((char *) inode) + EXT2_GOOD_OLD_INODE_SIZE +
385 inode->i_extra_isize);
387 /* it seems inode has an extended attribute(s) in body */
393 * Check to see if the inode might really be a directory, despite i_mode
403 struct ext2_inode *inode = pctx->inode;
415 * inode is extent-mapped, it is still the case that the latter
419 if (LINUX_S_ISDIR(inode->i_mode) || LINUX_S_ISREG(inode->i_mode) ||
420 LINUX_S_ISLNK(inode->i_mode) || inode->i_block[0] == 0)
441 if (extent_fs && (inode->i_flags & EXT4_EXTENTS_FL)) {
443 if (ext2fs_bmap(ctx->fs, pctx->ino, inode, 0, 0, 0,
450 blk = inode->i_block[i];
462 blk = inode->i_block[0];
470 if ((LINUX_S_ISCHR(inode->i_mode) || LINUX_S_ISBLK(inode->i_mode)) &&
471 (inode->i_links_count == 1) && !not_device)
487 (dirent->inode != pctx->ino) ||
505 inode->i_mode = (inode->i_mode & 07777) | LINUX_S_IFDIR;
506 e2fsck_write_inode_full(ctx, pctx->ino, inode,
549 struct ext2_inode *inode;
597 pctx.errcode = ext2fs_allocate_inode_bitmap(fs, _("in-use inode map"),
606 _("directory inode map"), &ctx->inode_dir_map);
614 _("regular file inode map"), &ctx->inode_reg_map);
639 inode = (struct ext2_inode *)
640 e2fsck_allocate_memory(ctx, inode_size, "scratch inode");
653 ext2fs_free_mem(&inode);
675 old_op = ehandler_operation(_("opening inode scan"));
683 ext2fs_free_mem(&inode);
687 ctx->stashed_inode = inode;
699 old_op = ehandler_operation(_("getting next inode from scan"));
701 inode, inode_size);
720 pctx.inode = inode;
722 if (inode->i_links_count) {
724 ino, inode->i_links_count);
726 pctx.num = inode->i_links_count;
737 * When the inode is read, the i_block array is not swapped
745 * extent_header_verify is ok. If the inode is cleared,
748 if ((inode->i_flags & EXT4_EXTENTS_FL) && !extent_fs &&
749 (inode->i_links_count || (ino == EXT2_BAD_INO) ||
751 if ((ext2fs_extent_header_verify(inode->i_block,
752 sizeof(inode->i_block)) == 0) &&
759 e2fsck_clear_inode(ctx, ino, inode, 0, "pass1");
769 * If the inode didn't have the extents flag set when it
775 if (extent_fs && !(inode->i_flags & EXT4_EXTENTS_FL) &&
776 (inode->i_links_count || (ino == EXT2_BAD_INO) ||
778 (LINUX_S_ISREG(inode->i_mode) ||
779 LINUX_S_ISDIR(inode->i_mode))) {
785 tmp_block[i] = ext2fs_swab32(inode->i_block[i]);
788 ehp = inode->i_block;
791 sizeof(inode->i_block)) == 0) &&
793 inode->i_flags |= EXT4_EXTENTS_FL;
795 memcpy(inode->i_block, tmp_block,
796 sizeof(inode->i_block));
798 e2fsck_write_inode(ctx, ino, inode, "pass1");
819 pb.inode = inode;
840 * Make sure the root inode is a directory; if
844 if (!LINUX_S_ISDIR(inode->i_mode)) {
857 if (inode->i_dtime && inode->i_links_count) {
859 inode->i_dtime = 0;
860 e2fsck_write_inode(ctx, ino, inode,
867 if (!LINUX_S_ISREG(inode->i_mode) &&
870 inode->i_mode = LINUX_S_IFREG;
871 e2fsck_write_inode(ctx, ino, inode,
877 if ((inode->i_links_count || inode->i_blocks ||
878 inode->i_blocks || inode->i_block[0]) &&
881 memset(inode, 0, inode_size);
884 e2fsck_write_inode_full(ctx, ino, inode,
892 if (LINUX_S_ISDIR(inode->i_mode))
895 if (inode->i_mode &&
896 !LINUX_S_ISREG(inode->i_mode))
899 if (inode->i_mode != 0)
904 inode->i_mode = 0;
905 e2fsck_write_inode(ctx, ino, inode,
922 * inodes where i_size and the inode blocks are
929 if (inode->i_dtime && !busted_fs_time &&
930 inode->i_dtime < ctx->fs->super->s_inodes_count) {
932 inode->i_dtime = inode->i_links_count ?
934 e2fsck_write_inode(ctx, ino, inode,
943 if (!inode->i_links_count) {
944 if (!inode->i_dtime && inode->i_mode) {
947 inode->i_dtime = ctx->now;
948 e2fsck_write_inode(ctx, ino, inode,
964 if (inode->i_dtime) {
966 inode->i_dtime = 0;
967 e2fsck_write_inode(ctx, ino, inode, "pass1");
974 frag = inode->osd2.hurd2.h_i_frag;
975 fsize = inode->osd2.hurd2.h_i_fsize;
981 if (inode->i_faddr || frag || fsize ||
982 (LINUX_S_ISDIR(inode->i_mode) && inode->i_dir_acl))
986 inode->osd2.linux2.l_i_file_acl_high != 0)
991 (inode->osd2.linux2.l_i_blocks_hi != 0))
993 if (inode->i_flags & EXT2_IMAGIC_FL) {
1001 inode->i_flags &= ~EXT2_IMAGIC_FL;
1003 inode, "pass1");
1015 if (extent_fs && (inode->i_flags & EXT4_EXTENTS_FL) &&
1016 LINUX_S_ISLNK(inode->i_mode) &&
1017 !ext2fs_inode_has_valid_blocks(inode) &&
1019 inode->i_flags &= ~EXT4_EXTENTS_FL;
1020 e2fsck_write_inode(ctx, ino, inode, "pass1");
1023 if (LINUX_S_ISDIR(inode->i_mode)) {
1027 } else if (LINUX_S_ISREG (inode->i_mode)) {
1030 } else if (LINUX_S_ISCHR (inode->i_mode) &&
1031 e2fsck_pass1_check_device_inode(fs, inode)) {
1035 } else if (LINUX_S_ISBLK (inode->i_mode) &&
1036 e2fsck_pass1_check_device_inode(fs, inode)) {
1040 } else if (LINUX_S_ISLNK (inode->i_mode) &&
1041 e2fsck_pass1_check_symlink(fs, ino, inode,
1045 if (ext2fs_inode_data_blocks(fs, inode) == 0) {
1051 else if (LINUX_S_ISFIFO (inode->i_mode) &&
1052 e2fsck_pass1_check_device_inode(fs, inode)) {
1056 } else if ((LINUX_S_ISSOCK (inode->i_mode)) &&
1057 e2fsck_pass1_check_device_inode(fs, inode)) {
1063 if (!(inode->i_flags & EXT4_EXTENTS_FL)) {
1064 if (inode->i_block[EXT2_IND_BLOCK])
1066 if (inode->i_block[EXT2_DIND_BLOCK])
1068 if (inode->i_block[EXT2_TIND_BLOCK])
1071 if (!(inode->i_flags & EXT4_EXTENTS_FL) &&
1072 (inode->i_block[EXT2_IND_BLOCK] ||
1073 inode->i_block[EXT2_DIND_BLOCK] ||
1074 inode->i_block[EXT2_TIND_BLOCK] ||
1075 inode->i_file_acl)) {
1077 inodes_to_process[process_inode_count].inode = *inode;
1137 e2fsck_read_inode(ctx, EXT2_RESIZE_INO, inode,
1138 "recreate inode");
1139 inode->i_mtime = ctx->now;
1140 e2fsck_write_inode(ctx, EXT2_RESIZE_INO, inode,
1141 "recreate inode");
1171 ext2fs_free_mem(&inode);
1224 pctx.inode = ctx->stashed_inode = &inodes_to_process[i].inode;
1230 sprintf(buf, _("reading indirect blocks of inode %u"),
1254 ret = (ib_a->inode.i_block[EXT2_IND_BLOCK] -
1255 ib_b->inode.i_block[EXT2_IND_BLOCK]);
1257 ret = ib_a->inode.i_file_acl - ib_b->inode.i_file_acl;
1264 * Mark an inode as being bad in some what
1274 _("bad inode map"), &ctx->inode_bad_map);
1288 * This procedure will allocate the inode "bb" (badblock) map table
1296 _("inode in bad block map"),
1308 * This procedure will allocate the inode imagic table
1316 _("imagic inode map"),
1414 struct ext2_inode *inode = pctx->inode;
1422 blk = inode->i_file_acl;
1428 * file acl means that the inode is corrupted.
1431 * then the inode is also corrupted.
1466 printf("Inode %u has EA block %u\n", ino, blk);
1497 pctx->blk = inode->i_file_acl;
1585 inode->i_file_acl = 0;
1586 e2fsck_write_inode(ctx, ino, inode, "check_ext_attr");
1592 ext2_ino_t ino, struct ext2_inode *inode,
1600 if ((!LINUX_S_ISDIR(inode->i_mode) &&
1606 pctx->errcode = ext2fs_bmap(fs, ino, inode, 0, 0, 0, &blk);
1649 struct ext2_inode *inode, int restart_flag,
1652 inode->i_flags = 0;
1653 inode->i_links_count = 0;
1655 inode->i_dtime = ctx->now;
1665 * If the inode was partially accounted for before processing
1670 e2fsck_write_inode(ctx, ino, inode, source);
1694 is_dir = LINUX_S_ISDIR(pctx->inode->i_mode);
1825 struct ext2_inode *inode = pctx->inode;
1831 pctx->errcode = ext2fs_extent_open2(fs, ino, inode, &ehandle);
1834 e2fsck_clear_inode(ctx, ino, inode, 0,
1851 inode->i_blocks = 0;
1852 e2fsck_clear_inode(ctx, ino, inode, E2F_FLAG_RESTART,
1860 struct ext2_inode *inode)
1862 return (inode->i_blocks |
1865 (__u64)inode->osd2.linux2.l_i_blocks_hi << 32 : 0));
1869 * This subroutine is called on each inode to account for all of the
1870 * blocks used by that inode.
1878 struct ext2_inode *inode = pctx->inode;
1893 pb.is_dir = LINUX_S_ISDIR(inode->i_mode);
1894 pb.is_reg = LINUX_S_ISREG(inode->i_mode);
1896 pb.inode = inode;
1905 if (inode->i_flags & EXT2_COMPRBLK_FL) {
1911 inode->i_flags &= ~EXT2_COMPRBLK_FL;
1917 if (inode->i_file_acl && check_ext_attr(ctx, pctx, block_buf)) {
1923 if (ext2fs_inode_has_valid_blocks(inode)) {
1924 if (extent_fs && (inode->i_flags & EXT4_EXTENTS_FL))
1939 if (LINUX_S_ISDIR(inode->i_mode))
1946 e2fsck_clear_inode(ctx, ino, inode, E2F_FLAG_RESTART,
1951 if (inode->i_flags & EXT2_INDEX_FL) {
1952 if (handle_htree(ctx, pctx, ino, inode, block_buf)) {
1953 inode->i_flags &= ~EXT2_INDEX_FL;
1964 e2fsck_clear_inode(ctx, ino, inode, 0, "check_blocks");
1972 !(inode->i_flags & EXT4_HUGE_FILE_FL))
1975 printf("inode %u, i_size = %lu, last_block = %lld, i_blocks=%lu, num_blocks = %lu\n",
1976 ino, inode->i_size, pb.last_block, inode->i_blocks,
1980 int nblock = inode->i_size >> EXT2_BLOCK_SIZE_BITS(fs->super);
1981 if (inode->i_size & (fs->blocksize - 1))
1993 size = EXT2_I_SIZE(inode);
1999 !(inode->i_flags & EXT4_EOFBLOCKS_FL))
2001 else if (!(extent_fs && (inode->i_flags & EXT4_EXTENTS_FL)) &&
2005 else if ((extent_fs && (inode->i_flags & EXT4_EXTENTS_FL)) &&
2015 if ((inode->i_flags & EXT4_EOFBLOCKS_FL) &&
2019 inode->i_flags &= ~EXT4_EOFBLOCKS_FL;
2025 if (bad_size && !LINUX_S_ISLNK(inode->i_mode)) {
2029 inode->i_size = pctx->num;
2030 if (!LINUX_S_ISDIR(inode->i_mode))
2031 inode->i_size_high = pctx->num >> 32;
2036 if (LINUX_S_ISREG(inode->i_mode) &&
2037 (inode->i_size_high || inode->i_size & 0x80000000UL))
2039 if ((pb.num_blocks != ext2fs_inode_i_blocks(fs, inode)) ||
2042 (inode->i_flags & EXT4_HUGE_FILE_FL) &&
2043 (inode->osd2.linux2.l_i_blocks_hi != 0))) {
2046 inode->i_blocks = pb.num_blocks;
2047 inode->osd2.linux2.l_i_blocks_hi = 0;
2054 !(inode->i_flags & EXT2_INDEX_FL) &&
2055 ((inode->i_size / fs->blocksize) >= 3))
2060 e2fsck_write_inode(ctx, ino, inode, "check_blocks");
2099 sprintf(problem, "is the inode bitmap of group %d", i);
2105 sprintf(problem, "is in the inode table of group %d",
2142 inode is a regular file. If we're doing a "full
2162 printf("Process_block, inode %lu, block %u, #%d\n", p->ino, blk,
2229 * The resize inode has already be sanity checked
2285 * inode, which is never compressed. So we don't use HOLE_BLKADDR().
2337 * (bitmaps and inode table) and the bad block list.
2399 * If there are bad blocks in the inode table,
2400 * the inode scan code will try to do
2409 * possibility is that the bad block inode meta data
2412 if ((blk == p->inode->i_block[EXT2_IND_BLOCK]) ||
2413 (blk == p->inode->i_block[EXT2_DIND_BLOCK]) ||
2414 (blk == p->inode->i_block[EXT2_TIND_BLOCK])) {
2537 new_table_block(ctx, first_block, i, _("inode bitmap"),
2541 new_table_block(ctx, first_block, i, _("inode table"),
2552 * group descriptors, inode bitmaps, and block bitmaps.
2570 * Mark the blocks used for the inode table
2610 * Mark block used for the inode bitmap
2630 * ext2fs_check_directory; we use them since we already have the inode
2632 * the inode again.
2649 struct ext2_inode *inode)
2655 *inode = *ctx->stashed_inode;
2660 struct ext2_inode *inode)
2665 (inode != ctx->stashed_inode))
2666 *ctx->stashed_inode = *inode;