Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | Upstream-Status: Inappropriate [No Longer Maintained] |
| 2 | |
| 3 | diff -Naur grub-0.97-800/stage2/fsys_ext2fs.c grub-0.97-810/stage2/fsys_ext2fs.c |
| 4 | --- grub-0.97-800/stage2/fsys_ext2fs.c 2008-07-21 00:40:21.668879475 -0600 |
| 5 | +++ grub-0.97-810/stage2/fsys_ext2fs.c 2008-07-21 01:01:11.063953773 -0600 |
| 6 | @@ -79,7 +79,52 @@ |
| 7 | __u32 s_rev_level; /* Revision level */ |
| 8 | __u16 s_def_resuid; /* Default uid for reserved blocks */ |
| 9 | __u16 s_def_resgid; /* Default gid for reserved blocks */ |
| 10 | - __u32 s_reserved[235]; /* Padding to the end of the block */ |
| 11 | + /* |
| 12 | + * These fields are for EXT2_DYNAMIC_REV superblocks only. |
| 13 | + * |
| 14 | + * Note: the difference between the compatible feature set and |
| 15 | + * the incompatible feature set is that if there is a bit set |
| 16 | + * in the incompatible feature set that the kernel doesn't |
| 17 | + * know about, it should refuse to mount the filesystem. |
| 18 | + * |
| 19 | + * e2fsck's requirements are more strict; if it doesn't know |
| 20 | + * about a feature in either the compatible or incompatible |
| 21 | + * feature set, it must abort and not try to meddle with |
| 22 | + * things it doesn't understand... |
| 23 | + */ |
| 24 | + __u32 s_first_ino; /* First non-reserved inode */ |
| 25 | + __u16 s_inode_size; /* size of inode structure */ |
| 26 | + __u16 s_block_group_nr; /* block group # of this superblock */ |
| 27 | + __u32 s_feature_compat; /* compatible feature set */ |
| 28 | + __u32 s_feature_incompat; /* incompatible feature set */ |
| 29 | + __u32 s_feature_ro_compat; /* readonly-compatible feature set */ |
| 30 | + __u8 s_uuid[16]; /* 128-bit uuid for volume */ |
| 31 | + char s_volume_name[16]; /* volume name */ |
| 32 | + char s_last_mounted[64]; /* directory where last mounted */ |
| 33 | + __u32 s_algorithm_usage_bitmap; /* For compression */ |
| 34 | + /* |
| 35 | + * Performance hints. Directory preallocation should only |
| 36 | + * happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on. |
| 37 | + */ |
| 38 | + __u8 s_prealloc_blocks; /* Nr of blocks to try to preallocate*/ |
| 39 | + __u8 s_prealloc_dir_blocks; /* Nr to preallocate for dirs */ |
| 40 | + __u16 s_reserved_gdt_blocks;/* Per group table for online growth */ |
| 41 | + /* |
| 42 | + * Journaling support valid if EXT2_FEATURE_COMPAT_HAS_JOURNAL set. |
| 43 | + */ |
| 44 | + __u8 s_journal_uuid[16]; /* uuid of journal superblock */ |
| 45 | + __u32 s_journal_inum; /* inode number of journal file */ |
| 46 | + __u32 s_journal_dev; /* device number of journal file */ |
| 47 | + __u32 s_last_orphan; /* start of list of inodes to delete */ |
| 48 | + __u32 s_hash_seed[4]; /* HTREE hash seed */ |
| 49 | + __u8 s_def_hash_version; /* Default hash version to use */ |
| 50 | + __u8 s_jnl_backup_type; /* Default type of journal backup */ |
| 51 | + __u16 s_reserved_word_pad; |
| 52 | + __u32 s_default_mount_opts; |
| 53 | + __u32 s_first_meta_bg; /* First metablock group */ |
| 54 | + __u32 s_mkfs_time; /* When the filesystem was created */ |
| 55 | + __u32 s_jnl_blocks[17]; /* Backup of the journal inode */ |
| 56 | + __u32 s_reserved[172]; /* Padding to the end of the block */ |
| 57 | }; |
| 58 | |
| 59 | struct ext2_group_desc |
| 60 | @@ -218,6 +263,14 @@ |
| 61 | #define EXT2_ADDR_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s) / sizeof (__u32)) |
| 62 | #define EXT2_ADDR_PER_BLOCK_BITS(s) (log2(EXT2_ADDR_PER_BLOCK(s))) |
| 63 | |
| 64 | +#define EXT2_GOOD_OLD_REV 0 /* The good old (original) format */ |
| 65 | +#define EXT2_DYNAMIC_REV 1 /* V2 format w/ dynamic inode sizes */ |
| 66 | +#define EXT2_GOOD_OLD_INODE_SIZE 128 |
| 67 | +#define EXT2_INODE_SIZE(s) (((s)->s_rev_level == EXT2_GOOD_OLD_REV) ? \ |
| 68 | + EXT2_GOOD_OLD_INODE_SIZE : \ |
| 69 | + (s)->s_inode_size) |
| 70 | +#define EXT2_INODES_PER_BLOCK(s) (EXT2_BLOCK_SIZE(s)/EXT2_INODE_SIZE(s)) |
| 71 | + |
| 72 | /* linux/ext2_fs.h */ |
| 73 | #define EXT2_BLOCK_SIZE_BITS(s) ((s)->s_log_block_size + 10) |
| 74 | /* kind of from ext2/super.c */ |
| 75 | @@ -553,7 +606,7 @@ |
| 76 | gdp = GROUP_DESC; |
| 77 | ino_blk = gdp[desc].bg_inode_table + |
| 78 | (((current_ino - 1) % (SUPERBLOCK->s_inodes_per_group)) |
| 79 | - >> log2 (EXT2_BLOCK_SIZE (SUPERBLOCK) / sizeof (struct ext2_inode))); |
| 80 | + >> log2 (EXT2_INODES_PER_BLOCK (SUPERBLOCK))); |
| 81 | #ifdef E2DEBUG |
| 82 | printf ("inode table fsblock=%d\n", ino_blk); |
| 83 | #endif /* E2DEBUG */ |
| 84 | @@ -565,13 +618,12 @@ |
| 85 | /* reset indirect blocks! */ |
| 86 | mapblock2 = mapblock1 = -1; |
| 87 | |
| 88 | - raw_inode = INODE + |
| 89 | - ((current_ino - 1) |
| 90 | - & (EXT2_BLOCK_SIZE (SUPERBLOCK) / sizeof (struct ext2_inode) - 1)); |
| 91 | + raw_inode = (struct ext2_inode *)((char *)INODE + |
| 92 | + ((current_ino - 1) & (EXT2_INODES_PER_BLOCK (SUPERBLOCK) - 1)) * |
| 93 | + EXT2_INODE_SIZE (SUPERBLOCK)); |
| 94 | #ifdef E2DEBUG |
| 95 | printf ("ipb=%d, sizeof(inode)=%d\n", |
| 96 | - (EXT2_BLOCK_SIZE (SUPERBLOCK) / sizeof (struct ext2_inode)), |
| 97 | - sizeof (struct ext2_inode)); |
| 98 | + EXT2_INODES_PER_BLOCK (SUPERBLOCK), EXT2_INODE_SIZE (SUPERBLOCK)); |
| 99 | printf ("inode=%x, raw_inode=%x\n", INODE, raw_inode); |
| 100 | printf ("offset into inode table block=%d\n", (int) raw_inode - (int) INODE); |
| 101 | for (i = (unsigned char *) INODE; i <= (unsigned char *) raw_inode; |