Simple mount command
authorBarret Rhoden <brho@cs.berkeley.edu>
Wed, 29 Jan 2014 03:11:49 +0000 (19:11 -0800)
committerBarret Rhoden <brho@cs.berkeley.edu>
Wed, 29 Jan 2014 03:11:49 +0000 (19:11 -0800)
Based off bind.  Doesn't do anything with auth or similar things.  Feel
free to replace this.  =)

kern/kfs/root
tests/mount.c [new file with mode: 0644]

index aed7739..231e6bd 100755 (executable)
@@ -35,5 +35,5 @@ else
        exit
 fi
 
-mount /srv/$SRVNAME /mnt
+mount -c /srv/$SRVNAME /mnt
 ls /mnt
diff --git a/tests/mount.c b/tests/mount.c
new file mode 100644 (file)
index 0000000..c0f5fd8
--- /dev/null
@@ -0,0 +1,45 @@
+#include <stdio.h> 
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <arch/arch.h>
+#include <unistd.h>
+#include <errno.h>
+#include <dirent.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ros/syscall.h>
+
+int main(int argc, char *argv[]) 
+{ 
+       int fd;
+       int flag = 0;
+       /* crap arg handling for now. */
+       argc--,argv++;
+       if (argc > 2){
+               switch(argv[0][1]){
+                       case 'b': flag = 1;
+                       break;
+                       case 'a': flag = 2;
+                       break;
+                       case 'c': flag = 4;
+                       break;
+                       default: 
+                               printf("-a or -b and/or -c for now\n");
+                               exit(-1);
+               }
+               argc--, argv++;
+       }
+
+       if (argc < 2) {
+               fprintf(stderr, "usage: mount [-a|-b|-c] channel onto_path\n");
+               exit(-1);
+       }
+       fd = open(argv[0], O_RDWR);
+       if (fd < 0) {
+               perror("Unable to open chan for mounting");
+               exit(-1);
+       }
+       syscall(SYS_nmount, fd, argv[1], strlen(argv[1]), flag);
+       return 0;
+}