aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/tabfs.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/fs/tabfs.c b/fs/tabfs.c
index aeb55f3..725358c 100644
--- a/fs/tabfs.c
+++ b/fs/tabfs.c
@@ -445,6 +445,10 @@ static const struct fuse_operations tabfs_oper = {
int main(int argc, char **argv) {
(void)argc;
+ char* mountdir = getenv("TABFS_MOUNT_DIR");
+ if (mountdir == NULL) {
+ mountdir = "mnt";
+ }
freopen("log.txt", "a", stderr);
setvbuf(stderr, NULL, _IONBF, 0);
@@ -453,15 +457,17 @@ int main(int argc, char **argv) {
sprintf(killcmd, "pgrep tabfs | grep -v %d | xargs kill -9 2>/dev/null", getpid());
system(killcmd);
-#if defined(__APPLE__)
- system("diskutil umount force mnt >/dev/null");
-#elif defined(__FreeBSD__)
- system("umount -f mnt 2>/dev/null");
+ char unmountcmd[1000];
+#ifdef __APPLE__
+ sprintf(unmountcmd, "diskutil umount force %s >/dev/null", mountdir);
+#elif __FreeBSD__
+ sprintf(unmountcmd, "umount -f %s 2>/dev/null", mountdir);
#else
- system("fusermount -u mnt 2>/dev/null");
+ sprintf(unmountcmd, "fusermount -u %s 2>/dev/null", mountdir);
#endif
+ system(unmountcmd);
- mkdir("mnt", 0755);
+ mkdir(mountdir, 0755);
pthread_t thread;
int err = pthread_create(&thread, NULL, reader_main, NULL);
@@ -469,6 +475,7 @@ int main(int argc, char **argv) {
eprintln("pthread_create: %s", strerror(err));
exit(1);
}
+
pthread_detach(thread);
char *fuse_argv[] = {
@@ -478,7 +485,7 @@ int main(int argc, char **argv) {
"-oauto_unmount",
#endif
"-odirect_io",
- "mnt",
+ mountdir,
NULL,
};
return fuse_main(