diff options
author | David Buckley <david@davidbuckley.ca> | 2021-01-05 11:17:03 -0500 |
---|---|---|
committer | David Buckley <david@davidbuckley.ca> | 2021-01-05 11:17:03 -0500 |
commit | b77bf24168168456969feb4acc7b70d2f1ee8cd0 (patch) | |
tree | 1a7823d3e9d9b0e72dc6c68bd6d4ca18cb23ca1a /fs/tabfs.c | |
parent | daa3785d7cf3fe67c9ef518a3e4feeb51c888351 (diff) | |
parent | 509a0e1ce9e5106790c9588f1b95db1deea7761d (diff) |
Merge remote-tracking branch 'huglovefan/master'
Diffstat (limited to 'fs/tabfs.c')
-rw-r--r-- | fs/tabfs.c | 21 |
1 files changed, 9 insertions, 12 deletions
@@ -445,9 +445,8 @@ 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"; + if (NULL == getenv("TABFS_MOUNT_DIR")) { + setenv("TABFS_MOUNT_DIR", "mnt", 1); } freopen("log.txt", "a", stderr); @@ -457,17 +456,15 @@ int main(int argc, char **argv) { sprintf(killcmd, "pgrep tabfs | grep -v %d | xargs kill -9 2>/dev/null", getpid()); system(killcmd); - 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); +#if defined(__APPLE__) + system("diskutil umount force \"$TABFS_MOUNT_DIR\" >/dev/null"); +#elif defined(__FreeBSD__) + system("umount -f \"$TABFS_MOUNT_DIR\" 2>/dev/null"); #else - sprintf(unmountcmd, "fusermount -u %s 2>/dev/null", mountdir); + system("fusermount -u \"$TABFS_MOUNT_DIR\" 2>/dev/null"); #endif - system(unmountcmd); - mkdir(mountdir, 0755); + system("mkdir -p \"$TABFS_MOUNT_DIR\""); pthread_t thread; int err = pthread_create(&thread, NULL, reader_main, NULL); @@ -485,7 +482,7 @@ int main(int argc, char **argv) { "-oauto_unmount", #endif "-odirect_io", - mountdir, + getenv("TABFS_MOUNT_DIR"), NULL, }; return fuse_main( |