summaryrefslogtreecommitdiff
path: root/util-linux/mount.c
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2006-09-17 15:08:12 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2006-09-17 15:08:12 +0000
commitc889d2b786e8bd3e6e79ed4e03de5d04d3b4b196 (patch)
tree815cc22724f2be2732300cffe06ca0151545d558 /util-linux/mount.c
parentc0975199bea22a1f4f99f496ee32c3fac854bed5 (diff)
downloadbusybox-w32-c889d2b786e8bd3e6e79ed4e03de5d04d3b4b196.tar.gz
busybox-w32-c889d2b786e8bd3e6e79ed4e03de5d04d3b4b196.tar.bz2
busybox-w32-c889d2b786e8bd3e6e79ed4e03de5d04d3b4b196.zip
mount: fix "duplicate mount options in mtab" bug
Diffstat (limited to 'util-linux/mount.c')
-rw-r--r--util-linux/mount.c24
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 {
102static void append_mount_options(char **oldopts, char *newopts) 102static void append_mount_options(char **oldopts, char *newopts)
103{ 103{
104 if (*oldopts && **oldopts) { 104 if (*oldopts && **oldopts) {
105 char *temp = xasprintf("%s,%s",*oldopts,newopts); 105 /* do not insert options which are already there */
106 free(*oldopts); 106 while (newopts[0]) {
107 *oldopts = temp; 107 char *p;
108 int len = strlen(newopts);
109 p = strchr(newopts, ',');
110 if (p) len = p - newopts;
111 p = *oldopts;
112 while (1) {
113 if (!strncmp(p,newopts,len) && (p[len]==',' || p[len]==0))
114 goto skip;
115 p = strchr(p,',');
116 if(!p) break;
117 p++;
118 }
119 p = xasprintf("%s,%.*s", *oldopts, len, newopts);
120 free(*oldopts);
121 *oldopts = p;
122skip:
123 newopts += len;
124 while (newopts[0] == ',') newopts++;
125 }
108 } else { 126 } else {
109 if (ENABLE_FEATURE_CLEAN_UP) free(*oldopts); 127 if (ENABLE_FEATURE_CLEAN_UP) free(*oldopts);
110 *oldopts = xstrdup(newopts); 128 *oldopts = xstrdup(newopts);