Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1501953

Summary: blkid shows wrong return code on failure with ambivalent results
Product: Red Hat Enterprise Linux 7 Reporter: John Pittman <jpittman>
Component: util-linuxAssignee: Karel Zak <kzak>
Status: CLOSED ERRATA QA Contact: Radka Brychtova <rskvaril>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 7.4CC: fsumsal, rskvaril
Target Milestone: rc   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
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 17:27:15 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description John Pittman 2017-10-13 14:55:00 UTC
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 18:46:12 UTC
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 09:25:37 UTC
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 10:03:38 UTC
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 17:27:15 UTC
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