]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: allow overwrite how to use libblkid
authorKarel Zak <kzak@redhat.com>
Tue, 9 May 2023 11:21:58 +0000 (13:21 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 9 May 2023 11:21:58 +0000 (13:21 +0200)
This is unnecessary for classic mount-like tasks, but application
may use libmount in situation when the default for probing is not
optimal.

Addresses: https://github.com/util-linux/util-linux/issues/2214
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/docs/libmount-sections.txt
libmount/src/cache.c
libmount/src/libmount.h.in
libmount/src/libmount.sym

index 3e2e6761daad73f1479802a14bb08befce70b891..86a762277dfcd515640c04336b02d420a4df2524 100644 (file)
@@ -9,6 +9,7 @@ mnt_cache_device_has_tag
 mnt_cache_find_tag_value
 mnt_cache_read_tags
 mnt_cache_set_targets
+mnt_cache_set_sbprobe
 mnt_get_fstype
 mnt_pretty_path
 mnt_resolve_path
index c9b99538a3154ff45b4006a72d0f3052afb6c638..2505919c99c135719531adf95addae6bd0be141e 100644 (file)
@@ -56,6 +56,7 @@ struct libmnt_cache {
        size_t                  nents;
        size_t                  nallocs;
        int                     refcount;
+       int                     probe_sb_extra; /* extra BLKID_SUBLKS_* flags */
 
        /* blkid_evaluate_tag() works in two ways:
         *
@@ -170,6 +171,23 @@ int mnt_cache_set_targets(struct libmnt_cache *cache,
        return 0;
 }
 
+/**
+ * mnt_cache_set_sbprobe:
+ * @cache: cache pointer
+ * @flags: BLKID_SUBLKS_* flags
+ *
+ * Add extra flags to the libblkid prober. Don't use if not sure.
+ *
+ * Returns: negative number in case of error, or 0 o success.
+ */
+int mnt_cache_set_sbprobe(struct libmnt_cache *cache, int flags)
+{
+       if (!cache)
+               return -EINVAL;
+
+       cache->probe_sb_extra = flags;
+       return 0;
+}
 
 /* note that the @key could be the same pointer as @value */
 static int cache_add_entry(struct libmnt_cache *cache, char *key,
@@ -346,7 +364,7 @@ int mnt_cache_read_tags(struct libmnt_cache *cache, const char *devname)
        blkid_probe_enable_superblocks(pr, 1);
        blkid_probe_set_superblocks_flags(pr,
                        BLKID_SUBLKS_LABEL | BLKID_SUBLKS_UUID |
-                       BLKID_SUBLKS_TYPE);
+                       BLKID_SUBLKS_TYPE | cache->probe_sb_extra);
 
        blkid_probe_enable_partitions(pr, 1);
        blkid_probe_set_partitions_flags(pr, BLKID_PARTS_ENTRY_DETAILS);
index 6e57efb751e783eaece856c60cc9edc3f079f8be..73a2802f49501984c7b8fc033771ff55e5a7fec7 100644 (file)
@@ -363,6 +363,7 @@ extern void mnt_unref_cache(struct libmnt_cache *cache);
 
 extern int mnt_cache_set_targets(struct libmnt_cache *cache,
                                struct libmnt_table *mountinfo);
+extern int mnt_cache_set_sbprobe(struct libmnt_cache *cache, int flags);
 extern int mnt_cache_read_tags(struct libmnt_cache *cache, const char *devname);
 
 extern int mnt_cache_device_has_tag(struct libmnt_cache *cache,
index 7d8396a1a935d99d787c32e61773050b4c4e4f67..715bb5c5f02119070bd6a619d5d89f9a0f23c1e5 100644 (file)
@@ -368,6 +368,7 @@ MOUNT_2_38 {
 } MOUNT_2_37;
 
 MOUNT_2_39 {
+       mnt_cache_set_sbprobe;
        mnt_context_enable_onlyonce;
        mnt_context_is_lazy;
        mnt_context_enable_noautofs;