[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Wrong logical sector size detection

From: Benjamin Cama
Subject: Wrong logical sector size detection
Date: Wed, 05 Apr 2006 23:55:28 +0200


I tried today to build from source the latest parted tarball, and got a
strange error that i didn't get before when using pre-compiled packages
(from ubuntu and debian). I compiled from sources because i wanted to
see if the problem i got when resizing an HFS+ partition was still there
with the latest version (yes, i'll have to fill a bug for this too if it
is still there).

My system is a G4 iBook (PowerBook6,3) with a kernel (custom
built), and i'm trying to resize an HFS+ partition from my main hard
drive (is this dangerous to do, as linux is running on the same hard
drive that contains this HFS+ partition ?). I tried both parted-1.7.0rc3
and 1.7.1rc2 (which one is the newest ?) and got this error when trying
"parted /dev/hda" :

AVERTISSEMENT: The logical sector size for /dev/hda is 512. Not all
parts of GNU Parted support this at the moment.

But i was quite sure that the logical sector size of my disk was 512 and
that it was the "classical" size (and found that it was it as
PED_SECTOR_SIZE_DEFAULT = 512LL in parted/unit.h). I rebuilt parted with
--enable-debug, and gdb'ed it to see, breaking where the problem came
from (libparted/arch/linux.c:_device_set_sector_size , according to the
error message). I looked at the sector_size var just after the ioctl()
and found something strange :

(gdb) print *dev
$12 = {next = 0xffffffff, model = 0x1005ee00 "HTS541060G9AT00", path =
0x1005f0b0 "/dev/hda", type = PED_DEVICE_IDE, sector_size =
2199023256064, phys_sector_size = 512, length = -1, open_count = 1,
read_only = 0, external_mode = 0, dirty = 0, boot_dirty = 0, hw_geom =
{cylinders = -1, heads = -1, sectors = -1}, bios_geom = {cylinders = -1,
heads = -1, sectors = -1}, host = -1, did = -1, arch_specific =

Well, a value of 2199023256064 is bit "too much" for a sector size... I
looked at the PedDevice struct and found that sector_size is a long long
(so it's 64 bits), and that it had been changed on 2005/11/14 according
to the Changelog (before, it was only a long i think).

Struggling a bit with this number, i found that it was the value 512
shifted by 32 bits. So i concluded that the ioctl is returning a 32 bits
integer, and so does printf with %d (according to the man, you have to
go with %ll to display a long long).

So i wonder what to do with that. My questions are : why was the
sector_size changed to long long ? Is it a good solution on 32 bits
architectures (like my PowerPC) ? Is it compatible with the kernel
ioctl ? (a 64 bits call for 32 bits arch may exists, i didn't check)

First, the %d in the printf should be changed so that one doesn't see
this value thinking that this is really what the sector_size var
contains. Second, something should be changed in the way the sector size
is pulled from the kernel. As i'm quite new to parted, i'll let anyone
more skilled than me suggest what to do with this bug.

Benjamin Cama

reply via email to

[Prev in Thread] Current Thread [Next in Thread]