diff options
| author | David Buckley <david@davidbuckley.ca> | 2021-01-02 22:58:54 -0500 | 
|---|---|---|
| committer | David Buckley <david@davidbuckley.ca> | 2021-01-02 22:58:54 -0500 | 
| commit | 598c67a7753e80f312da0557f1c7f2305d15ead3 (patch) | |
| tree | e6cf152c6929d16e8e3c1fe3bd3bf6716d6769b0 /fs | |
| parent | fef9289e3a7f82cda6319d5f19d5a5f13f3cc44b (diff) | |
use environment variable TABFS_MOUNT_DIR instead of hardcoded mnt
Diffstat (limited to 'fs')
| -rw-r--r-- | fs/tabfs.c | 16 | 
1 files changed, 13 insertions, 3 deletions
@@ -8,6 +8,7 @@  #include <string.h>  #include <unistd.h>  #include <stdlib.h> +#include <stdio.h>  #include <pthread.h>  #include <fuse.h> @@ -211,19 +212,28 @@ static struct fuse_operations tabfs_filesystem_operations = {  };  int main(int argc, char **argv) { +    char* mountdir = getenv("TABFS_MOUNT_DIR"); +    if (mountdir == NULL) { +        mountdir = malloc(sizeof(char)*4); +        sprintf(mountdir, "mnt"); +    } +      char killcmd[1000];      sprintf(killcmd, "pgrep tabfs | grep -v %d | xargs kill -9", getpid());      system(killcmd); + +    char unmountcmd[1000];  #ifdef __APPLE__ -    system("diskutil umount force mnt > /dev/null"); +    sprintf(unmountcmd, "diskutil umount force %s > /dev/null", mountdir);  #else -    system("fusermount -u mnt"); +    sprintf(unmountcmd, "fusermount -u %s", mountdir);  #endif +    system(unmountcmd);      l = fopen("log.txt", "w");      for (int i = 0; i < argc; i++) {          fprintf(l, "arg%d: [%s]\n", i, argv[i]); fflush(l);      } -    char* fuse_argv[] = {argv[0], "-odirect_io", "-s", "-f", "mnt"}; +    char* fuse_argv[] = {argv[0], "-odirect_io", "-s", "-f", mountdir};      return fuse_main(5, fuse_argv, &tabfs_filesystem_operations, NULL);  }  | 
