diff options
author | Karel Zak <kzak@redhat.com> | 2009-03-11 14:00:21 +0100 |
---|---|---|
committer | Karel Zak <kzak@redhat.com> | 2009-03-11 14:00:21 +0100 |
commit | 929f243f79c4fdf3e89dad5134e53bf001598a5e (patch) | |
tree | 16f02b38f82ccc64bd7b199c786cc732163ae0a1 /fdisk | |
parent | db1749cf6c105a86adfc7246cb1ab60b1753f077 (diff) | |
download | util-linux-old-929f243f79c4fdf3e89dad5134e53bf001598a5e.tar.gz |
lib: add is_whole_disk() from fdisk code
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'fdisk')
-rw-r--r-- | fdisk/Makefile.am | 2 | ||||
-rw-r--r-- | fdisk/common.h | 1 | ||||
-rw-r--r-- | fdisk/fdisk.c | 3 | ||||
-rw-r--r-- | fdisk/partname.c | 29 | ||||
-rw-r--r-- | fdisk/sfdisk.c | 4 |
5 files changed, 6 insertions, 33 deletions
diff --git a/fdisk/Makefile.am b/fdisk/Makefile.am index b3b5d7e9..20906b52 100644 --- a/fdisk/Makefile.am +++ b/fdisk/Makefile.am @@ -3,7 +3,7 @@ include $(top_srcdir)/config/include-Makefile.am EXTRA_DIST = README.fdisk README.cfdisk sfdisk.examples partitiontype.c fdisk_common = i386_sys_types.c common.h gpt.c gpt.h \ - ../lib/blkdev.c + ../lib/blkdev.c ../lib/wholedisk.c if LINUX fdisk_common += ../lib/linux_version.c diff --git a/fdisk/common.h b/fdisk/common.h index 674e65f4..352b9a59 100644 --- a/fdisk/common.h +++ b/fdisk/common.h @@ -11,6 +11,5 @@ struct systypes { extern struct systypes i386_sys_types[]; extern char *partname(char *dev, int pno, int lth); -extern int is_probably_full_disk(char *name); #endif /* FDISK_COMMON_H */ diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c index 5593503b..e3b6857f 100644 --- a/fdisk/fdisk.c +++ b/fdisk/fdisk.c @@ -26,6 +26,7 @@ #include "blkdev.h" #include "common.h" #include "fdisk.h" +#include "wholedisk.h" #include "fdisksunlabel.h" #include "fdisksgilabel.h" @@ -2568,7 +2569,7 @@ tryprocpt(void) { &ma, &mi, &sz, ptname) != 4) continue; snprintf(devname, sizeof(devname), "/dev/%s", ptname); - if (is_probably_full_disk(devname)) + if (is_whole_disk(devname)) try(devname, 0); } fclose(procpt); diff --git a/fdisk/partname.c b/fdisk/partname.c index 889e7f0b..1fe3087b 100644 --- a/fdisk/partname.c +++ b/fdisk/partname.c @@ -1,9 +1,7 @@ #include <ctype.h> #include <stdio.h> #include <string.h> -#include <sys/types.h> -#include <fcntl.h> -#include <unistd.h> + #include "blkdev.h" #include "pathnames.h" #include "common.h" @@ -48,28 +46,3 @@ partname(char *dev, int pno, int lth) { return bufp; } -int -is_probably_full_disk(char *name) { -#ifdef HDIO_GETGEO - struct hd_geometry geometry; - int fd, i = 0; - - fd = open(name, O_RDONLY); - if (fd >= 0) { - i = ioctl(fd, HDIO_GETGEO, &geometry); - close(fd); - } - if (i==0) - return (fd >= 0 && geometry.start == 0); -#endif - /* - * The "silly heuristic" is still sexy for us, because - * for example Xen doesn't implement HDIO_GETGEO for virtual - * block devices (/dev/xvda). - * - * -- kzak@redhat.com (23-Feb-2006) - */ - while (*name) - name++; - return !isdigit(name[-1]); -} diff --git a/fdisk/sfdisk.c b/fdisk/sfdisk.c index 533e729a..2cda03ce 100644 --- a/fdisk/sfdisk.c +++ b/fdisk/sfdisk.c @@ -50,7 +50,7 @@ #include "blkdev.h" #include "linux_version.h" #include "common.h" - +#include "wholedisk.h" #include "gpt.h" #define SIZE(a) (sizeof(a)/sizeof(a[0])) @@ -2443,7 +2443,7 @@ nextproc(FILE *procf) { &ma, &mi, &sz, ptname) != 4) continue; snprintf(devname, sizeof(devname), "/dev/%s", ptname); - if (!is_probably_full_disk(devname)) + if (!is_whole_disk(devname)) continue; return devname; } |