2.2.5 ext2 bug

Michael Marxmeier (mike@msede.com)
Sun, 25 Apr 1999 01:27:45 +0200


The check to enforce the 2GB file size on 32 architectures in
ext2_file_write (fs/ext2/file.c) looks like a bug to me:

#if BITS_PER_LONG < 64
if (pos > (__u32) (pos + count)) {
count = ~pos; /* == 0xFFFFFFFF - pos */
if (!count)
return -EFBIG;
}
#else

This should probably something along:

#if BITS_PER_LONG < 64
if (pos > (__s32) (pos + count)) {
count = 0x7FFFFFFF - pos;
if (!count)
return -EFBIG;
}
#else

Another interesting bit is in ext2_file_lseek:

if (((unsigned long long) offset >> 32) != 0) {
#if BITS_PER_LONG < 64
return -EINVAL;
#else

Since the max. file size is to be checked against 2 GB shouldn't
this be

if (((unsigned long long) offset >> 31) != 0) {

Background:

I created a file with 2G-8k (using 8K writes) but the last write
succeeded only partially:

write() failed: size=8192, returned 7168
write() failed: size=8192, returned 7168

Afterwards i saved it to tape but tar failed to restore the file:

tar: data2/db/db01.vol: Could only write 8192 of 10240 bytes

And the consequently the file got truncated to
-rw------- 1 eloq eloq 2147479552 Apr 24 15:31
/data2/db/db01.vol

tar tv reports
-rw------- eloq/eloq 2147482624 1999-04-24 15:31 data2/db/db01.vol

Michael

-- 
Michael Marxmeier           Marxmeier Software GmbH
E-Mail: mike@msede.com      Besenbruchstrasse 9
Voice : +49 202 2431440     42285 Wuppertal, Germany
Fax   : +49 202 2431420     http://www.msede.com/

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/