diff options
author | Karel Zak | 2013-11-19 17:41:28 +0100 |
---|---|---|
committer | Karel Zak | 2013-11-19 17:41:28 +0100 |
commit | a53cc4e0cb30eb55e5ccbd376d1ea803aefa060d (patch) | |
tree | 3da115b2873b666048f6cb9d0a55f0564b43de2f /libmount/src | |
parent | fsck: add ext4 to list of filesystems with progress bars in fsck man page (diff) | |
download | kernel-qcow2-util-linux-a53cc4e0cb30eb55e5ccbd376d1ea803aefa060d.tar.gz kernel-qcow2-util-linux-a53cc4e0cb30eb55e5ccbd376d1ea803aefa060d.tar.xz kernel-qcow2-util-linux-a53cc4e0cb30eb55e5ccbd376d1ea803aefa060d.zip |
libmount: add mnt_tag_is_valid()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src')
-rw-r--r-- | libmount/src/libmount.h.in | 1 | ||||
-rw-r--r-- | libmount/src/libmount.sym | 4 | ||||
-rw-r--r-- | libmount/src/utils.c | 17 |
3 files changed, 22 insertions, 0 deletions
diff --git a/libmount/src/libmount.h.in b/libmount/src/libmount.h.in index bb03363c8..8c8e739c9 100644 --- a/libmount/src/libmount.h.in +++ b/libmount/src/libmount.h.in @@ -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); diff --git a/libmount/src/libmount.sym b/libmount/src/libmount.sym index 430c58ec6..d1180d35b 100644 --- a/libmount/src/libmount.sym +++ b/libmount/src/libmount.sym @@ -287,3 +287,7 @@ global: mnt_unref_fs; mnt_unref_table; } MOUNT_2.23; + +MOUNT_2.25 { + mnt_tag_is_valid; +} MOUNT_2.24; diff --git a/libmount/src/utils.c b/libmount/src/utils.c index 0d5a22716..66203d2b4 100644 --- a/libmount/src/utils.c +++ b/libmount/src/utils.c @@ -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; |