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
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 */
#include "blkdev.h"
#include "common.h"
#include "fdisk.h"
+#include "wholedisk.h"
#include "fdisksunlabel.h"
#include "fdisksgilabel.h"
&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);
#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"
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]);
-}
#include "blkdev.h"
#include "linux_version.h"
#include "common.h"
-
+#include "wholedisk.h"
#include "gpt.h"
#define SIZE(a) (sizeof(a)/sizeof(a[0]))
&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;
}
#include <sys/types.h>
#include <sys/ioctl.h>
+#include <fcntl.h>
+#include <unistd.h>
#define DEFAULT_SECTOR_SIZE 512
--- /dev/null
+#ifndef WHOLEDISK_H
+#define WHOLEDISK_H
+
+extern int is_whole_disk(const char *name);
+
+#endif /* WHOLEDISK_H */
+
--- /dev/null
+
+#include <ctype.h>
+
+#include "blkdev.h"
+#include "wholedisk.h"
+
+int is_whole_disk(const 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]);
+}