diff options
author | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-09-17 15:08:12 +0000 |
---|---|---|
committer | vda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2006-09-17 15:08:12 +0000 |
commit | d725a6a7f13325a830b540afe2a21bebf2b3b379 (patch) | |
tree | 815cc22724f2be2732300cffe06ca0151545d558 | |
parent | 230f617e5099cefb3f7ae60d49318abe459797fa (diff) | |
download | busybox-w32-d725a6a7f13325a830b540afe2a21bebf2b3b379.tar.gz busybox-w32-d725a6a7f13325a830b540afe2a21bebf2b3b379.tar.bz2 busybox-w32-d725a6a7f13325a830b540afe2a21bebf2b3b379.zip |
mount: fix "duplicate mount options in mtab" bug
git-svn-id: svn://busybox.net/trunk/busybox@16137 69ca8d6d-28ef-0310-b511-8ec308f3f277
-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 { | |||
102 | static void append_mount_options(char **oldopts, char *newopts) | 102 | static 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; | ||
122 | skip: | ||
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); |