diff options
author | Karel Zak | 2014-07-28 11:57:10 +0200 |
---|---|---|
committer | Karel Zak | 2014-07-28 12:07:32 +0200 |
commit | 52d92543ffb8efb56036f316a1072d8fbba62c38 (patch) | |
tree | b673d16f7fc1f704fb2e458be655afdf652a2043 | |
parent | hwclock: use pluralized translations. (diff) | |
download | kernel-qcow2-util-linux-52d92543ffb8efb56036f316a1072d8fbba62c38.tar.gz kernel-qcow2-util-linux-52d92543ffb8efb56036f316a1072d8fbba62c38.tar.xz kernel-qcow2-util-linux-52d92543ffb8efb56036f316a1072d8fbba62c38.zip |
fdisk: fix -l [<device>]
* don't use err(), but warn(), so don't stop after the first error
* display all errors when "-l <device> ..." specified
* display only EACCES errors when list whole disks from
/proc/partitions ("fdisk -l" )
Reported-by: Boian Bonev <bbonev@ipacct.com>
Addresses: https://github.com/karelzak/util-linux/pull/106
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r-- | disk-utils/fdisk.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/disk-utils/fdisk.c b/disk-utils/fdisk.c index 8d57dbb17..46e632aa3 100644 --- a/disk-utils/fdisk.c +++ b/disk-utils/fdisk.c @@ -670,10 +670,13 @@ static int is_ide_cdrom_or_tape(char *device) return ret; } -static void print_device_pt(struct fdisk_context *cxt, char *device) +static void print_device_pt(struct fdisk_context *cxt, char *device, int warnme) { - if (fdisk_context_assign_device(cxt, device, 1) != 0) /* read-only */ - err(EXIT_FAILURE, _("cannot open %s"), device); + if (fdisk_context_assign_device(cxt, device, 1) != 0) { /* read-only */ + if (warnme || errno == EACCES) + warn(_("cannot open %s"), device); + return; + } list_disk_geometry(cxt); @@ -717,7 +720,7 @@ static void print_all_devices_pt(struct fdisk_context *cxt) if (!cn) continue; if (!is_ide_cdrom_or_tape(cn)) - print_device_pt(cxt, cn); + print_device_pt(cxt, cn, 0); free(cn); } fclose(f); @@ -912,7 +915,7 @@ int main(int argc, char **argv) if (argc > optind) { int k; for (k = optind; k < argc; k++) - print_device_pt(cxt, argv[k]); + print_device_pt(cxt, argv[k], 1); } else print_all_devices_pt(cxt); break; |