diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-17 19:08:12 +0400 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2006-09-17 19:08:12 +0400 |
commit | c889d2b786e8bd3e6e79ed4e03de5d04d3b4b196 (patch) | |
tree | 815cc22724f2be2732300cffe06ca0151545d558 /util-linux | |
parent | c0975199bea22a1f4f99f496ee32c3fac854bed5 (diff) |
mount: fix "duplicate mount options in mtab" bug
Diffstat (limited to 'util-linux')
-rw-r--r-- | util-linux/mount.c | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/util-linux/mount.c b/util-linux/mount.c index 57d2d0430..430ec9bac 100644 --- a/util-linux/mount.c +++ b/util-linux/mount.c @@ -102,9 +102,27 @@ struct { static void append_mount_options(char **oldopts, char *newopts) { if (*oldopts && **oldopts) { - char *temp = xasprintf("%s,%s",*oldopts,newopts); - free(*oldopts); - *oldopts = temp; + /* do not insert options which are already there */ + while (newopts[0]) { + char *p; + int len = strlen(newopts); + p = strchr(newopts, ','); + if (p) len = p - newopts; + p = *oldopts; + while (1) { + if (!strncmp(p,newopts,len) && (p[len]==',' || p[len]==0)) + goto skip; + p = strchr(p,','); + if(!p) break; + p++; + } + p = xasprintf("%s,%.*s", *oldopts, len, newopts); + free(*oldopts); + *oldopts = p; +skip: + newopts += len; + while (newopts[0] == ',') newopts++; + } } else { if (ENABLE_FEATURE_CLEAN_UP) free(*oldopts); *oldopts = xstrdup(newopts); |