summaryrefslogtreecommitdiff
path: root/rescuept
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2006-12-07 00:25:43 +0100
committerKarel Zak <kzak@redhat.com>2006-12-07 00:25:43 +0100
commit22853e4a82c6ef7b336527529acb94b14a0b0fd8 (patch)
treeee28e4598c8c449d7e811711d8ce8eb17caecfb6 /rescuept
parenteb63b9b8f4cecb34c2478282567862bc48ef256d (diff)
downloadutil-linux-old-22853e4a82c6ef7b336527529acb94b14a0b0fd8.tar.gz
Imported from util-linux-2.10m tarball.
Diffstat (limited to 'rescuept')
-rw-r--r--rescuept/README2
-rw-r--r--rescuept/rescuept.c13
2 files changed, 11 insertions, 4 deletions
diff --git a/rescuept/README b/rescuept/README
index 50114d13..f7ce866d 100644
--- a/rescuept/README
+++ b/rescuept/README
@@ -9,7 +9,7 @@ It is in the non-installed part of the e2progs distribution.
(ii) rescuept is a utility that recognizes ext2 superblocks,
FAT partitions, swap partitions, and extended partition tables;
it may also recognize BSD disklabels and Unixware 7 partitions.
-It prints out information that can be used with fdisk or sfdisk
+It prints out information that is suitable as input to sfdisk
to reconstruct the partition table.
It is in the non-installed part of the util-linux distribution.
diff --git a/rescuept/rescuept.c b/rescuept/rescuept.c
index 8be53538..80c0a469 100644
--- a/rescuept/rescuept.c
+++ b/rescuept/rescuept.c
@@ -24,10 +24,12 @@
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
+#include <sys/stat.h>
#include <sys/ioctl.h>
-#include <linux/fs.h> /* for BLKGETSIZE */
-
+#ifndef BLKGETSIZE
+#define BLKGETSIZE _IO(0x12,96)
+#endif
char *progname;
char *device;
@@ -497,9 +499,14 @@ main(int argc, char **argv){
}
if (ioctl(fd, BLKGETSIZE, &size)) {
+ struct stat s;
perror("BLKGETSIZE");
fprintf(stderr, "%s: could not get device size\n", progname);
- exit(1);
+ if (stat(device, &s)) {
+ fprintf(stderr, "and also stat fails. Aborting.\n");
+ exit(1);
+ }
+ size = s.st_size / 512;
}
pagesize = getpagesize();