Messages in this thread Patch in this message |  | | Date | Mon, 28 Aug 2000 21:46:03 +0200 (CEST) | From | Oivind Hardy Danielsen <> | Subject | [PATCH] fs/fat/inode.c, kernel 2.4.0-test6 |
| |
When writing to a >64GB FAT32 partition, file system panic can occur: .... kernel: attempt to access beyond end of device .... kernel: 09:01: rw=0, want=2081825939, limit=103317504 .... kernel: dev = 09:01, ino = -2101046686 .... kernel: Filesystem panic (dev 09:01). .... kernel: msdos_write_inode: unable to read i-node block .... kernel: File system has been set read-only
Fix: (unified diff is attached) - if (!(bh = fat_bread(sb, i_pos >> MSDOS_DPB_BITS))) { + if (!(bh = fat_bread(sb, ((unsigned int)i_pos) >> MSDOS_DPB_BITS))) {
i_pos is signed int. When reading a block at offset >64GB, overflow occurs. Shifting a negative number to the right gives a bad result in this case (1's insert in high bits). By casting the number to unsigned, this problem will not occur and the limit is raised to 128GB (assumed). In order to get 2TB FAT32 partitions, 64 bit datatypes should be introduced.
64GB limit: (2*1024*1024*1024)/(16*(1024/512)) = 67108864 1k blocks 2*1024*1024*1024: (32-bit signed int maximum)+1 16: directory entries per 512byte sector (1<<MSDOS_DPB_BITS) 1024/512: Treat sector as 1k block (strange emulation)
Regards,
- Oivind H. Danielsen
Fix >64GB fat32 filesystem problem (2.4.0-test6). <Oivind.Danielsen@fast.no> --- linux-2.4.0-test6_orig/linux/fs/fat/inode.c Wed Jul 19 20:27:45 2000 +++ linux-2.4.0-test6/fs/fat/inode.c Fri Aug 25 18:07:19 2000 @@ -860,7 +860,7 @@ return; } lock_kernel(); - if (!(bh = fat_bread(sb, i_pos >> MSDOS_DPB_BITS))) { + if (!(bh = fat_bread(sb, ((unsigned int)i_pos) >> MSDOS_DPB_BITS))) { printk("dev = %s, ino = %d\n", kdevname(inode->i_dev), i_pos); fat_fs_panic(sb, "msdos_write_inode: unable to read i-node block"); unlock_kernel(); |  |