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:          <none>

    ...

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:          <none>

    ...

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
This commit is contained in:
Mike Fleetwood 2021-03-20 16:01:26 +00:00 committed by Curtis Gedak
parent 2a76af5beb
commit 690fedfff9
1 changed files with 6 additions and 1 deletions

View File

@ -141,7 +141,12 @@ void reiser4::read_uuid( Partition & partition )
return; 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);
} }