diff options
author | David Teigland <teigland@redhat.com> | 2014-10-10 15:46:35 -0500 |
---|---|---|
committer | David Teigland <teigland@redhat.com> | 2014-10-17 16:58:50 -0500 |
commit | 3e7915b20aa95759c7e4b92b8cf58de336ac6182 (patch) | |
tree | 681d2b3b8c4199d10b9af6008f5dee88e30ccdc5 /lib/misc/lvm-string.c | |
parent | 4461c624bc59ddca60f4bbf1eb447d64c8d4aeb2 (diff) | |
download | lvm2-dev-dct-systemid2.tar.gz |
system_id: use for VG ownershipdev-dct-systemid2
See included lvmsystemid(7) for full description.
Diffstat (limited to 'lib/misc/lvm-string.c')
-rw-r--r-- | lib/misc/lvm-string.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/lib/misc/lvm-string.c b/lib/misc/lvm-string.c index 84c870837..f4c7110a0 100644 --- a/lib/misc/lvm-string.c +++ b/lib/misc/lvm-string.c @@ -101,6 +101,41 @@ int validate_name(const char *n) return (_validate_name(n) == NAME_VALID) ? 1 : 0; } +/* + * Copy valid characters from source to destination. + * Invalid characters are skipped. Copying is stopped + * when NAME_LEN characters have been copied. + */ + +void copy_valid_chars(const char *src, char *dst) +{ + const char *s = src; + char *d = dst; + int len = 0; + int i; + char c; + + if (!s || !*s) + return; + + for (i = 0; i < strlen(src); i++) { + c = *s; + + if (!isalnum(c) && c != '.' && c != '_' && c != '-' && c != '+') { + s++; + continue; + } + + *d = *s; + d++; + s++; + len++; + + if (len == NAME_LEN) + break; + } +} + static const char *_lvname_has_reserved_prefix(const char *lvname) { static const char _prefixes[][12] = { |