[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
libparted/linux.c _read/write_lastoddsector not needed on 2.6 kernels
From: |
Matt Domsch |
Subject: |
libparted/linux.c _read/write_lastoddsector not needed on 2.6 kernels |
Date: |
Wed, 21 Apr 2004 13:10:10 -0500 |
User-agent: |
Mutt/1.4.1i |
Trying parted 1.6.8 and 1.6.9 on a 2.6.4 kernel, parted hangs (and
can't be ctrl-C'd) while trying to read an odd-sized GPT disk. This
is because the _read_lastoddsector code is being run, however the
kernel doesn't have (and doesn't need to have) the BLKGETLASTSECT
ioctl().
The kludge code in linux.c isn't needed when running on 2.6 kernels.
Perhaps it would be appropriate to test for kernel version and
optionally not run it, like the patch below provides. This works for me.
--
Matt Domsch
Sr. Software Engineer, Lead Engineer
Dell Linux Solutions linux.dell.com & www.dell.com/linux
Linux on Dell mailing lists @ http://lists.us.dell.com
--- parted-1.6.9/libparted/linux.c 2004-03-09 04:16:18.000000000 -0600
+++ parted-1.6.9.new/libparted/linux.c 2004-04-21 13:09:16.000000000 -0500
@@ -1067,14 +1067,16 @@
PedExceptionOption ex_status;
size_t read_length = count * PED_SECTOR_SIZE;
- /* Kludge. This is necessary to read/write the last
- block of an odd-sized disk, until Linux 2.5.x kernel fixes.
- */
- if (dev->type != PED_DEVICE_FILE && (dev->length & 1)
- && start + count - 1 == dev->length - 1)
- return ped_device_read (dev, buffer, start, count - 1)
- && _read_lastoddsector (dev, buffer + (count-1) * 512);
+ if (_get_linux_version() < KERNEL_VERSION (2,6,0)) {
+ /* Kludge. This is necessary to read/write the last
+ block of an odd-sized disk, until Linux 2.5.x kernel fixes.
+ */
+ if (dev->type != PED_DEVICE_FILE && (dev->length & 1)
+ && start + count - 1 == dev->length - 1)
+ return ped_device_read (dev, buffer, start, count - 1)
+ && _read_lastoddsector (dev, buffer + (count-1)
* 512);
+ }
while (1) {
if (_device_seek (dev, start))
break;
@@ -1184,14 +1186,15 @@
return 1;
}
- /* Kludge. This is necessary to read/write the last
- block of an odd-sized disk, until Linux 2.5.x kernel fixes.
- */
- if (dev->type != PED_DEVICE_FILE && (dev->length & 1)
- && start + count - 1 == dev->length - 1)
- return ped_device_write (dev, buffer, start, count - 1)
- && _write_lastoddsector (dev, buffer + (count-1) * 512);
-
+ if (_get_linux_version() < KERNEL_VERSION (2,6,0)) {
+ /* Kludge. This is necessary to read/write the last
+ block of an odd-sized disk, until Linux 2.5.x kernel fixes.
+ */
+ if (dev->type != PED_DEVICE_FILE && (dev->length & 1)
+ && start + count - 1 == dev->length - 1)
+ return ped_device_write (dev, buffer, start, count - 1)
+ && _write_lastoddsector (dev, buffer +
(count-1) * 512);
+ }
while (1) {
if (_device_seek (dev, start))
break;
pgpQQvifjGutP.pgp
Description: PGP signature
- libparted/linux.c _read/write_lastoddsector not needed on 2.6 kernels,
Matt Domsch <=