]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: make gfs2 prober more extendible
authorKarel Zak <kzak@redhat.com>
Mon, 11 Jan 2021 10:58:16 +0000 (11:58 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 11 Jan 2021 10:58:16 +0000 (11:58 +0100)
The current GFS2 prober hard codes superblock constants, but these
constants are affected by GFS2 development.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1913844
Signed-off-by: Karel Zak <kzak@redhat.com>
libblkid/src/superblocks/gfs.c

index e22a6a3f953a094f580ba312ce16ca7aa17ba9d3..37a74b157f909312b666ee598edcbddc7deea072 100644 (file)
@@ -18,9 +18,6 @@
 /* gfs1 constants: */
 #define GFS_FORMAT_FS           1309
 #define GFS_FORMAT_MULTI        1401
-/* gfs2 constants: */
-#define GFS2_FORMAT_FS          1801
-#define GFS2_FORMAT_MULTI       1900
 
 struct gfs2_meta_header {
        uint32_t mh_magic;
@@ -58,6 +55,8 @@ struct gfs2_sb {
        uint8_t sb_uuid[16]; /* The UUID maybe 0 for backwards compat */
 } __attribute__((packed));
 
+
+
 static int probe_gfs(blkid_probe pr, const struct blkid_idmag *mag)
 {
        struct gfs2_sb *sbd;
@@ -81,6 +80,15 @@ static int probe_gfs(blkid_probe pr, const struct blkid_idmag *mag)
        return 1;
 }
 
+static inline int gfs2_format_is_valid(uint32_t format)
+{
+       return (format >= 1800 && format < 1900);
+}
+static inline int gfs2_multiformat_is_valid(uint32_t multi)
+{
+       return (multi >= 1900 && multi < 2000);
+}
+
 static int probe_gfs2(blkid_probe pr, const struct blkid_idmag *mag)
 {
        struct gfs2_sb *sbd;
@@ -89,8 +97,8 @@ static int probe_gfs2(blkid_probe pr, const struct blkid_idmag *mag)
        if (!sbd)
                return errno ? -errno : 1;
 
-       if (be32_to_cpu(sbd->sb_fs_format) == GFS2_FORMAT_FS &&
-           be32_to_cpu(sbd->sb_multihost_format) == GFS2_FORMAT_MULTI)
+       if (gfs2_format_is_valid(be32_to_cpu(sbd->sb_fs_format)) &&
+           gfs2_multiformat_is_valid(be32_to_cpu(sbd->sb_multihost_format)))
        {
                if (*sbd->sb_locktable)
                        blkid_probe_set_label(pr,