dcavalca / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone
64664a
From 8229770ff79a383d7e5b133f94609e861aae4283 Mon Sep 17 00:00:00 2001
64664a
From: Karel Zak <kzak@redhat.com>
64664a
Date: Fri, 17 Mar 2017 15:03:28 +0100
64664a
Subject: [PATCH 099/116] sfdisk: remove useless CDROM detection for -s
64664a
64664a
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1402825
64664a
Signed-off-by: Karel Zak <kzak@redhat.com>
64664a
---
64664a
 fdisks/sfdisk.c | 16 ++++++----------
64664a
 1 file changed, 6 insertions(+), 10 deletions(-)
64664a
64664a
diff --git a/fdisks/sfdisk.c b/fdisks/sfdisk.c
64664a
index 93bca27..afb15fc 100644
64664a
--- a/fdisks/sfdisk.c
64664a
+++ b/fdisks/sfdisk.c
64664a
@@ -2905,36 +2905,32 @@ do_pt_geom(char *dev, int silent) {
64664a
 /* for compatibility with earlier fdisk: provide option -s */
64664a
 static void
64664a
 do_size(char *dev, int silent) {
64664a
-    int fd;
64664a
+    int fd, rc;
64664a
     unsigned long long size;
64664a
 
64664a
     fd = my_open(dev, 0, silent);
64664a
     if (fd < 0)
64664a
 	return;
64664a
 
64664a
-    if (blkdev_get_sectors(fd, &size) == -1) {
64664a
+    rc = blkdev_get_sectors(fd, &size);
64664a
+    close(fd);
64664a
+
64664a
+    if (rc == -1) {
64664a
 	if (!silent) {
64664a
 	    perror(dev);
64664a
 	    errx(EXIT_FAILURE, _("Cannot get size of %s"), dev);
64664a
 	}
64664a
-	goto done;
64664a
+	return;
64664a
     }
64664a
 
64664a
     size /= 2;			/* convert sectors to blocks */
64664a
 
64664a
-    /* a CDROM drive without mounted CD yields MAXINT */
64664a
-    if (silent && size == ((1 << 30) - 1))
64664a
-	goto done;
64664a
-
64664a
     if (silent)
64664a
 	printf("%s: %9llu\n", dev, size);
64664a
     else
64664a
 	printf("%llu\n", size);
64664a
 
64664a
     total_size += size;
64664a
-
64664a
-done:
64664a
-    close(fd);
64664a
 }
64664a
 
64664a
 /*
64664a
-- 
64664a
2.9.3
64664a