Merge pull request #38 from buckley-w-david/master

Use environment varaible to configure mount location
This commit is contained in:
Omar Rizwan 2021-01-05 09:41:14 -08:00 committed by GitHub
commit 6d65a48d4e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -445,6 +445,9 @@ static const struct fuse_operations tabfs_oper = {
int main(int argc, char **argv) { int main(int argc, char **argv) {
(void)argc; (void)argc;
if (NULL == getenv("TABFS_MOUNT_DIR")) {
setenv("TABFS_MOUNT_DIR", "mnt", 1);
}
freopen("log.txt", "a", stderr); freopen("log.txt", "a", stderr);
setvbuf(stderr, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0);
@ -454,14 +457,14 @@ int main(int argc, char **argv) {
system(killcmd); system(killcmd);
#if defined(__APPLE__) #if defined(__APPLE__)
system("diskutil umount force mnt >/dev/null"); system("diskutil umount force \"$TABFS_MOUNT_DIR\" >/dev/null");
#elif defined(__FreeBSD__) #elif defined(__FreeBSD__)
system("umount -f mnt 2>/dev/null"); system("umount -f \"$TABFS_MOUNT_DIR\" 2>/dev/null");
#else #else
system("fusermount -u mnt 2>/dev/null"); system("fusermount -u \"$TABFS_MOUNT_DIR\" 2>/dev/null");
#endif #endif
mkdir("mnt", 0755); system("mkdir -p \"$TABFS_MOUNT_DIR\"");
pthread_t thread; pthread_t thread;
int err = pthread_create(&thread, NULL, reader_main, NULL); int err = pthread_create(&thread, NULL, reader_main, NULL);
@ -469,6 +472,7 @@ int main(int argc, char **argv) {
eprintln("pthread_create: %s", strerror(err)); eprintln("pthread_create: %s", strerror(err));
exit(1); exit(1);
} }
pthread_detach(thread); pthread_detach(thread);
char *fuse_argv[] = { char *fuse_argv[] = {
@ -478,7 +482,7 @@ int main(int argc, char **argv) {
"-oauto_unmount", "-oauto_unmount",
#endif #endif
"-odirect_io", "-odirect_io",
"mnt", getenv("TABFS_MOUNT_DIR"),
NULL, NULL,
}; };
return fuse_main( return fuse_main(