From 690fedfff999ae17b2b63350ed0617c055982014 Mon Sep 17 00:00:00 2001 From: Mike Fleetwood Date: Sat, 20 Mar 2021 16:01:26 +0000 Subject: [PATCH] Explicitly read the reiser4 volume UUID when present Reiser4 has introduced new disk format which includes support for spanning the file system over multiple block devices (subvolumes) [1][2]. As such the output of the debugfs.reiser4 for the UUID has changed slightly. So far the new reiser4progs package (version 2.0.x) is only available as a Debian experimental package. Using reiser4progs 1.2.1 the old output was like this: $ debugfs.reiser4 test.img debugfs.reiser4 1.2.1 Format release: 4.0.2 Copyright (C) 2001-2005 by Hans Reiser, licensing governed by reiser4progs/COPYING. Master super block (16): magic: ReIsEr4 blksize: 4096 format: 0x0 (format40) uuid: 1116afce-99fd-4a6e-94cb-2d9f19c91d67 label: ... With reiser4progs 2.0.4 the new output is like this: $ debugfs.reiser4 test.img debugfs.reiser4 Package Version: 2.0.4 Software Framework Release: 5.1.3 Copyright (C) 2001-2005 by Hans Reiser, licensing governed by reiser4progs/COPYING. Master super block (16): magic: ReIsEr4 blksize: 4096 volume: 0x1 (asym) distrib: 0x1 (fsx32m) format: 0x1 (format41) description: Standard layout for logical volumes. stripe bits: 14 mirror id: 0 replicas: 0 volume uuid: 9538bfa3-5694-4abe-864c-edc288a9d801 subvol uuid: d841c692-2042-49e6-ac55-57e454691782 label: ... GParted happens to read the correct UUID just because the first matching "uuid" string in the output is the volume UUID. Make the code more robust by explicitly reading the volume uuid when labelled as such. [1] Logical Volumes Howto https://reiser4.wiki.kernel.org/index.php/Logical_Volumes_Howto [2] Logical Volumes Background https://reiser4.wiki.kernel.org/index.php/Logical_Volumes_Background --- src/reiser4.cc | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/reiser4.cc b/src/reiser4.cc index ed4e1c6c..47f2c2d5 100644 --- a/src/reiser4.cc +++ b/src/reiser4.cc @@ -141,7 +141,12 @@ void reiser4::read_uuid( Partition & partition ) return; } - partition.uuid = Utils::regexp_label(output, "uuid:[[:blank:]]*(" RFC4122_NONE_NIL_UUID_REGEXP ")"); + Glib::ustring pattern = "uuid:[[:blank:]]*(" RFC4122_NONE_NIL_UUID_REGEXP ")"; + // Reiser4progs >= 2.0.3 supports subvolumes. Ensure the volume UUID, rather than + // subvolume UUID, is reported. + if (output.find("volume uuid:") != Glib::ustring::npos) + pattern = "volume " + pattern; + partition.uuid = Utils::regexp_label(output, pattern); }