]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: add interface for FSSIZE field
authorAndrey Albershteyn <aalbersh@redhat.com>
Mon, 25 Apr 2022 15:08:37 +0000 (17:08 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 26 Apr 2022 08:26:03 +0000 (10:26 +0200)
Add interface to let filesystem probe calculate and set FSSIZE.
Enable that field in the 'superblocks' sample.

Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
libblkid/samples/superblocks.c
libblkid/src/blkid.h.in
libblkid/src/superblocks/superblocks.c
libblkid/src/superblocks/superblocks.h

index 7d95557716e42eef72ff4e4287770ecdc32789db..38903ecee21bc5099b17dc2bd0a8d54b68ca8e4f 100644 (file)
@@ -44,7 +44,7 @@ int main(int argc, char *argv[])
                        BLKID_SUBLKS_UUID | BLKID_SUBLKS_UUIDRAW |
                        BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE |
                        BLKID_SUBLKS_USAGE | BLKID_SUBLKS_VERSION |
-                       BLKID_SUBLKS_MAGIC);
+                       BLKID_SUBLKS_MAGIC | BLKID_SUBLKS_FSSIZE);
 
        rc = blkid_do_safeprobe(pr);
        if (rc == -1)
index 3cd4116d9184d742b9224f6ec7517b4f6ff5e0d7..ad4becf0ad3be5c4071d8a9c1587286f1b126fa9 100644 (file)
@@ -281,6 +281,7 @@ extern int blkid_probe_enable_superblocks(blkid_probe pr, int enable)
 #define BLKID_SUBLKS_VERSION   (1 << 8) /* read FS type from superblock */
 #define BLKID_SUBLKS_MAGIC     (1 << 9) /* define SBMAGIC and SBMAGIC_OFFSET */
 #define BLKID_SUBLKS_BADCSUM   (1 << 10) /* allow a bad checksum */
+#define BLKID_SUBLKS_FSSIZE    (1 << 11) /* read and define FSSIZE from superblock */
 
 #define BLKID_SUBLKS_DEFAULT   (BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID | \
                                 BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE)
index f21365538050feb8fbfc46bfe995cf4ecf8a28af..9adc2cfa33d410db6b90571549c70f4f2e93dfc3 100644 (file)
@@ -7,6 +7,7 @@
  * GNU Lesser General Public License.
  */
 
+#include <inttypes.h>
 #include <stdio.h>
 #include <string.h>
 #include <stdlib.h>
@@ -584,6 +585,16 @@ static int blkid_probe_set_usage(blkid_probe pr, int usage)
        return blkid_probe_set_value(pr, "USAGE", (unsigned char *) u, strlen(u) + 1);
 }
 
+int blkid_probe_set_fssize(blkid_probe pr, uint64_t size)
+{
+       struct blkid_chain *chn = blkid_probe_get_chain(pr);
+
+       if (!(chn->flags & BLKID_SUBLKS_FSSIZE))
+               return 0;
+
+       return blkid_probe_sprintf_value(pr, "FSSIZE", "%" PRIu64, size);
+}
+
 int blkid_probe_set_id_label(blkid_probe pr, const char *name,
                             const unsigned char *data, size_t len)
 {
index 9c489c438e32b81edfb452bc391fc411dad4178c..67803679f3c6875656e5bdb14d05e67fc1d24c54 100644 (file)
@@ -111,6 +111,7 @@ extern int blkid_probe_set_utf8_id_label(blkid_probe pr, const char *name,
                             const unsigned char *data, size_t len, int enc);
 
 int blkid_probe_set_block_size(blkid_probe pr, unsigned block_size);
+int blkid_probe_set_fssize(blkid_probe pr, uint64_t size);
 
 extern int blkid_probe_is_bitlocker(blkid_probe pr);
 extern int blkid_probe_is_ntfs(blkid_probe pr);