shithub: riscv

Download patch

ref: 28859a83f41b4c5231865cc556665f2060c70010
parent: 2f3b4175f6cf06703d2c85f3524f2c7e99874ca7
author: aiju <[email protected]>
date: Sun May 8 19:00:11 EDT 2011

extended ramfs (-abc)

--- a/sys/src/cmd/ramfs.c
+++ b/sys/src/cmd/ramfs.c
@@ -157,9 +157,11 @@
 	int p[2];
 	int fd;
 	int stdio = 0;
+	int mountflags;
 
 	service = "ramfs";
 	defmnt = "/tmp";
+	mountflags = 0;
 	ARGBEGIN{
 	case 'i':
 		defmnt = 0;
@@ -186,9 +188,20 @@
 		defmnt = 0;
 		service = EARGF(usage());
 		break;
+	case 'b':
+		mountflags |= MBEFORE;
+		break;
+	case 'c':
+		mountflags |= MCREATE;
+		break;
+	case 'a':
+		mountflags |= MAFTER;
+		break;
 	default:
 		usage();
 	}ARGEND
+	if(mountflags == 0)
+		mountflags = MREPL | MCREATE;
 
 	if(pipe(p) < 0)
 		error("pipe failed");
@@ -239,7 +252,7 @@
 		break;
 	default:
 		close(p[0]);	/* don't deadlock if child fails */
-		if(defmnt && mount(p[1], -1, defmnt, MREPL|MCREATE, "") < 0)
+		if(defmnt && mount(p[1], -1, defmnt, mountflags, "") < 0)
 			error("mount failed");
 	}
 	exits(0);
@@ -902,6 +915,6 @@
 void
 usage(void)
 {
-	fprint(2, "usage: %s [-Dipsu] [-m mountpoint] [-S srvname]\n", argv0);
+	fprint(2, "usage: %s [-Dipsubac] [-m mountpoint] [-S srvname]\n", argv0);
 	exits("usage");
 }