aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/tabfs.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/fs/tabfs.c b/fs/tabfs.c
index fecec22..90895f2 100644
--- a/fs/tabfs.c
+++ b/fs/tabfs.c
@@ -8,6 +8,7 @@
#include <string.h>
#include <unistd.h>
#include <stdlib.h>
+#include <stdio.h>
#include <pthread.h>
#include <fuse.h>
@@ -211,21 +212,30 @@ 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);
#elif __FreeBSD__
- system("umount -f mnt");
+ sprintf(unmountcmd, "umount -f %s", 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);
}