From: Karel Zak <kzak@redhat.com>
To: Bernhard Voelker <mail@bernhard-voelker.de>
Cc: "util-linux@vger.kernel.org" <util-linux@vger.kernel.org>
Subject: Re: blkid: exit code as non-root user, and segfault
Date: Mon, 10 Dec 2012 12:49:01 +0100 [thread overview]
Message-ID: <20121210114901.GD21405@x2.net.home> (raw)
In-Reply-To: <50C4CFDD.1070405@bernhard-voelker.de>
On Sun, Dec 09, 2012 at 06:52:29PM +0100, Bernhard Voelker wrote:
> blkid returns 0 without output when running as non-root user
> and when the cache /dev/.blkid.tab is not yet there:
>
> ./blkid /dev/sdb3 ; echo $?
> 0
[...]
> access("/dev/sdb3", F_OK) = 0
> stat("/dev/sdb3", {st_mode=S_IFBLK|0660, st_rdev=makedev(8, 19), ...}) = 0
[...]
> I'd have expected either an error message along with exit code 1,
> or success with some useful output.
Well, it seems that the code differentiate between:
a) device does not exist:
$ blkid /dev/FooBar; echo $?
2
or exists but does not match:
$ blkid -t LABEL=xyz /dev/sda1; echo $?
2
b) device exists, but there is nothing to print
$ blkid /dev/sda1; echo $?
0
just for the record, you can always print device name:
$ blkid -o device /dev/sda1; echo $?
/dev/sda1
0
maybe it's not obvious at a first glance, but the current behavior
seems correct.
Maybe we can detect the special situation (and print a warning
message) when the cache is empty and user is non-root to make it more
user-friendly. I'm not sure if any change in return code is necessary.
Karel
--
Karel Zak <kzak@redhat.com>
http://karelzak.blogspot.com
prev parent reply other threads:[~2012-12-10 11:49 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-09 17:52 blkid: exit code as non-root user, and segfault Bernhard Voelker
2012-12-10 8:42 ` Karel Zak
2012-12-10 8:58 ` Bernhard Voelker
2012-12-10 9:11 ` Karel Zak
2012-12-10 11:49 ` Karel Zak [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121210114901.GD21405@x2.net.home \
--to=kzak@redhat.com \
--cc=mail@bernhard-voelker.de \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox