cdown / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone

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

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