ia64/xen-unstable

changeset 17469:c777e572a467

[LIBFSIMAGE] Support 256 byte inodes on ext3

Patch taken from Debian grub package version 0.97-32.
See http://bugs.debian.org/463236 & http://bugs.debian.org/463123

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Apr 16 09:45:44 2008 +0100 (2008-04-16)
parents c3efeb3095ac
children 1ac2a314aa3c
files tools/libfsimage/ext2fs/fsys_ext2fs.c
line diff
     1.1 --- a/tools/libfsimage/ext2fs/fsys_ext2fs.c	Wed Apr 16 09:32:45 2008 +0100
     1.2 +++ b/tools/libfsimage/ext2fs/fsys_ext2fs.c	Wed Apr 16 09:45:44 2008 +0100
     1.3 @@ -77,7 +77,52 @@ struct ext2_super_block
     1.4      __u32 s_rev_level;		/* Revision level */
     1.5      __u16 s_def_resuid;		/* Default uid for reserved blocks */
     1.6      __u16 s_def_resgid;		/* Default gid for reserved blocks */
     1.7 -    __u32 s_reserved[235];	/* Padding to the end of the block */
     1.8 +    /*
     1.9 +     * These fields are for EXT2_DYNAMIC_REV superblocks only.
    1.10 +     *
    1.11 +     * Note: the difference between the compatible feature set and
    1.12 +     * the incompatible feature set is that if there is a bit set
    1.13 +     * in the incompatible feature set that the kernel doesn't
    1.14 +     * know about, it should refuse to mount the filesystem.
    1.15 +     *
    1.16 +     * e2fsck's requirements are more strict; if it doesn't know
    1.17 +     * about a feature in either the compatible or incompatible
    1.18 +     * feature set, it must abort and not try to meddle with
    1.19 +     * things it doesn't understand...
    1.20 +     */
    1.21 +    __u32 s_first_ino;		/* First non-reserved inode */
    1.22 +    __u16 s_inode_size;		/* size of inode structure */
    1.23 +    __u16 s_block_group_nr;	/* block group # of this superblock */
    1.24 +    __u32 s_feature_compat;	/* compatible feature set */
    1.25 +    __u32 s_feature_incompat;	/* incompatible feature set */
    1.26 +    __u32 s_feature_ro_compat;	/* readonly-compatible feature set */
    1.27 +    __u8  s_uuid[16];		/* 128-bit uuid for volume */
    1.28 +    char  s_volume_name[16];	/* volume name */
    1.29 +    char  s_last_mounted[64];	/* directory where last mounted */
    1.30 +    __u32 s_algorithm_usage_bitmap; /* For compression */
    1.31 +    /*
    1.32 +     * Performance hints.  Directory preallocation should only
    1.33 +     * happen if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is on.
    1.34 +     */
    1.35 +    __u8  s_prealloc_blocks;	/* Nr of blocks to try to preallocate*/
    1.36 +    __u8  s_prealloc_dir_blocks;	/* Nr to preallocate for dirs */
    1.37 +    __u16 s_reserved_gdt_blocks;/* Per group table for online growth */
    1.38 +    /*
    1.39 +     * Journaling support valid if EXT2_FEATURE_COMPAT_HAS_JOURNAL set.
    1.40 +     */
    1.41 +    __u8 s_journal_uuid[16];	/* uuid of journal superblock */
    1.42 +    __u32 s_journal_inum;	/* inode number of journal file */
    1.43 +    __u32 s_journal_dev;	/* device number of journal file */
    1.44 +    __u32 s_last_orphan;	/* start of list of inodes to delete */
    1.45 +    __u32 s_hash_seed[4];	/* HTREE hash seed */
    1.46 +    __u8  s_def_hash_version;	/* Default hash version to use */
    1.47 +    __u8  s_jnl_backup_type; 	/* Default type of journal backup */
    1.48 +    __u16 s_reserved_word_pad;
    1.49 +    __u32 s_default_mount_opts;
    1.50 +    __u32 s_first_meta_bg;	/* First metablock group */
    1.51 +    __u32 s_mkfs_time;		/* When the filesystem was created */
    1.52 +    __u32 s_jnl_blocks[17]; 	/* Backup of the journal inode */
    1.53 +    __u32 s_reserved[172];	/* Padding to the end of the block */
    1.54    };
    1.55  
    1.56  struct ext2_group_desc
    1.57 @@ -216,6 +261,9 @@ struct ext2_dir_entry
    1.58  #define EXT2_ADDR_PER_BLOCK(s)          (EXT2_BLOCK_SIZE(s) / sizeof (__u32))
    1.59  #define EXT2_ADDR_PER_BLOCK_BITS(s)		(log2(EXT2_ADDR_PER_BLOCK(s)))
    1.60  
    1.61 +#define EXT2_INODE_SIZE(s)		(SUPERBLOCK->s_inode_size)
    1.62 +#define EXT2_INODES_PER_BLOCK(s)	(EXT2_BLOCK_SIZE(s)/EXT2_INODE_SIZE(s))
    1.63 +
    1.64  /* linux/ext2_fs.h */
    1.65  #define EXT2_BLOCK_SIZE_BITS(s)        ((s)->s_log_block_size + 10)
    1.66  /* kind of from ext2/super.c */
    1.67 @@ -537,7 +585,7 @@ ext2fs_dir (fsi_file_t *ffi, char *dirna
    1.68        gdp = GROUP_DESC;
    1.69        ino_blk = gdp[desc].bg_inode_table +
    1.70  	(((current_ino - 1) % (SUPERBLOCK->s_inodes_per_group))
    1.71 -	 >> log2 (EXT2_BLOCK_SIZE (SUPERBLOCK) / sizeof (struct ext2_inode)));
    1.72 +	 >> log2 (EXT2_INODES_PER_BLOCK (SUPERBLOCK)));
    1.73  #ifdef E2DEBUG
    1.74        printf ("inode table fsblock=%d\n", ino_blk);
    1.75  #endif /* E2DEBUG */
    1.76 @@ -549,13 +597,12 @@ ext2fs_dir (fsi_file_t *ffi, char *dirna
    1.77        /* reset indirect blocks! */
    1.78        mapblock2 = mapblock1 = -1;
    1.79  
    1.80 -      raw_inode = INODE +
    1.81 -	((current_ino - 1)
    1.82 -	 & (EXT2_BLOCK_SIZE (SUPERBLOCK) / sizeof (struct ext2_inode) - 1));
    1.83 +      raw_inode = (struct ext2_inode *)((char *)INODE +
    1.84 +	((current_ino - 1) & (EXT2_INODES_PER_BLOCK (SUPERBLOCK) - 1)) *
    1.85 +	EXT2_INODE_SIZE (SUPERBLOCK));
    1.86  #ifdef E2DEBUG
    1.87        printf ("ipb=%d, sizeof(inode)=%d\n",
    1.88 -	      (EXT2_BLOCK_SIZE (SUPERBLOCK) / sizeof (struct ext2_inode)),
    1.89 -	      sizeof (struct ext2_inode));
    1.90 +	      EXT2_INODES_PER_BLOCK (SUPERBLOCK), EXT2_INODE_SIZE (SUPERBLOCK));
    1.91        printf ("inode=%x, raw_inode=%x\n", INODE, raw_inode);
    1.92        printf ("offset into inode table block=%d\n", (int) raw_inode - (int) INODE);
    1.93        for (i = (unsigned char *) INODE; i <= (unsigned char *) raw_inode;