akaros/tests/mount.c
<<
>>
Prefs
   1#include <stdio.h>
   2#include <sys/types.h>
   3#include <sys/stat.h>
   4#include <fcntl.h>
   5#include <parlib/arch/arch.h>
   6#include <unistd.h>
   7#include <errno.h>
   8#include <dirent.h>
   9#include <stdlib.h>
  10#include <string.h>
  11#include <ros/syscall.h>
  12
  13int main(int argc, char *argv[])
  14{
  15        int fd;
  16        int flag = 0;
  17        int ret;
  18
  19        /* crap arg handling for now. */
  20        argc--, argv++;
  21        while (argc > 2) {
  22                switch(argv[0][1]){
  23                case 'b':
  24                        flag |= 1;
  25                        break;
  26                case 'a':
  27                        flag |= 2;
  28                        break;
  29                case 'c':
  30                        flag |= 4;
  31                        break;
  32                case 'C':
  33                        flag |= 0x10;
  34                        break;
  35                default:
  36                        printf("-a or -b and/or -c and/or -C for now\n");
  37                        exit(-1);
  38                }
  39                argc--, argv++;
  40        }
  41
  42        if (argc < 2) {
  43                fprintf(stderr,
  44                        "usage: mount [-a|-b|-c|-C] channel onto_path\n");
  45                exit(-1);
  46        }
  47        fd = open(argv[0], O_RDWR);
  48        if (fd < 0) {
  49                perror("Unable to open chan for mounting");
  50                exit(-1);
  51        }
  52        ret = syscall(SYS_nmount, fd, argv[1], strlen(argv[1]), flag);
  53        if (ret < 0) {
  54                perror("sys_mount:");
  55                return -1;
  56        }
  57        return 0;
  58}
  59