This odd ioctl is unsupported in the current 2.4 and 2.6 mainline.
Signed-off-by: Karel Zak <kzak@redhat.com>
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)
{
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 *
#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) */
#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
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);
}
/**