Re: blkid: exit code as non-root user, and segfault

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux