Update parsing of btrfs filesystem show for the UUID (#733601)
Issue 1/2 - GParted shows warnings for mounted btrfs file systems 'btrfs filesystem show /dev/PTN' command is used to query details of a btrfs file system. When the file system is mounted the command reports failed exit status 1, but only when using btrfs-progs v3.14 and v3.14.1. This causes GParted to: (1) report warnings from the failed commands for a mounted btrfs file system, (2) fail to determine file system usage figures and (3) fail to display the mount point and busy indicator for non-mounting devices in multi-device btrfs file systems. The label is also read using the secondary blkid method via the FS_Info cache. Failed exit status 1 when the btrfs file system is mounted: # fgrep sdb1 /proc/mounts /dev/sdb1 /mnt/1 btrfs rw,seclabel,relatime,space_cache 0 0 # btrfs filesystem show /dev/sdb1 Label: 'test1-btrfs' uuid: 033e6b07-ee6a-4620-a585-8580a2b83275 Total devices 1 FS bytes used 192.00KiB devid 1 size 2.00GiB used 240.75MiB path /dev/sdb1 Btrfs v3.14.1 # echo $? 1 Successful exit status 0 when the btrfs file system is unmounted: # umount /dev/sdb1 # btrfs filesystem show /dev/sdb1 Label: 'test1-btrfs' uuid: 033e6b07-ee6a-4620-a585-8580a2b83275 Total devices 1 FS bytes used 192.00KiB devid 1 size 2.00GiB used 240.75MiB path /dev/sdb1 Btrfs v3.14.1 # echo $? 0 Fix by ignoring the exit status of the 'btrfs filesystem show' command and rely on parsing the required information to determine success or failure. The output from the older 'btrfs-show' command is almost identical so the same code will parse it in all cases. Patch 1/4 - btrfs::read_uuid() This patch changes the secondary method used to read the btrfs UUID to resolve issue 1/2 as described above. Bug #733601 - Btrfs: Warnings and missing label with btrfs-progs 3.12 and 3.14
This commit is contained in:
parent
3bea067596
commit
82c6265fa5
24
src/btrfs.cc
24
src/btrfs.cc
|
@ -406,22 +406,16 @@ void btrfs::read_label( Partition & partition )
|
|||
void btrfs::read_uuid( Partition & partition )
|
||||
{
|
||||
if ( btrfs_found )
|
||||
{
|
||||
exit_status = Utils::execute_command( "btrfs filesystem show " + partition .get_path(), output, error, true ) ;
|
||||
if ( ! exit_status )
|
||||
{
|
||||
partition .uuid = Utils::regexp_label( output, "uuid:[[:blank:]]*(" RFC4122_NONE_NIL_UUID_REGEXP ")" ) ;
|
||||
}
|
||||
}
|
||||
Utils::execute_command( "btrfs filesystem show " + partition .get_path(), output, error, true ) ;
|
||||
else
|
||||
Utils::execute_command( "btrfs-show " + partition .get_path(), output, error, true ) ;
|
||||
//In many cases the exit status doesn't reflect valid output or an error condition
|
||||
// so rely on parsing the output to determine success.
|
||||
|
||||
Glib::ustring uuid_str = Utils::regexp_label( output, "uuid:[[:blank:]]*(" RFC4122_NONE_NIL_UUID_REGEXP ")" ) ;
|
||||
if ( ! uuid_str .empty() )
|
||||
partition .uuid = uuid_str ;
|
||||
else
|
||||
{
|
||||
exit_status = Utils::execute_command( "btrfs-show " + partition .get_path(), output, error, true ) ;
|
||||
if ( ! exit_status )
|
||||
{
|
||||
partition .uuid = Utils::regexp_label( output, "uuid:[[:blank:]]*(" RFC4122_NONE_NIL_UUID_REGEXP ")" ) ;
|
||||
}
|
||||
}
|
||||
if ( exit_status )
|
||||
{
|
||||
if ( ! output .empty() )
|
||||
partition .messages .push_back( output ) ;
|
||||
|
|
Loading…
Reference in New Issue