Whamcloud - gitweb
Fix a byte swap bugs, including one which caused e2fsck to
authorTheodore Ts'o <tytso@mit.edu>
Fri, 30 Jan 2004 06:48:06 +0000 (01:48 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 30 Jan 2004 06:48:06 +0000 (01:48 -0500)
incorrectly treat as valid symlinks created with SE Linux
(Debian bug #228723) as well as failing the f_journal test case on
big endian systems due to the backup journal blocks not being swapped.

e2fsck/ChangeLog
e2fsck/pass2.c
lib/ext2fs/ChangeLog
lib/ext2fs/ext2_fs.h
lib/ext2fs/swapfs.c

index 754a688..6adb24c 100644 (file)
@@ -1,3 +1,9 @@
+2004-01-30  Theodore Ts'o  <tytso@mit.edu>
+
+       * pass2.c (deallocate_inode_block): Check to make sure the block
+               number is invalid before deallocating it, to avoid core
+               dumping e2fsck.
+
 2003-12-12  Theodore Ts'o  <tytso@mit.edu>
 
        * pass3.c (check_directory): When reconnecting a directory, we may
index c3858ab..774294c 100644 (file)
@@ -1083,6 +1083,9 @@ static int deallocate_inode_block(ext2_filsys fs,
        
        if (HOLE_BLKADDR(*block_nr))
                return 0;
+       if ((*block_nr < fs->super->s_first_data_block) ||
+           (*block_nr >= fs->super->s_blocks_count))
+               return 0;
        ext2fs_unmark_block_bitmap(ctx->block_found_map, *block_nr);
        ext2fs_block_alloc_stats(fs, *block_nr, -1);
        return 0;
index 586abc1..61a62f4 100644 (file)
@@ -1,3 +1,15 @@
+2004-01-30  Theodore Ts'o  <tytso@mit.edu>
+
+       * ext2_fs.h: Reserve an extra 4 bytes for the journal backup,
+               which we're using due to a typo in the e2fsck code.  (Oops)
+
+       * swapfs.c (ext2fs_swap_inode): Fix byte swap bug which causes SE
+               Linux created symlinks with mandatory attributes to fail
+               to be properly handled on big endian systems.  (Addresses
+               Debian Bug #228723).
+               (ext2fs_swap_super): Byte swap some new fields in the
+               superblock, including the journal backup fields.
+
 2003-12-02  Theodore Ts'o  <tytso@mit.edu>
 
        * alloc.c, bb_inode.c, bitops.c, block.c, check_desc.c, closefs.c,
index f9f96b5..0313c3e 100644 (file)
@@ -446,8 +446,8 @@ struct ext2_super_block {
        __u32   s_default_mount_opts;
        __u32   s_first_meta_bg;        /* First metablock group */
        __u32   s_mkfs_time;            /* When the filesystem was created */
-       __u32   s_jnl_blocks[16];       /* Backup of the journal inode */
-       __u32   s_reserved[173];        /* Padding to the end of the block */
+       __u32   s_jnl_blocks[17];       /* Backup of the journal inode */
+       __u32   s_reserved[172];        /* Padding to the end of the block */
 };
 
 /*
index e375c63..41e6fc3 100644 (file)
@@ -57,9 +57,14 @@ void ext2fs_swap_super(struct ext2_super_block * sb)
        sb->s_journal_inum = ext2fs_swab32(sb->s_journal_inum);
        sb->s_journal_dev = ext2fs_swab32(sb->s_journal_dev);
        sb->s_last_orphan = ext2fs_swab32(sb->s_last_orphan);
+       sb->s_default_mount_opts = ext2fs_swab32(sb->s_default_mount_opts);
        sb->s_first_meta_bg = ext2fs_swab32(sb->s_first_meta_bg);
+       sb->s_mkfs_time = ext2fs_swab32(sb->s_mkfs_time);
        for (i=0; i < 4; i++)
                sb->s_hash_seed[i] = ext2fs_swab32(sb->s_hash_seed[i]);
+       for (i=0; i < 17; i++)
+               sb->s_jnl_blocks[i] = ext2fs_swab32(sb->s_jnl_blocks[i]);
+
 }
 
 void ext2fs_swap_group_desc(struct ext2_group_desc *gdp)
@@ -93,7 +98,9 @@ void ext2fs_swap_inode(ext2_filsys fs, struct ext2_inode *t,
        t->i_links_count = ext2fs_swab16(f->i_links_count);
        t->i_blocks = ext2fs_swab32(f->i_blocks);
        t->i_flags = ext2fs_swab32(f->i_flags);
-       if (!islnk || f->i_blocks) {
+       t->i_file_acl = ext2fs_swab32(f->i_file_acl);
+       t->i_dir_acl = ext2fs_swab32(f->i_dir_acl);
+       if (!islnk || ext2fs_inode_data_blocks(fs, t)) {
                for (i = 0; i < EXT2_N_BLOCKS; i++)
                        t->i_block[i] = ext2fs_swab32(f->i_block[i]);
        } else if (t != f) {
@@ -101,8 +108,6 @@ void ext2fs_swap_inode(ext2_filsys fs, struct ext2_inode *t,
                        t->i_block[i] = f->i_block[i];
        }
        t->i_generation = ext2fs_swab32(f->i_generation);
-       t->i_file_acl = ext2fs_swab32(f->i_file_acl);
-       t->i_dir_acl = ext2fs_swab32(f->i_dir_acl);
        t->i_faddr = ext2fs_swab32(f->i_faddr);
 
        switch (fs->super->s_creator_os) {