svn commit: trunk/busybox/util-linux

vda at busybox.net vda at busybox.net
Sun Sep 17 15:08:13 UTC 2006


Author: vda
Date: 2006-09-17 08:08:12 -0700 (Sun, 17 Sep 2006)
New Revision: 16137

Log:
mount: fix "duplicate mount options in mtab" bug


Modified:
   trunk/busybox/util-linux/mount.c


Changeset:
Modified: trunk/busybox/util-linux/mount.c
===================================================================
--- trunk/busybox/util-linux/mount.c	2006-09-17 15:06:34 UTC (rev 16136)
+++ trunk/busybox/util-linux/mount.c	2006-09-17 15:08:12 UTC (rev 16137)
@@ -102,9 +102,27 @@
 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);




More information about the busybox-cvs mailing list