[BusyBox] mount -a, using sysfs()

Glenn McGrath bug1 at optushome.com.au
Thu Mar 1 12:22:29 UTC 2001


Erik Andersen wrote:

> Wanna try something for me?  Wanna check if the following
> completely untested change 1) makes things smaller, and
> 2) actually works.
> 
> The patch would go something like
> 
> static const char *strings[] = { "tmpfs", "shm", "proc", "ramfs", "devpts", 0 };
> const char** nodevfss;
> 
> ...
> 
> while(i < num_of_filesystems) {
>     sysfs(2, i++, filesystemType);
>     for (nodevfss = strings; *nodevfss; nodevfss++) {
>         if (!strcmp(filesystemType, *nodevfss))
>             return (FALSE);
>     }
>     status = do_mount(blockDevice, directory, filesystemType,
> ...
> 

Yea, thats better, cant return where you do though, it can only exit the
while loop. It adds 128 Bytes.


Glenn
-------------- next part --------------
diff -U 3 ./busybox.orig/mount.c ./busybox/mount.c
--- ./busybox.orig/mount.c	Thu Mar  1 18:55:49 2001
+++ ./busybox/mount.c	Thu Mar  1 23:13:47 2001
@@ -239,18 +239,30 @@
 	int status = 0;
 
 	if (strcmp(filesystemType, "auto") == 0) {
-		int i=0;
+		static const char *strings[] = { "tmpfs", "shm", "proc", "ramfs", "devpts", 0 };
+		const char** nodevfss;
 		const int num_of_filesystems = sysfs(3, 0, 0);
 		char buf[255];
+		int i=0;
+
 		filesystemType=buf;
 
 		while(i < num_of_filesystems) {
+			int try_mount = TRUE;
 			sysfs(2, i++, filesystemType);
-			status = do_mount(blockDevice, directory, filesystemType,
+			for (nodevfss = strings; *nodevfss; nodevfss++) {
+				if (!strcmp(filesystemType, *nodevfss)) {
+					try_mount = FALSE;
+					break;
+				}
+			}
+			if (try_mount) {
+				status = do_mount(blockDevice, directory, filesystemType,
 					flags | MS_MGC_VAL, string_flags,
 					useMtab, fakeIt, mtab_opts);
-			if (status == TRUE)
-				break;
+				if (status == TRUE)
+					break;
+			}
 		}
 	} else {
 		status = do_mount(blockDevice, directory, filesystemType,


More information about the busybox mailing list