[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] BLKGETSIZE64 for parted 1.6.2
From: |
Matt Domsch |
Subject: |
[PATCH] BLKGETSIZE64 for parted 1.6.2 |
Date: |
Mon, 22 Jul 2002 10:42:34 -0500 (CDT) |
See previous message for description. The 'linux.c' abstraction helps a
bit in 1.6.2. :-)
--
Matt Domsch
Sr. Software Engineer, Lead Engineer, Architect
Dell Linux Solutions www.dell.com/linux
Linux on Dell mailing lists @ http://lists.us.dell.com
#1 US Linux Server provider for 2001 and Q1/2002! (IDC May 2002)
diff -urNp --exclude-from=/home/mdomsch/excludes --minimal
parted-1.6.2.orig/libparted/linux.c parted-1.6.2/libparted/linux.c
--- parted-1.6.2.orig/libparted/linux.c Fri May 17 07:29:29 2002
+++ parted-1.6.2/libparted/linux.c Sun Jul 21 21:54:44 2002
@@ -164,6 +164,7 @@ struct hd_driveid {
#define BLKSSZGET _IO(0x12,104) /* get block device sector size */
#define BLKGETLASTSECT _IO(0x12,108) /* get last sector of block device */
#define BLKSETLASTSECT _IO(0x12,109) /* set last sector of block device */
+#define BLKGETSIZE64 _IOR(0x12,114,sizeof(uint64_t)) /* return device size
in bytes (u64 *arg) */
struct blkdev_ioctl_param {
unsigned int block;
@@ -381,14 +382,32 @@ _device_get_sector_size (PedDevice* dev)
return sector_size;
}
+static int
+_kernel_has_blkgetsize64(void)
+{
+ int version = _get_linux_version();
+
+ if (version >= KERNEL_VERSION (2,5,4)) return 1;
+ if (version < KERNEL_VERSION (2,5,0) &&
+` version >= KERNEL_VERSION (2,4,18)) return 1;
+ return 0;
+}
+
/* TODO: do a binary search if BLKGETSIZE doesn't work?! */
static PedSector
_device_get_length (PedDevice* dev)
{
unsigned long size;
LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev);
+ uint64_t bytes=0;
PED_ASSERT (dev->open_count > 0, return 0);
+
+ if (_kernel_has_blkgetsize64()) {
+ if (ioctl(arch_specific->fd, BLKGETSIZE64, &bytes) == 0) {
+ return bytes / _device_get_sector_size(dev);
+ }
+ }
if (ioctl (arch_specific->fd, BLKGETSIZE, &size)) {
ped_exception_throw (
- [PATCH] BLKGETSIZE64 for parted 1.6.2,
Matt Domsch <=