Red Hat Bugzilla – Bug 1501953
blkid shows wrong return code on failure with ambivalent results
Last modified: 2018-04-10 13:28:02 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
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.'
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.
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
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