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