clear_warning();
}
+#ifdef BLKFLSBUF
/* Blocks are visible in more than one way:
e.g. as block on /dev/hda and as block on /dev/hda3
By a bug in the Linux buffer cache, we will see the old
so this only plays a role if we want to show volume labels. */
ioctl(fd, BLKFLSBUF); /* ignore errors */
/* e.g. Permission Denied */
+#endif
if (blkdev_get_sectors(fd, &llsectors) == -1)
fatal(_("Cannot get disk size"), 3);
}
if (is_bdev) {
+#ifdef BLKRRPART
sync();
sleep(2);
if (!ioctl(fd,BLKRRPART))
changed = TRUE;
+#endif
sync();
sleep(4);
i = fstat(fd, &statbuf);
if (i == 0 && S_ISBLK(statbuf.st_mode)) {
- printf(_("Calling ioctl() to re-read partition table.\n"));
sync();
sleep(2);
+#ifdef BLKRRPART
+ printf(_("Calling ioctl() to re-read partition table.\n"));
i = ioctl(fd, BLKRRPART);
+#else
+ errno = ENOSYS;
+ i = 1;
+#endif
}
if (i) {
res = blkdev_get_sectors(fd, &llsectors);
+#ifdef HDIO_GETGEO
if (!ioctl(fd, HDIO_GETGEO, &geometry)) {
heads = geometry.heads;
sectors = geometry.sectors;
" > 33.8 GB.\n"), disk_device, cylinders);
}
}
+#endif
for (i = 0; i < 4; i++) {
old[i].sysid = 0;
if (valid_part_table_flag(MBRbuffer)) {
res = blkdev_get_sectors(fd, &llsectors);
sec_fac = sector_size / 512;
+#ifdef HDIO_GETGEO
if (!ioctl(fd, HDIO_GETGEO, &geometry)) {
heads = geometry.heads;
sectors = geometry.sectors;
"This value may be truncated for devices"
" > 33.8 GB.\n"), disk_device, cylinders);
}
- } else {
+ } else
+#endif
+ {
heads = read_int(1,1,1024,0,_("Heads"));
sectors = read_int(1,1,1024,0,_("Sectors/track"));
cylinders = read_int(1,1,65535,0,_("Cylinders"));
return sectors - 1;
}
+#ifdef __linux__
static ssize_t
read_lastoddsector(int fd, uint64_t lba, void *buffer, size_t count)
{
return !rc;
}
+#endif
static ssize_t
read_lba(int fd, uint64_t lba, void *buffer, size_t bytes)
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
*/
if (!bytesread && !(last_lba(fd) & 1) && lba == last_lba(fd))
bytesread = read_lastoddsector(fd, lba, buffer, bytes);
+#endif
return bytesread;
}
unsigned long long sectors;
struct geometry R;
- if (ioctl(fd, HDIO_GETGEO, &g)) {
+#ifdef HDIO_GETGEO
+ if (ioctl(fd, HDIO_GETGEO, &g))
+#endif
+ {
g.heads = g.sectors = g.cylinders = g.start = 0;
if (!silent)
do_warn(_("Disk %s: cannot get geometry\n"), dev);
/* tell the kernel to reread the partition tables */
static int
reread_ioctl(int fd) {
- if (ioctl(fd, BLKRRPART)) {
+#ifdef BLKRRPART
+ if (ioctl(fd, BLKRRPART))
+#else
+ errno = ENOSYS;
+#endif
+ {
perror("BLKRRPART");
/* 2.6.8 returns EIO for a zero table */