[BusyBox 0001333]: "fdisk -l" (lower case ell) does not read partition table correctly
bugs at busybox.net
bugs at busybox.net
Thu May 31 16:16:47 PDT 2007
A NOTE has been added to this issue.
======================================================================
http://busybox.net/bugs/view.php?id=1333
======================================================================
Reported By: kiltedknight
Assigned To: BusyBox
======================================================================
Project: BusyBox
Issue ID: 1333
Category: Other
Reproducibility: always
Severity: major
Priority: normal
Status: assigned
======================================================================
Date Submitted: 05-04-2007 09:50 PDT
Last Modified: 05-31-2007 16:16 PDT
======================================================================
Summary: "fdisk -l" (lower case ell) does not read partition
table correctly
Description:
When running "busybox fdisk -l" against a known disk, I get the following:
Warning: ignoring extra data in partition table 5
Warning: ignoring extra data in partition table 5
Warning: ignoring extra data in partition table 6
Warning: ignoring extra data in partition table 6
Warning: ignoring extra data in partition table 6
Warning: invalid flag 0xe4,0x0f of partition table 5 will be corrected by
w(rite)
Warning: invalid flag 0x36,0xb0 of partition table 6 will be corrected by
w(rite)
Disk /dev/hde: 20.0 GB, 20020396032 bytes
255 heads, 63 sectors/track, 2434 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hde1 * 1 33 265041 83 Linux
/dev/hde2 34 925 7164990 83 Linux
/dev/hde3 926 1186 2096482+ 82 Linux swap
/dev/hde4 1187 2434 10024560 5 Extended
/dev/hde5 ? 17782 15955 2132811720 3f Unknown
/dev/hde6 ? 101267 247811 1177113252+ 11 Hidden FAT12
If I run the linux "fdisk -l", I get this:
Disk /dev/hde: 20.0 GB, 20020396032 bytes
255 heads, 63 sectors/track, 2434 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hde1 * 1 33 265041 83 Linux
/dev/hde2 34 925 7164990 83 Linux
/dev/hde3 926 1186 2096482+ 82 Linux swap /
Solaris
/dev/hde4 1187 2434 10024560 5 Extended
/dev/hde5 1187 1377 1534176 83 Linux
/dev/hde6 1378 2434 8490321 83 Linux
It looks like it's having problems reading the partitions out of an
extended partition.
======================================================================
----------------------------------------------------------------------
kiltedknight - 05-30-07 09:46
----------------------------------------------------------------------
The problem is the off_t value. For it to work, it must be a 64-bit number
and lseek64() must be used.
The attached patch will correct the problem.
----------------------------------------------------------------------
kiltedknight - 05-30-07 10:01
----------------------------------------------------------------------
Of note, the fdisk.c found in the Fedora Core 6 util-linux RPM does not use
off_t to define the various offsets. It defines them all as "unsigned long
long" instead, as it is highly unlikely that you will ever find a hard
drive that will no longer have its offsets fit within 32 bits.
----------------------------------------------------------------------
kiltedknight - 05-30-07 10:07
----------------------------------------------------------------------
Use the updated fix, as it more closely mimics the base fdisk.c file, only
casting to off_t in seek_sector().
----------------------------------------------------------------------
vda - 05-31-07 16:13
----------------------------------------------------------------------
- off_t offset = secno * sector_size;
+ off_t offset = (off_t) secno * sector_size;
Doesn't look right to me.
----------------------------------------------------------------------
vda - 05-31-07 16:15
----------------------------------------------------------------------
static void
-seek_sector(off_t secno)
+seek_sector(unsigned long long secno)
{
- off_t offset = secno * sector_size;
+ off_t offset = (off_t) secno * sector_size;
if (lseek(fd, offset, SEEK_SET) == (off_t) -1)
fdisk_fatal(unable_to_seek);
}
I mean, you need to use lseek64 instead, and also need to make sure fd is
opened with O_LARGEFILE.
----------------------------------------------------------------------
vda - 05-31-07 16:16
----------------------------------------------------------------------
%"OFF_FMT"ld and %"OFF_FMT"lu are wrong. Use %lld, %llu.
Issue History
Date Modified Username Field Change
======================================================================
05-04-07 09:50 kiltedknight New Issue
05-04-07 09:50 kiltedknight Status new => assigned
05-04-07 09:50 kiltedknight Assigned To => BusyBox
05-04-07 09:51 kiltedknight Issue Monitored: kiltedknight
05-30-07 09:46 kiltedknight Note Added: 0002419
05-30-07 09:46 kiltedknight File Added: bb-fdisk-fix.diff
05-30-07 10:01 kiltedknight Note Added: 0002420
05-30-07 10:06 kiltedknight File Added: bb-fdisk-fix-updated.diff
05-30-07 10:07 kiltedknight Note Added: 0002421
05-31-07 16:13 vda Note Added: 0002422
05-31-07 16:15 vda Note Added: 0002423
05-31-07 16:16 vda Note Added: 0002424
======================================================================
More information about the busybox-cvs
mailing list