summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2009-02-26 23:03:46 +0100
committerKarel Zak2009-02-26 23:03:46 +0100
commitf314a6beccbb6bf00eca3acce0ec4d3a25de8051 (patch)
tree5c3714daf1b80ffdffe4922e410c886f5e22b06a
parentpartx: don't duplicate lib/blkdev.c code (diff)
downloadkernel-qcow2-util-linux-f314a6beccbb6bf00eca3acce0ec4d3a25de8051.tar.gz
kernel-qcow2-util-linux-f314a6beccbb6bf00eca3acce0ec4d3a25de8051.tar.xz
kernel-qcow2-util-linux-f314a6beccbb6bf00eca3acce0ec4d3a25de8051.zip
fdisk: (and partx) remove BLKGETLASTSECT
This odd ioctl is unsupported in the current 2.4 and 2.6 mainline. Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--fdisk/gpt.c40
-rw-r--r--include/blkdev.h2
-rw-r--r--partx/gpt.c39
3 files changed, 2 insertions, 79 deletions
diff --git a/fdisk/gpt.c b/fdisk/gpt.c
index 8cdf57f59..f7752c094 100644
--- a/fdisk/gpt.c
+++ b/fdisk/gpt.c
@@ -76,12 +76,6 @@ typedef struct _GuidPartitionTableHeader_t {
uint8_t Reserved2[512 - 92];
} __attribute__ ((packed)) GuidPartitionTableHeader_t;
-struct blkdev_ioctl_param {
- unsigned int block;
- size_t content_length;
- char * block_contents;
-};
-
static int
_get_sector_size (int fd)
{
@@ -131,46 +125,14 @@ last_lba(int fd)
return sectors - 1;
}
-#ifdef __linux__
-static ssize_t
-read_lastoddsector(int fd, uint64_t lba, void *buffer, size_t count)
-{
- int rc;
- struct blkdev_ioctl_param ioctl_param;
-
- if (!buffer) return 0;
-
- ioctl_param.block = 0; /* read the last sector */
- ioctl_param.content_length = count;
- ioctl_param.block_contents = buffer;
-
- rc = ioctl(fd, BLKGETLASTSECT, &ioctl_param);
- if (rc == -1) perror("read failed");
-
- return !rc;
-}
-#endif
-
static ssize_t
read_lba(int fd, uint64_t lba, void *buffer, size_t bytes)
{
int sector_size = _get_sector_size(fd);
off_t offset = lba * sector_size;
- ssize_t bytesread;
lseek(fd, offset, SEEK_SET);
- bytesread = read(fd, buffer, bytes);
-
-#ifdef __linux__
- /* Kludge. This is necessary to read/write the last
- block of an odd-sized disk, until Linux 2.5.x kernel fixes.
- This is only used by gpt.c, and only to read
- one sector, so we don't have to be fancy.
- */
- if (!bytesread && !(last_lba(fd) & 1) && lba == last_lba(fd))
- bytesread = read_lastoddsector(fd, lba, buffer, bytes);
-#endif
- return bytesread;
+ return read(fd, buffer, bytes);
}
static GuidPartitionTableHeader_t *
diff --git a/include/blkdev.h b/include/blkdev.h
index 409b5e43c..3cca79b94 100644
--- a/include/blkdev.h
+++ b/include/blkdev.h
@@ -28,8 +28,6 @@
#define BLKELVGET _IOR(0x12,106,size_t) /* elevator get */
#define BLKELVSET _IOW(0x12,107,size_t) /* elevator set */
-#define BLKGETLASTSECT _IO(0x12,108) /* get last sector of block device */
-
#define BLKBSZGET _IOR(0x12,112,size_t)
#define BLKBSZSET _IOW(0x12,113,size_t)
#define BLKGETSIZE64 _IOR(0x12,114,size_t) /* return device size in bytes (u64 *arg) */
diff --git a/partx/gpt.c b/partx/gpt.c
index b146c9e7e..cef38f9e7 100644
--- a/partx/gpt.c
+++ b/partx/gpt.c
@@ -38,17 +38,10 @@
#include "partx.h"
#include "bitops.h"
-#define BLKGETLASTSECT _IO(0x12,108) /* get last sector of block device */
#define BLKGETSIZE _IO(0x12,96) /* return device size */
#define BLKSSZGET _IO(0x12,104) /* get block device sector size */
#define BLKGETSIZE64 _IOR(0x12,114,sizeof(uint64_t)) /* return device size in bytes (u64 *arg) */
-struct blkdev_ioctl_param {
- unsigned int block;
- size_t content_length;
- char * block_contents;
-};
-
/**
* efi_crc32() - EFI version of crc32 function
* @buf: buffer to calculate crc32 of
@@ -184,44 +177,14 @@ last_lba(int filedes)
return sectors - 1;
}
-
-static ssize_t
-read_lastoddsector(int fd, uint64_t lba, void *buffer, size_t count)
-{
- int rc;
- struct blkdev_ioctl_param ioctl_param;
-
- if (!buffer) return 0;
-
- ioctl_param.block = 0; /* read the last sector */
- ioctl_param.content_length = count;
- ioctl_param.block_contents = buffer;
-
- rc = ioctl(fd, BLKGETLASTSECT, &ioctl_param);
- if (rc == -1) perror("read failed");
-
- return !rc;
-}
-
static ssize_t
read_lba(int fd, uint64_t lba, void *buffer, size_t bytes)
{
int sector_size = get_sector_size(fd);
off_t offset = lba * sector_size;
- ssize_t bytesread;
lseek(fd, offset, SEEK_SET);
- bytesread = read(fd, buffer, bytes);
-
- /* Kludge. This is necessary to read/write the last
- block of an odd-sized disk, until Linux 2.5.x kernel fixes.
- This is only used by gpt.c, and only to read
- one sector, so we don't have to be fancy.
- */
- if (!bytesread && !(last_lba(fd) & 1) && lba == last_lba(fd)) {
- bytesread = read_lastoddsector(fd, lba, buffer, bytes);
- }
- return bytesread;
+ return read(fd, buffer, bytes);
}
/**