dcavalca / rpms / util-linux

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