Blame SOURCES/0116-fdisk-use-sysfs_devno_is_wholedisk.patch

05ad79
From e86fe103accdf5dd688b3710c873094cfa41ae5f Mon Sep 17 00:00:00 2001
05ad79
From: Karel Zak <kzak@redhat.com>
05ad79
Date: Tue, 21 Mar 2017 15:11:29 +0100
05ad79
Subject: [PATCH 116/116] fdisk: use sysfs_devno_is_wholedisk()
05ad79
05ad79
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1402183
05ad79
Signed-off-by: Karel Zak <kzak@redhat.com>
05ad79
---
05ad79
 lib/wholedisk.c | 23 ++++++++---------------
05ad79
 1 file changed, 8 insertions(+), 15 deletions(-)
05ad79
05ad79
diff --git a/lib/wholedisk.c b/lib/wholedisk.c
05ad79
index 5161a1e..7c63204 100644
05ad79
--- a/lib/wholedisk.c
05ad79
+++ b/lib/wholedisk.c
05ad79
@@ -1,14 +1,10 @@
05ad79
-/*
05ad79
- * No copyright is claimed.  This code is in the public domain; do with
05ad79
- * it what you wish.
05ad79
- *
05ad79
- * Written by Karel Zak <kzak@redhat.com>
05ad79
- */
05ad79
+
05ad79
 #include <stdio.h>
05ad79
 #include <stdlib.h>
05ad79
 #include <ctype.h>
05ad79
 
05ad79
 #include "blkdev.h"
05ad79
+#include "sysfs.h"
05ad79
 #include "wholedisk.h"
05ad79
 
05ad79
 int is_whole_disk_fd(int fd, const char *name)
05ad79
@@ -35,16 +31,13 @@ int is_whole_disk_fd(int fd, const char *name)
05ad79
 
05ad79
 int is_whole_disk(const char *name)
05ad79
 {
05ad79
-	int fd = -1, res = 0;
05ad79
-#ifdef HDIO_GETGEO
05ad79
-	fd = open(name, O_RDONLY|O_CLOEXEC);
05ad79
-	if (fd != -1)
05ad79
-#endif
05ad79
-		res = is_whole_disk_fd(fd, name);
05ad79
+	dev_t devno = sysfs_devname_to_devno(name, NULL);
05ad79
+
05ad79
+	if (sysfs_devno_is_lvm_private(devno) ||
05ad79
+	    sysfs_devno_is_wholedisk(devno) <= 0)
05ad79
+		return 0;
05ad79
 
05ad79
-	if (fd != -1)
05ad79
-		close(fd);
05ad79
-	return res;
05ad79
+	return 1;
05ad79
 }
05ad79
 
05ad79
 #ifdef TEST_PROGRAM
05ad79
-- 
05ad79
2.9.3
05ad79