From 598c67a7753e80f312da0557f1c7f2305d15ead3 Mon Sep 17 00:00:00 2001 From: David Buckley Date: Sat, 2 Jan 2021 22:58:54 -0500 Subject: use environment variable TABFS_MOUNT_DIR instead of hardcoded mnt --- fs/tabfs.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/fs/tabfs.c b/fs/tabfs.c index c5ed91e..f674216 100644 --- a/fs/tabfs.c +++ b/fs/tabfs.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -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); } -- cgit v1.2.3