diff options
author | Karel Zak | 2009-09-22 12:32:34 +0200 |
---|---|---|
committer | Karel Zak | 2009-09-22 12:41:03 +0200 |
commit | c2dbd49bdfd84e9145044ae564d5ef841e60a41e (patch) | |
tree | 6f5ed95c3ebc78ebca1493639602a95f38449f81 /shlibs/blkid/src/probe.c | |
parent | libblkid: fix blkid_probe_set_utf8label() call for Joliet (diff) | |
download | kernel-qcow2-util-linux-c2dbd49bdfd84e9145044ae564d5ef841e60a41e.tar.gz kernel-qcow2-util-linux-c2dbd49bdfd84e9145044ae564d5ef841e60a41e.tar.xz kernel-qcow2-util-linux-c2dbd49bdfd84e9145044ae564d5ef841e60a41e.zip |
libblkid: trim tailing whitespace from unicode LABELs
old version:
$ ./blkid -o udev -p iso-joliet.img
ID_FS_LABEL=ThisIsLabel
ID_FS_LABEL_ENC=ThisIsLabel\x20\x20\x20\x20\x20
ID_FS_VERSION=Joliet\x20Extension
ID_FS_TYPE=iso9660
ID_FS_USAGE=filesystem
new version:
$ ./blkid -o udev -p iso-joliet.img
ID_FS_LABEL=ThisIsLabel
ID_FS_LABEL_ENC=ThisIsLabel
ID_FS_VERSION=Joliet\x20Extension
ID_FS_TYPE=iso9660
ID_FS_USAGE=filesystem
Reported-by: Maxim Levitsky <maximlevitsky@gmail.com>
Addresses-Ubuntu-Bug: #432215
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/blkid/src/probe.c')
-rw-r--r-- | shlibs/blkid/src/probe.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/shlibs/blkid/src/probe.c b/shlibs/blkid/src/probe.c index 05f61cf06..bac49771e 100644 --- a/shlibs/blkid/src/probe.c +++ b/shlibs/blkid/src/probe.c @@ -911,6 +911,9 @@ int blkid_probe_numof_values(blkid_probe pr) * @data: pointer to return value data or NULL * @len: pointer to return value length or NULL * + * Note, the @len returns length of the @data, including the terminating + * '\0' character. + * * Returns: 0 on success, or -1 in case of error. */ int blkid_probe_get_value(blkid_probe pr, int num, const char **name, @@ -938,6 +941,9 @@ int blkid_probe_get_value(blkid_probe pr, int num, const char **name, * @data: pointer to return value data or NULL * @len: pointer to return value length or NULL * + * Note, the @len returns length of the @data, including the terminating + * '\0' character. + * * Returns: 0 on success, or -1 in case of error. */ int blkid_probe_lookup_value(blkid_probe pr, const char *name, @@ -1013,3 +1019,21 @@ void blkid_unparse_uuid(const unsigned char *uuid, char *str, size_t len) #endif } + +/* Removes whitespace from the right-hand side of a string (trailing + * whitespace). + * + * Returns size of the new string (without \0). + */ +size_t blkid_rtrim_whitespace(unsigned char *str) +{ + size_t i = strlen((char *) str); + + while (i--) { + if (!isspace(str[i])) + break; + } + str[++i] = '\0'; + return i; +} + |