summaryrefslogtreecommitdiffstats
path: root/libmount/src/tab_parse.c
diff options
context:
space:
mode:
authorKarel Zak2014-02-17 13:17:47 +0100
committerKarel Zak2014-02-17 13:17:47 +0100
commit5980048edd296797afbdc8b7e973ec0a779a3351 (patch)
treeec266c2c0f4427feab7e9eb00425e410c60ec593 /libmount/src/tab_parse.c
parentlibmount: accept (deleted) path suffix in mountinfo file (diff)
downloadkernel-qcow2-util-linux-5980048edd296797afbdc8b7e973ec0a779a3351.tar.gz
kernel-qcow2-util-linux-5980048edd296797afbdc8b7e973ec0a779a3351.tar.xz
kernel-qcow2-util-linux-5980048edd296797afbdc8b7e973ec0a779a3351.zip
libmount: make the mountinfo parser more robust
... sorry, the previous change to the parser was too stupid. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/tab_parse.c')
-rw-r--r--libmount/src/tab_parse.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/libmount/src/tab_parse.c b/libmount/src/tab_parse.c
index 910b4b313..81232736c 100644
--- a/libmount/src/tab_parse.c
+++ b/libmount/src/tab_parse.c
@@ -123,7 +123,6 @@ static int mnt_parse_table_line(struct libmnt_fs *fs, char *s)
*/
static int mnt_parse_mountinfo_line(struct libmnt_fs *fs, char *s)
{
- size_t sz;
int rc, end = 0;
unsigned int maj, min;
char *fstype = NULL, *src = NULL, *p;
@@ -147,15 +146,6 @@ static int mnt_parse_mountinfo_line(struct libmnt_fs *fs, char *s)
if (rc >= 7 && end > 0)
s += end;
- /* remove "(deleted)" suffix */
- sz = strlen(fs->target);
- if (sz > PATH_DELETED_SUFFIX_SZ) {
- char *p = fs->target + (sz - PATH_DELETED_SUFFIX_SZ);
-
- if (strcmp(p, PATH_DELETED_SUFFIX) == 0)
- *p = '\0';
- }
-
/* (7) optional fields, terminated by " - " */
p = strstr(s, " - ");
if (!p) {
@@ -175,9 +165,20 @@ static int mnt_parse_mountinfo_line(struct libmnt_fs *fs, char *s)
&fs->fs_optstr);
if (rc >= 10) {
+ size_t sz;
+
fs->flags |= MNT_FS_KERNEL;
fs->devno = makedev(maj, min);
+ /* remove "(deleted)" suffix */
+ sz = strlen(fs->target);
+ if (sz > PATH_DELETED_SUFFIX_SZ) {
+ char *p = fs->target + (sz - PATH_DELETED_SUFFIX_SZ);
+
+ if (strcmp(p, PATH_DELETED_SUFFIX) == 0)
+ *p = '\0';
+ }
+
unmangle_string(fs->root);
unmangle_string(fs->target);
unmangle_string(fs->vfs_optstr);