Lines Matching refs: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.)
90 struct ext2_inode *inode;
98 struct ext2_inode inode;
126 * Check to make sure a device inode is real. Returns 1 if the device
134 struct ext2_inode *inode)
142 if (inode->i_flags & EXT2_INDEX_FL)
148 * inode's additional i_block fields, there are some rare
149 * occasions when a legitimate device inode will have non-zero
156 if (inode->i_flags & (EXT2_IMMUTABLE_FL | EXT2_APPEND_FL)) {
158 if (inode->i_block[i])
165 * Check to make sure a symlink inode is real. Returns 1 if the symlink
169 struct ext2_inode *inode, char *buf)
178 if ((inode->i_size_high || inode->i_size == 0) ||
179 (inode->i_flags & EXT2_INDEX_FL))
182 if (inode->i_flags & EXT4_EXTENTS_FL) {
183 if (inode->i_size > fs->blocksize)
185 if (ext2fs_extent_open2(fs, ino, inode, &handle))
204 blocks = ext2fs_inode_data_blocks2(fs, inode);
206 if ((inode->i_size >= fs->blocksize) ||
208 (inode->i_block[0] < fs->super->s_first_data_block) ||
209 (inode->i_block[0] >= ext2fs_blocks_count(fs->super)))
213 if (inode->i_block[i])
216 if (io_channel_read_blk64(fs->io, inode->i_block[0], 1, buf))
223 if (inode->i_size >= sizeof(inode->i_block))
226 len = strnlen((char *)inode->i_block, sizeof(inode->i_block));
227 if (len == sizeof(inode->i_block))
230 if (len != inode->i_size)
236 * If the immutable (or append-only) flag is set on the inode, offer
242 if (!(pctx->inode->i_flags & BAD_SPECIAL_FLAGS))
248 pctx->inode->i_flags &= ~BAD_SPECIAL_FLAGS;
249 e2fsck_write_inode(ctx, pctx->ino, pctx->inode, "pass1");
258 struct ext2_inode *inode = pctx->inode;
260 if (EXT2_I_SIZE(inode) == 0)
266 inode->i_size = 0;
267 inode->i_size_high = 0;
268 e2fsck_write_inode(ctx, pctx->ino, pctx->inode, "pass1");
274 struct ext2_inode_large *inode;
280 inode = (struct ext2_inode_large *) pctx->inode;
282 inode->i_extra_isize;
283 start = ((char *) inode) + EXT2_GOOD_OLD_INODE_SIZE +
284 inode->i_extra_isize + sizeof(__u32);
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_checksum_hi);
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;
413 * inode is extent-mapped, it is still the case that the latter
417 if (LINUX_S_ISDIR(inode->i_mode) || LINUX_S_ISREG(inode->i_mode) ||
418 LINUX_S_ISLNK(inode->i_mode) || inode->i_block[0] == 0)
440 if (extent_fs && (inode->i_flags & EXT4_EXTENTS_FL)) {
442 if (ext2fs_bmap2(ctx->fs, pctx->ino, inode, 0, 0, 0, 0,
449 blk = inode->i_block[i];
461 blk = inode->i_block[0];
469 if ((LINUX_S_ISCHR(inode->i_mode) || LINUX_S_ISBLK(inode->i_mode)) &&
470 (inode->i_links_count == 1) && !not_device)
486 (dirent->inode != pctx->ino) ||
504 inode->i_mode = (inode->i_mode & 07777) | LINUX_S_IFDIR;
505 e2fsck_write_inode_full(ctx, pctx->ino, inode,
548 struct ext2_inode *inode;
597 pctx.errcode = e2fsck_allocate_inode_bitmap(fs, _("in-use inode map"),
608 _("directory inode map"),
618 _("regular file inode map"), EXT2FS_BMAP64_RBTREE,
650 inode = (struct ext2_inode *)
651 e2fsck_allocate_memory(ctx, inode_size, "scratch inode");
664 ext2fs_free_mem(&inode);
688 ext2fs_free_mem(&inode);
694 old_op = ehandler_operation(_("opening inode scan"));
702 ext2fs_free_mem(&inode);
706 ctx->stashed_inode = inode;
728 old_op = ehandler_operation(_("getting next inode from scan"));
730 inode, inode_size);
749 pctx.inode = inode;
751 if (inode->i_links_count) {
753 ino, inode->i_links_count);
755 pctx.num = inode->i_links_count;
766 * When the inode is read, the i_block array is not swapped
774 * extent_header_verify is ok. If the inode is cleared,
777 if ((inode->i_flags & EXT4_EXTENTS_FL) && !extent_fs &&
778 (inode->i_links_count || (ino == EXT2_BAD_INO) ||
780 if ((ext2fs_extent_header_verify(inode->i_block,
781 sizeof(inode->i_block)) == 0) &&
788 e2fsck_clear_inode(ctx, ino, inode, 0, "pass1");
798 * If the inode didn't have the extents flag set when it
804 if (extent_fs && !(inode->i_flags & EXT4_EXTENTS_FL) &&
805 (inode->i_links_count || (ino == EXT2_BAD_INO) ||
807 (LINUX_S_ISREG(inode->i_mode) ||
808 LINUX_S_ISDIR(inode->i_mode))) {
814 tmp_block[i] = ext2fs_swab32(inode->i_block[i]);
817 ehp = inode->i_block;
820 sizeof(inode->i_block)) == 0) &&
822 inode->i_flags |= EXT4_EXTENTS_FL;
824 memcpy(inode->i_block, tmp_block,
825 sizeof(inode->i_block));
827 e2fsck_write_inode(ctx, ino, inode, "pass1");
834 if ((inode->i_mode || inode->i_uid || inode->i_gid ||
835 inode->i_links_count || inode->i_file_acl) &&
837 memset(inode, 0, sizeof(struct ext2_inode));
838 e2fsck_write_inode(ctx, ino, inode,
839 "clear bad inode");
856 pb.inode = inode;
877 * Make sure the root inode is a directory; if
881 if (!LINUX_S_ISDIR(inode->i_mode)) {
894 if (inode->i_dtime && inode->i_links_count) {
896 inode->i_dtime = 0;
897 e2fsck_write_inode(ctx, ino, inode,
904 if (!LINUX_S_ISREG(inode->i_mode) &&
907 inode->i_mode = LINUX_S_IFREG;
908 e2fsck_write_inode(ctx, ino, inode,
914 if ((inode->i_links_count ||
915 inode->i_blocks || inode->i_block[0]) &&
918 memset(inode, 0, inode_size);
921 e2fsck_write_inode_full(ctx, ino, inode,
931 if (!LINUX_S_ISREG(inode->i_mode) &&
934 inode->i_mode = LINUX_S_IFREG;
935 e2fsck_write_inode(ctx, ino, inode,
941 if ((inode->i_links_count ||
942 inode->i_blocks || inode->i_block[0]) &&
945 memset(inode, 0, inode_size);
948 e2fsck_write_inode_full(ctx, ino, inode,
956 if (LINUX_S_ISDIR(inode->i_mode))
959 if (inode->i_mode &&
960 !LINUX_S_ISREG(inode->i_mode))
963 if (inode->i_mode != 0)
968 inode->i_mode = 0;
969 e2fsck_write_inode(ctx, ino, inode,
987 * inodes where i_size and the inode blocks are
994 if (inode->i_dtime && !busted_fs_time &&
995 inode->i_dtime < ctx->fs->super->s_inodes_count) {
997 inode->i_dtime = inode->i_links_count ?
999 e2fsck_write_inode(ctx, ino, inode,
1008 if (!inode->i_links_count) {
1009 if (!inode->i_dtime && inode->i_mode) {
1012 inode->i_dtime = ctx->now;
1013 e2fsck_write_inode(ctx, ino, inode,
1029 if (inode->i_dtime) {
1031 inode->i_dtime = 0;
1032 e2fsck_write_inode(ctx, ino, inode, "pass1");
1039 frag = inode->osd2.hurd2.h_i_frag;
1040 fsize = inode->osd2.hurd2.h_i_fsize;
1046 if (inode->i_faddr || frag || fsize ||
1047 (LINUX_S_ISDIR(inode->i_mode) && inode->i_dir_acl))
1051 inode->osd2.linux2.l_i_file_acl_high != 0)
1056 (inode->osd2.linux2.l_i_blocks_hi != 0))
1058 if (inode->i_flags & EXT2_IMAGIC_FL) {
1066 inode->i_flags &= ~EXT2_IMAGIC_FL;
1068 inode, "pass1");
1080 if (extent_fs && (inode->i_flags & EXT4_EXTENTS_FL) &&
1081 LINUX_S_ISLNK(inode->i_mode) &&
1082 !ext2fs_inode_has_valid_blocks2(fs, inode) &&
1084 inode->i_flags &= ~EXT4_EXTENTS_FL;
1085 e2fsck_write_inode(ctx, ino, inode, "pass1");
1088 if (LINUX_S_ISDIR(inode->i_mode)) {
1092 } else if (LINUX_S_ISREG (inode->i_mode)) {
1095 } else if (LINUX_S_ISCHR (inode->i_mode) &&
1096 e2fsck_pass1_check_device_inode(fs, inode)) {
1100 } else if (LINUX_S_ISBLK (inode->i_mode) &&
1101 e2fsck_pass1_check_device_inode(fs, inode)) {
1105 } else if (LINUX_S_ISLNK (inode->i_mode) &&
1106 e2fsck_pass1_check_symlink(fs, ino, inode,
1110 if (ext2fs_inode_data_blocks(fs, inode) == 0) {
1116 else if (LINUX_S_ISFIFO (inode->i_mode) &&
1117 e2fsck_pass1_check_device_inode(fs, inode)) {
1121 } else if ((LINUX_S_ISSOCK (inode->i_mode)) &&
1122 e2fsck_pass1_check_device_inode(fs, inode)) {
1128 if (!(inode->i_flags & EXT4_EXTENTS_FL)) {
1129 if (inode->i_block[EXT2_IND_BLOCK])
1131 if (inode->i_block[EXT2_DIND_BLOCK])
1133 if (inode->i_block[EXT2_TIND_BLOCK])
1136 if (!(inode->i_flags & EXT4_EXTENTS_FL) &&
1137 (inode->i_block[EXT2_IND_BLOCK] ||
1138 inode->i_block[EXT2_DIND_BLOCK] ||
1139 inode->i_block[EXT2_TIND_BLOCK] ||
1140 ext2fs_file_acl_block(fs, inode))) {
1142 inodes_to_process[process_inode_count].inode = *inode;
1202 e2fsck_read_inode(ctx, EXT2_RESIZE_INO, inode,
1203 "recreate inode");
1204 inode->i_mtime = ctx->now;
1205 e2fsck_write_inode(ctx, EXT2_RESIZE_INO, inode,
1206 "recreate inode");
1236 ext2fs_free_mem(&inode);
1289 pctx.inode = ctx->stashed_inode = &inodes_to_process[i].inode;
1295 sprintf(buf, _("reading indirect blocks of inode %u"),
1319 ret = (ib_a->inode.i_block[EXT2_IND_BLOCK] -
1320 ib_b->inode.i_block[EXT2_IND_BLOCK]);
1327 ret = ext2fs_file_acl_block(0, &(ib_a->inode)) -
1328 ext2fs_file_acl_block(0, &(ib_b->inode));
1335 * Mark an inode as being bad in some what
1345 _("bad inode map"), EXT2FS_BMAP64_RBTREE,
1360 * This procedure will allocate the inode "bb" (badblock) map table
1368 _("inode in bad block map"), EXT2FS_BMAP64_RBTREE,
1380 * This procedure will allocate the inode imagic table
1388 _("imagic inode map"), EXT2FS_BMAP64_RBTREE,
1497 struct ext2_inode *inode = pctx->inode;
1505 blk = ext2fs_file_acl_block(fs, inode);
1511 * file acl means that the inode is corrupted.
1514 * then the inode is also corrupted.
1581 pctx->blk = ext2fs_file_acl_block(fs, inode);
1669 ext2fs_file_acl_block_set(fs, inode, 0);
1670 e2fsck_write_inode(ctx, ino, inode, "check_ext_attr");
1676 ext2_ino_t ino, struct ext2_inode *inode,
1684 if ((!LINUX_S_ISDIR(inode->i_mode) &&
1690 pctx->errcode = ext2fs_bmap2(fs, ino, inode, 0, 0, 0, 0, &blk);
1733 struct ext2_inode *inode, int restart_flag,
1736 inode->i_flags = 0;
1737 inode->i_links_count = 0;
1739 inode->i_dtime = ctx->now;
1749 * If the inode was partially accounted for before processing
1755 memset(inode, 0, sizeof(struct ext2_inode));
1757 e2fsck_write_inode(ctx, ino, inode, source);
1782 is_dir = LINUX_S_ISDIR(pctx->inode->i_mode);
1958 struct ext2_inode *inode = pctx->inode;
1965 pctx->errcode = ext2fs_extent_open2(fs, ino, inode, &ehandle);
1968 e2fsck_clear_inode(ctx, ino, inode, 0,
1981 eof_lblk = ((EXT2_I_SIZE(inode) + fs->blocksize - 1) >>
1987 inode->i_blocks = 0;
1988 e2fsck_clear_inode(ctx, ino, inode, E2F_FLAG_RESTART,
1996 * This subroutine is called on each inode to account for all of the
1997 * blocks used by that inode.
2005 struct ext2_inode *inode = pctx->inode;
2021 pb.is_dir = LINUX_S_ISDIR(inode->i_mode);
2022 pb.is_reg = LINUX_S_ISREG(inode->i_mode);
2024 pb.inode = inode;
2033 if (inode->i_flags & EXT2_COMPRBLK_FL) {
2039 inode->i_flags &= ~EXT2_COMPRBLK_FL;
2045 if (ext2fs_file_acl_block(fs, inode) &&
2052 if (ext2fs_inode_has_valid_blocks2(fs, inode)) {
2053 if (extent_fs && (inode->i_flags & EXT4_EXTENTS_FL))
2074 if (LINUX_S_ISDIR(inode->i_mode))
2081 e2fsck_clear_inode(ctx, ino, inode, E2F_FLAG_RESTART,
2086 if (inode->i_flags & EXT2_INDEX_FL) {
2087 if (handle_htree(ctx, pctx, ino, inode, block_buf)) {
2088 inode->i_flags &= ~EXT2_INDEX_FL;
2099 e2fsck_clear_inode(ctx, ino, inode, 0, "check_blocks");
2106 quota_data_add(ctx->qctx, inode, ino,
2108 quota_data_inodes(ctx->qctx, inode, ino, +1);
2113 !(inode->i_flags & EXT4_HUGE_FILE_FL))
2117 printf("inode %u, i_size = %u, last_block = %lld, i_blocks=%llu, num_blocks = %llu\n",
2118 ino, inode->i_size, pb.last_block, ext2fs_inode_i_blocks(fs, inode),
2122 int nblock = inode->i_size >> EXT2_BLOCK_SIZE_BITS(fs->super);
2123 if (inode->i_size & (fs->blocksize - 1))
2135 size = EXT2_I_SIZE(inode);
2143 else if (!(extent_fs && (inode->i_flags & EXT4_EXTENTS_FL)) &&
2147 else if ((extent_fs && (inode->i_flags & EXT4_EXTENTS_FL)) &&
2154 if (bad_size && !LINUX_S_ISLNK(inode->i_mode)) {
2158 inode->i_size = pctx->num;
2159 if (!LINUX_S_ISDIR(inode->i_mode))
2160 inode->i_size_high = pctx->num >> 32;
2165 if (LINUX_S_ISREG(inode->i_mode) &&
2166 ext2fs_needs_large_file_feature(EXT2_I_SIZE(inode)))
2168 if ((pb.num_blocks != ext2fs_inode_i_blocks(fs, inode)) ||
2171 (inode->i_flags & EXT4_HUGE_FILE_FL) &&
2172 (inode->osd2.linux2.l_i_blocks_hi != 0))) {
2175 inode->i_blocks = pb.num_blocks;
2176 inode->osd2.linux2.l_i_blocks_hi = pb.num_blocks >> 32;
2183 !(inode->i_flags & EXT2_INDEX_FL) &&
2184 ((inode->i_size / fs->blocksize) >= 3))
2189 e2fsck_write_inode(ctx, ino, inode, "check_blocks");
2228 sprintf(problem, "is the inode bitmap of group %d", i);
2234 sprintf(problem, "is in the inode table of group %d",
2271 inode is a regular file. If we're doing a "full
2291 printf("Process_block, inode %lu, block %u, #%d\n", p->ino, blk,
2357 * The resize inode has already be sanity checked
2421 * inode, which is never compressed. So we don't use HOLE_BLKADDR().
2473 * (bitmaps and inode table) and the bad block list.
2535 * If there are bad blocks in the inode table,
2536 * the inode scan code will try to do
2545 * possibility is that the bad block inode meta data
2548 if ((blk == p->inode->i_block[EXT2_IND_BLOCK]) ||
2549 (blk == p->inode->i_block[EXT2_DIND_BLOCK]) ||
2550 (blk == p->inode->i_block[EXT2_TIND_BLOCK])) {
2679 new_table_block(ctx, first_block, i, _("inode bitmap"),
2685 new_table_block(ctx, first_block, i, _("inode table"),
2697 * group descriptors, inode bitmaps, and block bitmaps.
2715 * Mark the blocks used for the inode table
2755 * Mark block used for the inode bitmap
2775 * ext2fs_check_directory; we use them since we already have the inode
2777 * the inode again.
2794 struct ext2_inode *inode)
2800 *inode = *ctx->stashed_inode;
2805 struct ext2_inode *inode)
2810 (inode != ctx->stashed_inode))
2811 *ctx->stashed_inode = *inode;