]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: add mnt_tag_is_valid()
authorKarel Zak <kzak@redhat.com>
Tue, 19 Nov 2013 16:41:28 +0000 (17:41 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 14 Jan 2014 11:48:04 +0000 (12:48 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/docs/libmount-sections.txt
libmount/src/libmount.h.in
libmount/src/libmount.sym
libmount/src/utils.c

index ec04fff0982f89c06a3db74808e500ff925235c8..6affbfbb6e3d02432e8be1a46e143538ccaac602 100644 (file)
@@ -370,6 +370,7 @@ mnt_has_regular_mtab
 mnt_mangle
 mnt_match_fstype
 mnt_match_options
+mnt_tag_is_valid
 mnt_unmangle
 </SECTION>
 
index bb03363c860396adb72e41f1bd50e9c45c5ebe88..8c8e739c9a81d9e5005c1361438769666aac2d27 100644 (file)
@@ -197,6 +197,7 @@ extern char *mnt_mangle(const char *str)
 extern char *mnt_unmangle(const char *str)
                        __ul_attribute__((warn_unused_result));
 
+extern int mnt_tag_is_valid(const char *tag);
 extern int mnt_fstype_is_netfs(const char *type);
 extern int mnt_fstype_is_pseudofs(const char *type);
 
index 430c58ec676a40f083eada797a6fa66f94ab8279..d1180d35b5a4ded2bd6a345114fc6f588b1de358 100644 (file)
@@ -287,3 +287,7 @@ global:
        mnt_unref_fs;
        mnt_unref_table;
 } MOUNT_2.23;
+
+MOUNT_2.25 {
+       mnt_tag_is_valid;
+} MOUNT_2.24;
index 0d5a22716634acfaa0bdf180a4738c7408134618..66203d2b47be073bf8d4cde258f8a1a6e2a2a50e 100644 (file)
@@ -14,6 +14,7 @@
 #include <fcntl.h>
 #include <pwd.h>
 #include <grp.h>
+#include <blkid.h>
 
 #include "strutils.h"
 #include "pathnames.h"
@@ -71,6 +72,22 @@ int mnt_valid_tagname(const char *tagname)
        return 0;
 }
 
+/**
+ * mnt_tag_is_valid:
+ * @tag: NAME=value string
+ *
+ * Returns: 1 if the @tag is parsable and tag NAME= is supported by libmount, or 0.
+ */
+int mnt_tag_is_valid(const char *tag)
+{
+       char *t = NULL;
+       int rc = tag && blkid_parse_tag_string(tag, &t, NULL) == 0
+                    && mnt_valid_tagname(t);
+
+       free(t);
+       return rc;
+}
+
 int mnt_parse_offset(const char *str, size_t len, uintmax_t *res)
 {
        char *p;