diff options
author | Karel Zak | 2012-01-12 16:52:32 +0100 |
---|---|---|
committer | Karel Zak | 2012-01-12 16:52:32 +0100 |
commit | 1e8c936978f5467a50732a072084337653820bba (patch) | |
tree | feddd390d2d5d5545e8abca8a7d8c7a16c25dbfd /libmount/src/tab_parse.c | |
parent | tests: update tests with fdisk output (diff) | |
download | kernel-qcow2-util-linux-1e8c936978f5467a50732a072084337653820bba.tar.gz kernel-qcow2-util-linux-1e8c936978f5467a50732a072084337653820bba.tar.xz kernel-qcow2-util-linux-1e8c936978f5467a50732a072084337653820bba.zip |
libmount: make options in fstab optional
.. to be compatible with old mount(8).
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/tab_parse.c')
-rw-r--r-- | libmount/src/tab_parse.c | 23 |
1 files changed, 15 insertions, 8 deletions
diff --git a/libmount/src/tab_parse.c b/libmount/src/tab_parse.c index 4ee590889..6cd66afeb 100644 --- a/libmount/src/tab_parse.c +++ b/libmount/src/tab_parse.c @@ -52,8 +52,8 @@ static int next_number(char **s, int *num) */ static int mnt_parse_table_line(struct libmnt_fs *fs, char *s) { - int rc, n = 0; - char *src, *fstype, *optstr; + int rc, n = 0, xrc; + char *src = NULL, *fstype = NULL, *optstr = NULL; rc = sscanf(s, UL_SCNsA" " /* (1) source */ UL_SCNsA" " /* (2) target */ @@ -66,17 +66,20 @@ static int mnt_parse_table_line(struct libmnt_fs *fs, char *s) &fstype, &optstr, &n); + xrc = rc; - if (rc == 4) { + if (rc == 3 || rc == 4) { /* options are optional */ unmangle_string(src); unmangle_string(fs->target); unmangle_string(fstype); - unmangle_string(optstr); + + if (optstr && *optstr) + unmangle_string(optstr); rc = __mnt_fs_set_source_ptr(fs, src); if (!rc) rc = __mnt_fs_set_fstype_ptr(fs, fstype); - if (!rc) + if (!rc && optstr) rc = mnt_fs_set_options(fs, optstr); free(optstr); } else { @@ -84,12 +87,16 @@ static int mnt_parse_table_line(struct libmnt_fs *fs, char *s) rc = -EINVAL; } - if (rc) + if (rc) { + DBG(TAB, mnt_debug("tab parse error: [set vars, rc=%d]\n", rc)); return rc; /* error */ + } fs->passno = fs->freq = 0; - s = skip_spaces(s + n); - if (*s) { + + if (xrc == 4 && n) + s = skip_spaces(s + n); + if (xrc == 4 && *s) { if (next_number(&s, &fs->freq) != 0) { if (*s) { DBG(TAB, mnt_debug("tab parse error: [freq]")); |