From 1c27cac2e848300a515cc994bc71ee48e2f3fa19 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Thu, 14 Aug 1997 17:20:42 +0000 Subject: [PATCH] ChangeLog, .del-io.h~72680822, irel_ma.c, llseek.c, rw_bitmaps.c: io.h: Change the prototype of ext2fs_llseek() to use int's instead of unsigned int's. llseek.c: Change to allow PIC and !HAVE_LLSEEK. Add a prototype to make life easer for GNU Libc 2. rw_bitmaps.c: On the PowerPC, the big-endian variant of the ext2 filesystem has its bitmaps stored as 32-bit words with bit 0 as the LSB of each word. Thus a bitmap with only bit 0 set would be, as a string of bytes, 00 00 00 01 00 ... To cope with this, we byte-reverse each word of a bitmap if we have a big-endian filesystem, that is, if we are *not* byte-swapping other word-sized numbers. ChangeLog, expect.1, image.gz: f_badinode: Modify test to check for "bad" character and block devices (i.e., ones which contain garbage block entries) --- lib/ext2fs/ChangeLog | 16 ++++++++++++++++ lib/ext2fs/io.h | 2 +- lib/ext2fs/irel_ma.c | 2 +- lib/ext2fs/llseek.c | 26 ++++++++++++++++++-------- lib/ext2fs/rw_bitmaps.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ tests/ChangeLog | 5 +++++ tests/f_badinode/expect.1 | 10 ++++++++-- tests/f_badinode/image.gz | Bin 1037 -> 1109 bytes 8 files changed, 93 insertions(+), 12 deletions(-) diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog index 68e9ed0..47ee666 100644 --- a/lib/ext2fs/ChangeLog +++ b/lib/ext2fs/ChangeLog @@ -1,3 +1,19 @@ +Thu Aug 14 08:14:17 1997 Theodore Ts'o + + * io.h: Change the prototype of ext2fs_llseek() to use int's + instead of unsigned int's. + + * llseek.c: Change to allow PIC and !HAVE_LLSEEK. Add a prototype + to make life easer for GNU Libc 2. + + * rw_bitmaps.c: On the PowerPC, the big-endian variant of the ext2 + filesystem has its bitmaps stored as 32-bit words with bit + 0 as the LSB of each word. Thus a bitmap with only bit 0 + set would be, as a string of bytes, 00 00 00 01 00 ... To + cope with this, we byte-reverse each word of a bitmap if + we have a big-endian filesystem, that is, if we are *not* + byte-swapping other word-sized numbers. + Mon Aug 11 03:30:48 1997 Theodore Ts'o * dosio.c: New file to do DOS/BIOS disk accesses. diff --git a/lib/ext2fs/io.h b/lib/ext2fs/io.h index efc8ff8..f40d56e 100644 --- a/lib/ext2fs/io.h +++ b/lib/ext2fs/io.h @@ -19,7 +19,7 @@ typedef long ext2_loff_t; #endif /* llseek.c */ -ext2_loff_t ext2fs_llseek (unsigned int, ext2_loff_t, unsigned int); +ext2_loff_t ext2fs_llseek (int, ext2_loff_t, int); typedef struct struct_io_manager *io_manager; typedef struct struct_io_channel *io_channel; diff --git a/lib/ext2fs/irel_ma.c b/lib/ext2fs/irel_ma.c index 8a9ac74..54b71dd 100644 --- a/lib/ext2fs/irel_ma.c +++ b/lib/ext2fs/irel_ma.c @@ -336,7 +336,7 @@ static errcode_t ima_delete(ext2_irel irel, ino_t old) free(ma->ref_entries[(unsigned) old].refs); ma->orig_map[ma->entries[(unsigned) old].orig] = 0; - ma->ref_entries[(unsinged) old].num = 0; + ma->ref_entries[(unsigned) old].num = 0; ma->ref_entries[(unsigned) old].refs = 0; return 0; } diff --git a/lib/ext2fs/llseek.c b/lib/ext2fs/llseek.c index 9e9d484..cd47b2d 100644 --- a/lib/ext2fs/llseek.c +++ b/lib/ext2fs/llseek.c @@ -1,7 +1,7 @@ /* * llseek.c -- stub calling the llseek system call * - * Copyright (C) 1994, 1995, 1996 Theodore Ts'o. + * Copyright (C) 1994, 1995, 1996, 1997 Theodore Ts'o. * * %Begin-Header% * This file may be redistributed under the terms of the GNU Public @@ -30,6 +30,12 @@ #endif #include +#if (__GLIBC__ == 2) +ext2_loff_t llseek (int fd, ext2_loff_t offset, int origin) +#endif + +#define my_llseek llseek + #else /* HAVE_LLSEEK */ #ifdef __alpha__ @@ -44,21 +50,26 @@ #define __NR__llseek 140 #endif +#ifndef __i386__ static int _llseek (unsigned int, unsigned long, unsigned long, ext2_loff_t *, unsigned int); static _syscall5(int,_llseek,unsigned int,fd,unsigned long,offset_high, unsigned long, offset_low,ext2_loff_t *,result, unsigned int, origin) +#endif -static ext2_loff_t llseek (unsigned int fd, ext2_loff_t offset, - unsigned int origin) +static ext2_loff_t my_llseek (int fd, ext2_loff_t offset, int origin) { ext2_loff_t result; int retval; - retval = _llseek (fd, ((unsigned long long) offset) >> 32, - ((unsigned long long) offset) & 0xffffffff, +#ifndef __i386__ + retval = _llseek(fd, ((unsigned long long) offset) >> 32, +#else + retval = syscall(__NR__llseek, fd, (unsigned long long) (offset >> 32), +#endif + ((unsigned long long) offset) & 0xffffffff, &result, origin); return (retval == -1 ? (ext2_loff_t) retval : result); } @@ -67,8 +78,7 @@ static ext2_loff_t llseek (unsigned int fd, ext2_loff_t offset, #endif /* __alpha__ */ -ext2_loff_t ext2fs_llseek (unsigned int fd, ext2_loff_t offset, - unsigned int origin) +ext2_loff_t ext2fs_llseek (int fd, ext2_loff_t offset, int origin) { ext2_loff_t result; static int do_compat = 0; @@ -82,7 +92,7 @@ ext2_loff_t ext2fs_llseek (unsigned int fd, ext2_loff_t offset, return -1; } - result = llseek (fd, offset, origin); + result = my_llseek (fd, offset, origin); if (result == -1 && errno == ENOSYS) { /* * Just in case this code runs on top of an old kernel diff --git a/lib/ext2fs/rw_bitmaps.c b/lib/ext2fs/rw_bitmaps.c index 5deca2c..d3aa7bb 100644 --- a/lib/ext2fs/rw_bitmaps.c +++ b/lib/ext2fs/rw_bitmaps.c @@ -27,6 +27,30 @@ #include "ext2fs.h" +#ifdef __powerpc__ +/* + * On the PowerPC, the big-endian variant of the ext2 filesystem + * has its bitmaps stored as 32-bit words with bit 0 as the LSB + * of each word. Thus a bitmap with only bit 0 set would be, as + * a string of bytes, 00 00 00 01 00 ... + * To cope with this, we byte-reverse each word of a bitmap if + * we have a big-endian filesystem, that is, if we are *not* + * byte-swapping other word-sized numbers. + */ +#define EXT2_BIG_ENDIAN_BITMAPS +#endif + +#ifdef EXT2_BIG_ENDIAN_BITMAPS +void ext2fs_swap_bitmap(ext2_filsys fs, char *bitmap, int nbytes) +{ + __u32 *p = (__u32 *) bitmap; + int n; + + for (n = nbytes / sizeof(__u32); n > 0; --n, ++p) + *p = ext2fs_swab32(*p); +} +#endif + errcode_t ext2fs_write_inode_bitmap(ext2_filsys fs) { int i; @@ -52,6 +76,11 @@ errcode_t ext2fs_write_inode_bitmap(ext2_filsys fs) memcpy(bitmap_block, inode_bitmap, nbytes); blk = fs->group_desc[i].bg_inode_bitmap; if (blk) { +#ifdef EXT2_BIG_ENDIAN_BITMAPS + if (!((fs->flags & EXT2_FLAG_SWAP_BYTES) || + (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE))) + ext2fs_swap_bitmap(fs, bitmap_block, nbytes); +#endif retval = io_channel_write_blk(fs->io, blk, 1, bitmap_block); if (retval) @@ -100,6 +129,11 @@ errcode_t ext2fs_write_block_bitmap (ext2_filsys fs) } blk = fs->group_desc[i].bg_block_bitmap; if (blk) { +#ifdef EXT2_BIG_ENDIAN_BITMAPS + if (!((fs->flags & EXT2_FLAG_SWAP_BYTES) || + (fs->flags & EXT2_FLAG_SWAP_BYTES_WRITE))) + ext2fs_swap_bitmap(fs, bitmap_block, nbytes); +#endif retval = io_channel_write_blk(fs->io, blk, 1, bitmap_block); if (retval) @@ -158,6 +192,11 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) retval = EXT2_ET_BLOCK_BITMAP_READ; goto cleanup; } +#ifdef EXT2_BIG_ENDIAN_BITMAPS + if (!((fs->flags & EXT2_FLAG_SWAP_BYTES) || + (fs->flags & EXT2_FLAG_SWAP_BYTES_READ))) + ext2fs_swap_bitmap(fs, block_bitmap, block_nbytes); +#endif } else memset(block_bitmap, 0, block_nbytes); block_bitmap += block_nbytes; @@ -171,6 +210,11 @@ static errcode_t read_bitmaps(ext2_filsys fs, int do_inode, int do_block) retval = EXT2_ET_INODE_BITMAP_READ; goto cleanup; } +#ifdef EXT2_BIG_ENDIAN_BITMAPS + if (!((fs->flags & EXT2_FLAG_SWAP_BYTES) || + (fs->flags & EXT2_FLAG_SWAP_BYTES_READ))) + ext2fs_swap_bitmap(fs, inode_bitmap, inode_nbytes); +#endif } else memset(inode_bitmap, 0, inode_nbytes); inode_bitmap += inode_nbytes; diff --git a/tests/ChangeLog b/tests/ChangeLog index f9534ce..0543a9d 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,8 @@ +Thu Aug 14 11:25:23 1997 Theodore Ts'o + + * f_badinode: Modify test to check for "bad" character and block + devices (i.e., ones which contain garbage block entries) + Tue Jun 17 01:33:20 1997 Theodore Ts'o * Release of E2fsprogs 1.11 diff --git a/tests/f_badinode/expect.1 b/tests/f_badinode/expect.1 index b2da205..67120d0 100644 --- a/tests/f_badinode/expect.1 +++ b/tests/f_badinode/expect.1 @@ -11,6 +11,12 @@ Clear? yes i_file_acl for inode 13 (/timings) is 39, should be zero. Clear? yes +Inode 14 (/block_dev) is an illegal block device. +Clear? yes + +Inode 15 (/char_dev) is an illegal character device. +Clear? yes + Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information @@ -19,8 +25,8 @@ Fix summary information? yes Block bitmap differences: -25. FIXED Free blocks count wrong for group 0 (76, counted=77). FIXED Free blocks count wrong (76, counted=77). FIXED -Free inodes count wrong for group #0 (19, counted=20). FIXED -Free inodes count wrong (19, counted=20). FIXED +Free inodes count wrong for group #0 (17, counted=20). FIXED +Free inodes count wrong (17, counted=20). FIXED test_filesys: ***** FILE SYSTEM WAS MODIFIED ***** test_filesys: 12/32 files (0.0% non-contiguous), 23/100 blocks diff --git a/tests/f_badinode/image.gz b/tests/f_badinode/image.gz index 7b3ccd2a77f09f8123aecfe86dedf64ecbdc64d5..e399c4b190705b92a3424f59e71ac62c322facd3 100644 GIT binary patch delta 1016 zcmVKqLos8i5Db)b|fxKtf(criE1^t|1iEQ zv7$EA?t>>v0eB9rNnCg||1Yamh6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