Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1501953 - blkid shows wrong return code on failure with ambivalent results
blkid shows wrong return code on failure with ambivalent results
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: util-linux (Show other bugs)
7.4
All Linux
unspecified Severity medium
: rc
: ---
Assigned To: Karel Zak
Radka Skvarilova
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2017-10-13 10:55 EDT by John Pittman
Modified: 2018-04-10 13:28 EDT (History)
2 users (show)

See Also:
Fixed In Version: util-linux-2.23.2-45.el7
Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2018-04-10 13:27:15 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)


External Trackers
Tracker ID Priority Status Summary Last Updated
Red Hat Knowledge Base (Solution) 3214961 None None None 2017-10-13 11:07 EDT
Red Hat Product Errata RHBA-2018:0936 None None None 2018-04-10 13:28 EDT

  None (edit)
Description John Pittman 2017-10-13 10:55:00 EDT
Description of problem:

Running blkid against a device with multiple filesystems present shows the wrong return code.  It returns BLKID_EXIT_NOTFOUND(2), when the return should be BLKID_EXIT_AMBIVAL(8).

Per the man page:
~~~
RETURN CODE
   If the specified token was found, or if any tags were shown from (specified) devices, 0 is returned.
   If the specified token was not found, or no (specified) devices could be identified, an exit code of 2 is returned.
   For usage or other errors, an exit code of 4 is returned.
   If an ambivalent low-level probing result was detected, an exit code of 8 is returned.
~~~

Additionally, the command fails silently and should not.

Version-Release number of selected component (if applicable):

util-linux-2.23.2-43.el7.x86_64

How reproducible:

[root@localhost ~]# wipefs /dev/sdd
offset               type
----------------------------------------------------------------
0x3ffa9000           zfs_member   [filesystem]

0x0                  xfs   [filesystem]
                     LABEL: f25
                     UUID:  08b51be7-10d9-4e69-b75c-ba4fd55a301a

[root@localhost ~]# blkid /dev/sdd
[root@localhost ~]# echo $?
2

#define BLKID_EXIT_NOTFOUND     2       /* token or device not found */
#define BLKID_EXIT_OTHER        4       /* bad usage or other error */
#define BLKID_EXIT_AMBIVAL      8       /* ambivalent low-level probing detected */

Actual results:

Command fails silently and returns 2.

Expected results:

The command should return as the probing option does, with an error that states there were likely ambivalent results, with a reference to wipefs, and with 8 as it's return code.

[root@localhost ~]# blkid -p /dev/sdd
/dev/sdd: ambivalent result (probably more filesystems on the device, use wipefs(8) to see more details)
[root@localhost ~]# echo $?
8
Comment 2 John Pittman 2017-10-13 14:46:12 EDT
It's also problematic that when the blkid command is used with no arguments, it does not display anything for devices that have multiple labels.  This is probably desirable, but is not informative at all.  It's also the way most customers use the command.  

Is it possible to get a mention in the man page of this behavior?  Something like 'If ambivalent results are found when running blkid with no arguments, no results will be displayed for the device.'
Comment 3 Karel Zak 2017-10-16 05:25:37 EDT
man page:

-p     Switch to low-level superblock probing mode (bypassing the cache).
...
If an ambivalent *low-level probing* result was detected, an exit code of 8 is returned.

--

If you don't use -p, then blkid reads cached information and has no clue about the ambivalent result. There is no way how to return 8 in this case.

It seems that all we can do is to add more information to the man page.
Comment 4 Karel Zak 2017-10-16 06:03:38 EDT
I've added some extra notes to the man page in the upstream tree. We need something like this for RHEL7.

https://github.com/karelzak/util-linux/commit/12786a901520d7b30ff75ee8727221bf8a3089cb
https://github.com/karelzak/util-linux/commit/27fbfef33c1f23b5448b6cee856bcb3500b33c42
Comment 14 errata-xmlrpc 2018-04-10 13:27:15 EDT
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHBA-2018:0936

Note You need to log in before you can comment on or make changes to this bug.