mschorm / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone
0c223bc
--- util-linux-2.13-pre6/fdisk/sfdisk.c.isfull	2006-06-12 13:31:46.000000000 +0200
0c223bc
+++ util-linux-2.13-pre6/fdisk/sfdisk.c	2006-06-12 13:31:47.000000000 +0200
0c223bc
@@ -2413,19 +2413,6 @@
0c223bc
 	return is_ide;
0c223bc
 }
0c223bc
 
0c223bc
-static int
0c223bc
-is_probably_full_disk(char *name) {
0c223bc
-	struct hd_geometry geometry;
0c223bc
-	int fd, i = 0;
0c223bc
-
0c223bc
-	fd = open(name, O_RDONLY);
0c223bc
-	if (fd >= 0) {
0c223bc
-		i = ioctl(fd, HDIO_GETGEO, &geometry);
0c223bc
-		close(fd);
0c223bc
-	}
0c223bc
-	return (fd >= 0 && i == 0 && geometry.start == 0);
0c223bc
-}
0c223bc
-
0c223bc
 #define PROC_PARTITIONS	"/proc/partitions"
0c223bc
 static FILE *procf = NULL;
0c223bc
 
0c223bc
--- util-linux-2.13-pre6/fdisk/common.h.isfull	2004-09-06 20:07:11.000000000 +0200
0c223bc
+++ util-linux-2.13-pre6/fdisk/common.h	2006-06-12 13:31:47.000000000 +0200
0c223bc
@@ -28,5 +28,6 @@
0c223bc
 extern struct systypes i386_sys_types[];
0c223bc
 
0c223bc
 extern char *partname(char *dev, int pno, int lth);
0c223bc
+extern int is_probably_full_disk(char *name);
0c223bc
 
0c223bc
 int disksize(int fd, unsigned long long *sectors);
0c223bc
--- util-linux-2.13-pre6/fdisk/partname.c.isfull	2002-07-07 14:16:43.000000000 +0200
0c223bc
+++ util-linux-2.13-pre6/fdisk/partname.c	2006-06-12 13:32:54.000000000 +0200
0c223bc
@@ -1,6 +1,9 @@
0c223bc
 #include <ctype.h>
0c223bc
 #include <stdio.h>
0c223bc
 #include <string.h>
0c223bc
+#include <sys/types.h>
0c223bc
+#include <sys/stat.h>
0c223bc
+#include <fcntl.h>
0c223bc
 #include "common.h"
0c223bc
 
0c223bc
 /*
0c223bc
@@ -45,3 +48,30 @@
0c223bc
 partname(char *dev, int pno, int lth) {
0c223bc
 	return partnamebf(dev, pno, lth, 0, NULL);
0c223bc
 }
0c223bc
+
0c223bc
+int
0c223bc
+is_probably_full_disk(char *name) {
0c223bc
+#ifdef HDIO_GETGEO
0c223bc
+	struct hd_geometry geometry;
0c223bc
+	int fd, i = 0;
0c223bc
+
0c223bc
+	fd = open(name, O_RDONLY);
0c223bc
+	if (fd >= 0) {
0c223bc
+		i = ioctl(fd, HDIO_GETGEO, &geometry);
0c223bc
+		close(fd);
0c223bc
+	}
0c223bc
+	if (i==0)
0c223bc
+		return (fd >= 0 && geometry.start == 0);
0c223bc
+	/*
0c223bc
+	 * "silly heuristic" is still so sexy for us, because
0c223bc
+	 * for example Xen doesn't implement HDIO_GETGEO for virtual
0c223bc
+	 * block devices (/dev/xvda).
0c223bc
+	 * -- kzak@redhat.com (23-Feb-2006)
0c223bc
+	 */
0c223bc
+#endif
0c223bc
+	/* silly heuristic */
0c223bc
+	while (*name)
0c223bc
+		name++;
0c223bc
+	return !isdigit(name[-1]);
0c223bc
+}
0c223bc
+
0c223bc
--- util-linux-2.13-pre6/fdisk/fdisk.c.isfull	2006-06-12 13:31:47.000000000 +0200
0c223bc
+++ util-linux-2.13-pre6/fdisk/fdisk.c	2006-06-12 13:31:47.000000000 +0200
0c223bc
@@ -788,26 +788,6 @@
0c223bc
 #endif
0c223bc
 }
0c223bc
 
0c223bc
-static int
0c223bc
-is_probably_full_disk(char *name) {
0c223bc
-#ifdef HDIO_GETGEO
0c223bc
-	struct hd_geometry geometry;
0c223bc
-	int fd, i = 0;
0c223bc
-
0c223bc
-	fd = open(name, O_RDONLY);
0c223bc
-	if (fd >= 0) {
0c223bc
-		i = ioctl(fd, HDIO_GETGEO, &geometry);
0c223bc
-		close(fd);
0c223bc
-	}
0c223bc
-	return (fd >= 0 && i == 0 && geometry.start == 0);
0c223bc
-#else
0c223bc
-	/* silly heuristic */
0c223bc
-	while (*name)
0c223bc
-		name++;
0c223bc
-	return !isdigit(name[-1]);
0c223bc
-#endif
0c223bc
-}
0c223bc
-
0c223bc
 static void
0c223bc
 get_partition_table_geometry(void) {
0c223bc
 	unsigned char *bufp = MBRbuffer;