diff options
author | Petr Uzel | 2012-09-20 15:53:50 +0200 |
---|---|---|
committer | Karel Zak | 2012-09-21 12:14:14 +0200 |
commit | 2754ffc5f52294a48ab73f4f26182020907997b0 (patch) | |
tree | 96bd55bf178e7f8f5a1a4ffe33aa5c75297856a6 /term-utils/setterm.c | |
parent | sfdisk: Fix format specifiers for size_t (diff) | |
download | kernel-qcow2-util-linux-2754ffc5f52294a48ab73f4f26182020907997b0.tar.gz kernel-qcow2-util-linux-2754ffc5f52294a48ab73f4f26182020907997b0.tar.xz kernel-qcow2-util-linux-2754ffc5f52294a48ab73f4f26182020907997b0.zip |
setterm: make error message more informative
If `setterm -dump` fails because of lack of permission to read
/dev/vcsa, it should not report that it couldn't read /dev/vcsa0.
This could be misleading if there is only /dev/vcsa, but not /dev/vcsa0.
Before:
$ ./setterm -dump
setterm: Couldn't read /dev/vcsa0
After:
$ ./setterm -dump
setterm: Couldn't read neither /dev/vcsa0 nor /dev/vcsa
(Note: /dev/vcsa0 does not exist and the user does not have read
permission on /dev/vcsa in this case).
Addresses: https://bugzilla.novell.com/show_bug.cgi?id=780615
Reported-by: Christopher Yeleighton <giecrilj@stegny.2a.pl>
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
Diffstat (limited to 'term-utils/setterm.c')
-rw-r--r-- | term-utils/setterm.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/term-utils/setterm.c b/term-utils/setterm.c index a2cf93b1e..18873f331 100644 --- a/term-utils/setterm.c +++ b/term-utils/setterm.c @@ -1208,9 +1208,13 @@ screendump(int vcnum, FILE * F) close(fd); return; - read_error: - warnx(_("Couldn't read %s"), infile); - error: +read_error: + if (vcnum != 0) + warnx(_("Couldn't read %s"), infile); + else + warnx(_("Couldn't read neither /dev/vcsa0 nor /dev/vcsa")); + +error: if (fd >= 0) close(fd); exit(EXIT_FAILURE); |