akaros/tests/unmount.c
<<
>>
Prefs
   1#define _LARGEFILE64_SOURCE /* needed to use lseek64 */
   2
   3#include <stdio.h> 
   4#include <sys/types.h>
   5#include <sys/stat.h>
   6#include <fcntl.h>
   7#include <parlib/arch/arch.h>
   8#include <unistd.h>
   9#include <errno.h>
  10#include <dirent.h>
  11#include <stdlib.h>
  12#include <string.h>
  13#include <ros/syscall.h>
  14
  15/* The naming for the args in bind is messy historically.  We do:
  16 *              bind src_path onto_path
  17 * plan9 says bind NEW OLD, where new is *src*, and old is *onto*.
  18 * Linux says mount --bind OLD NEW, where OLD is *src* and NEW is *onto*.
  19 *
  20 * For unmount, we use the same names as for bind. */
  21int main(int argc, char *argv[]) 
  22{ 
  23        int ret;
  24        int flag = 0;
  25        char *src_path, *onto_path;
  26
  27        switch (argc) {
  28        case 3:
  29                src_path = argv[1];
  30                onto_path = argv[2];
  31                break;
  32        case 2:
  33                src_path = NULL;
  34                onto_path = argv[1];
  35                break;
  36        default:
  37                fprintf(stderr, "usage: unmount [src_path] onto_path\n");
  38                exit(1);
  39        }
  40        ret = syscall(SYS_nunmount, src_path, src_path ? strlen(src_path) : 0,
  41                      onto_path, strlen(onto_path));
  42        if (ret < 0)
  43                perror("Unmount failed");
  44        return ret;
  45}
  46