|
|
dbeef3 |
From 863ecca27cfc937bc6fb2131e0d0e35947e38ce6 Mon Sep 17 00:00:00 2001
|
|
|
dbeef3 |
From: Andrey Albershteyn <aalbersh@redhat.com>
|
|
|
dbeef3 |
Date: Mon, 25 Apr 2022 17:08:37 +0200
|
|
|
dbeef3 |
Subject: libblkid: add interface for FSSIZE field
|
|
|
dbeef3 |
|
|
|
dbeef3 |
Add interface to let filesystem probe calculate and set FSSIZE.
|
|
|
dbeef3 |
Enable that field in the 'superblocks' sample.
|
|
|
dbeef3 |
|
|
|
dbeef3 |
Upstream: http://github.com/util-linux/util-linux/commit/ad08ae0aa
|
|
|
dbeef3 |
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=2064810
|
|
|
dbeef3 |
Signed-off-by: Andrey Albershteyn <aalbersh@redhat.com>
|
|
|
dbeef3 |
---
|
|
|
dbeef3 |
libblkid/samples/superblocks.c | 2 +-
|
|
|
dbeef3 |
libblkid/src/blkid.h.in | 1 +
|
|
|
dbeef3 |
libblkid/src/superblocks/superblocks.c | 11 +++++++++++
|
|
|
dbeef3 |
libblkid/src/superblocks/superblocks.h | 1 +
|
|
|
dbeef3 |
4 files changed, 14 insertions(+), 1 deletion(-)
|
|
|
dbeef3 |
|
|
|
dbeef3 |
diff --git a/libblkid/samples/superblocks.c b/libblkid/samples/superblocks.c
|
|
|
dbeef3 |
index 7d9555771..38903ecee 100644
|
|
|
dbeef3 |
--- a/libblkid/samples/superblocks.c
|
|
|
dbeef3 |
+++ b/libblkid/samples/superblocks.c
|
|
|
dbeef3 |
@@ -44,7 +44,7 @@ int main(int argc, char *argv[])
|
|
|
dbeef3 |
BLKID_SUBLKS_UUID | BLKID_SUBLKS_UUIDRAW |
|
|
|
dbeef3 |
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE |
|
|
|
dbeef3 |
BLKID_SUBLKS_USAGE | BLKID_SUBLKS_VERSION |
|
|
|
dbeef3 |
- BLKID_SUBLKS_MAGIC);
|
|
|
dbeef3 |
+ BLKID_SUBLKS_MAGIC | BLKID_SUBLKS_FSSIZE);
|
|
|
dbeef3 |
|
|
|
dbeef3 |
rc = blkid_do_safeprobe(pr);
|
|
|
dbeef3 |
if (rc == -1)
|
|
|
dbeef3 |
diff --git a/libblkid/src/blkid.h.in b/libblkid/src/blkid.h.in
|
|
|
dbeef3 |
index 3cd4116d9..ad4becf0a 100644
|
|
|
dbeef3 |
--- a/libblkid/src/blkid.h.in
|
|
|
dbeef3 |
+++ b/libblkid/src/blkid.h.in
|
|
|
dbeef3 |
@@ -281,6 +281,7 @@ extern int blkid_probe_enable_superblocks(blkid_probe pr, int enable)
|
|
|
dbeef3 |
#define BLKID_SUBLKS_VERSION (1 << 8) /* read FS type from superblock */
|
|
|
dbeef3 |
#define BLKID_SUBLKS_MAGIC (1 << 9) /* define SBMAGIC and SBMAGIC_OFFSET */
|
|
|
dbeef3 |
#define BLKID_SUBLKS_BADCSUM (1 << 10) /* allow a bad checksum */
|
|
|
dbeef3 |
+#define BLKID_SUBLKS_FSSIZE (1 << 11) /* read and define FSSIZE from superblock */
|
|
|
dbeef3 |
|
|
|
dbeef3 |
#define BLKID_SUBLKS_DEFAULT (BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID | \
|
|
|
dbeef3 |
BLKID_SUBLKS_TYPE | BLKID_SUBLKS_SECTYPE)
|
|
|
dbeef3 |
diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c
|
|
|
dbeef3 |
index f21365538..9adc2cfa3 100644
|
|
|
dbeef3 |
--- a/libblkid/src/superblocks/superblocks.c
|
|
|
dbeef3 |
+++ b/libblkid/src/superblocks/superblocks.c
|
|
|
dbeef3 |
@@ -7,6 +7,7 @@
|
|
|
dbeef3 |
* GNU Lesser General Public License.
|
|
|
dbeef3 |
*/
|
|
|
dbeef3 |
|
|
|
dbeef3 |
+#include <inttypes.h>
|
|
|
dbeef3 |
#include <stdio.h>
|
|
|
dbeef3 |
#include <string.h>
|
|
|
dbeef3 |
#include <stdlib.h>
|
|
|
dbeef3 |
@@ -584,6 +585,16 @@ static int blkid_probe_set_usage(blkid_probe pr, int usage)
|
|
|
dbeef3 |
return blkid_probe_set_value(pr, "USAGE", (unsigned char *) u, strlen(u) + 1);
|
|
|
dbeef3 |
}
|
|
|
dbeef3 |
|
|
|
dbeef3 |
+int blkid_probe_set_fssize(blkid_probe pr, uint64_t size)
|
|
|
dbeef3 |
+{
|
|
|
dbeef3 |
+ struct blkid_chain *chn = blkid_probe_get_chain(pr);
|
|
|
dbeef3 |
+
|
|
|
dbeef3 |
+ if (!(chn->flags & BLKID_SUBLKS_FSSIZE))
|
|
|
dbeef3 |
+ return 0;
|
|
|
dbeef3 |
+
|
|
|
dbeef3 |
+ return blkid_probe_sprintf_value(pr, "FSSIZE", "%" PRIu64, size);
|
|
|
dbeef3 |
+}
|
|
|
dbeef3 |
+
|
|
|
dbeef3 |
int blkid_probe_set_id_label(blkid_probe pr, const char *name,
|
|
|
dbeef3 |
const unsigned char *data, size_t len)
|
|
|
dbeef3 |
{
|
|
|
dbeef3 |
diff --git a/libblkid/src/superblocks/superblocks.h b/libblkid/src/superblocks/superblocks.h
|
|
|
dbeef3 |
index 9c489c438..67803679f 100644
|
|
|
dbeef3 |
--- a/libblkid/src/superblocks/superblocks.h
|
|
|
dbeef3 |
+++ b/libblkid/src/superblocks/superblocks.h
|
|
|
dbeef3 |
@@ -111,6 +111,7 @@ extern int blkid_probe_set_utf8_id_label(blkid_probe pr, const char *name,
|
|
|
dbeef3 |
const unsigned char *data, size_t len, int enc);
|
|
|
dbeef3 |
|
|
|
dbeef3 |
int blkid_probe_set_block_size(blkid_probe pr, unsigned block_size);
|
|
|
dbeef3 |
+int blkid_probe_set_fssize(blkid_probe pr, uint64_t size);
|
|
|
dbeef3 |
|
|
|
dbeef3 |
extern int blkid_probe_is_bitlocker(blkid_probe pr);
|
|
|
dbeef3 |
extern int blkid_probe_is_ntfs(blkid_probe pr);
|
|
|
dbeef3 |
--
|
|
|
dbeef3 |
2.36.1
|
|
|
dbeef3 |
|