]> git.pld-linux.org Git - packages/util-linux.git/blame - util-linux-fdisk-isfull.patch
- cryptsetup-luks isn't equivalent of cryptsetup
[packages/util-linux.git] / util-linux-fdisk-isfull.patch
CommitLineData
5545a732
JR
1- fdisk -l inside xen guest shows no disks
2- "sfdisk -l" tries to open partitions
3
4--- util-linux-2.13-pre6/fdisk/sfdisk.c.isfull 2006-06-12 13:31:46.000000000 +0200
5+++ util-linux-2.13-pre6/fdisk/sfdisk.c 2006-06-12 13:31:47.000000000 +0200
6@@ -2413,19 +2413,6 @@
7 return is_ide;
8 }
9
10-static int
11-is_probably_full_disk(char *name) {
12- struct hd_geometry geometry;
13- int fd, i = 0;
14-
15- fd = open(name, O_RDONLY);
16- if (fd >= 0) {
17- i = ioctl(fd, HDIO_GETGEO, &geometry);
18- close(fd);
19- }
20- return (fd >= 0 && i == 0 && geometry.start == 0);
21-}
22-
23 #define PROC_PARTITIONS "/proc/partitions"
24 static FILE *procf = NULL;
25
26--- util-linux-2.13-pre6/fdisk/common.h.isfull 2004-09-06 20:07:11.000000000 +0200
27+++ util-linux-2.13-pre6/fdisk/common.h 2006-06-12 13:31:47.000000000 +0200
28@@ -28,5 +28,6 @@
29 extern struct systypes i386_sys_types[];
30
31 extern char *partname(char *dev, int pno, int lth);
32+extern int is_probably_full_disk(char *name);
33
34 int disksize(int fd, unsigned long long *sectors);
35--- util-linux-2.13-pre6/fdisk/partname.c.isfull 2002-07-07 14:16:43.000000000 +0200
36+++ util-linux-2.13-pre6/fdisk/partname.c 2006-06-12 13:32:54.000000000 +0200
37@@ -1,6 +1,9 @@
38 #include <ctype.h>
39 #include <stdio.h>
40 #include <string.h>
41+#include <sys/types.h>
42+#include <sys/stat.h>
43+#include <fcntl.h>
44 #include "common.h"
45
46 /*
47@@ -45,3 +48,30 @@
48 partname(char *dev, int pno, int lth) {
49 return partnamebf(dev, pno, lth, 0, NULL);
50 }
51+
52+int
53+is_probably_full_disk(char *name) {
54+#ifdef HDIO_GETGEO
55+ struct hd_geometry geometry;
56+ int fd, i = 0;
57+
58+ fd = open(name, O_RDONLY);
59+ if (fd >= 0) {
60+ i = ioctl(fd, HDIO_GETGEO, &geometry);
61+ close(fd);
62+ }
63+ if (i==0)
64+ return (fd >= 0 && geometry.start == 0);
65+ /*
66+ * "silly heuristic" is still so sexy for us, because
67+ * for example Xen doesn't implement HDIO_GETGEO for virtual
68+ * block devices (/dev/xvda).
69+ * -- kzak@redhat.com (23-Feb-2006)
70+ */
71+#endif
72+ /* silly heuristic */
73+ while (*name)
74+ name++;
75+ return !isdigit(name[-1]);
76+}
77+
78--- util-linux-2.13-pre6/fdisk/fdisk.c.isfull 2006-06-12 13:31:47.000000000 +0200
79+++ util-linux-2.13-pre6/fdisk/fdisk.c 2006-06-12 13:31:47.000000000 +0200
80@@ -788,26 +788,6 @@
81 #endif
82 }
83
84-static int
85-is_probably_full_disk(char *name) {
86-#ifdef HDIO_GETGEO
87- struct hd_geometry geometry;
88- int fd, i = 0;
89-
90- fd = open(name, O_RDONLY);
91- if (fd >= 0) {
92- i = ioctl(fd, HDIO_GETGEO, &geometry);
93- close(fd);
94- }
95- return (fd >= 0 && i == 0 && geometry.start == 0);
96-#else
97- /* silly heuristic */
98- while (*name)
99- name++;
100- return !isdigit(name[-1]);
101-#endif
102-}
103-
104 static void
105 get_partition_table_geometry(void) {
106 unsigned char *bufp = MBRbuffer;
This page took 0.089488 seconds and 4 git commands to generate.