Merge remote-tracking branch 'huglovefan/master'

This commit is contained in:
David Buckley 2021-01-05 11:17:03 -05:00
commit b77bf24168

View file

@ -445,9 +445,8 @@ static const struct fuse_operations tabfs_oper = {
int main(int argc, char **argv) { int main(int argc, char **argv) {
(void)argc; (void)argc;
char* mountdir = getenv("TABFS_MOUNT_DIR"); if (NULL == getenv("TABFS_MOUNT_DIR")) {
if (mountdir == NULL) { setenv("TABFS_MOUNT_DIR", "mnt", 1);
mountdir = "mnt";
} }
freopen("log.txt", "a", stderr); 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()); sprintf(killcmd, "pgrep tabfs | grep -v %d | xargs kill -9 2>/dev/null", getpid());
system(killcmd); system(killcmd);
char unmountcmd[1000]; #if defined(__APPLE__)
#ifdef __APPLE__ system("diskutil umount force \"$TABFS_MOUNT_DIR\" >/dev/null");
sprintf(unmountcmd, "diskutil umount force %s >/dev/null", mountdir); #elif defined(__FreeBSD__)
#elif __FreeBSD__ system("umount -f \"$TABFS_MOUNT_DIR\" 2>/dev/null");
sprintf(unmountcmd, "umount -f %s 2>/dev/null", mountdir);
#else #else
sprintf(unmountcmd, "fusermount -u %s 2>/dev/null", mountdir); system("fusermount -u \"$TABFS_MOUNT_DIR\" 2>/dev/null");
#endif #endif
system(unmountcmd);
mkdir(mountdir, 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);
@ -485,7 +482,7 @@ int main(int argc, char **argv) {
"-oauto_unmount", "-oauto_unmount",
#endif #endif
"-odirect_io", "-odirect_io",
mountdir, getenv("TABFS_MOUNT_DIR"),
NULL, NULL,
}; };
return fuse_main( return fuse_main(