static int loadkmod(void) { int result = -1; int pid, terminated_pid; union wait status; long major; char *load_prog_path; major = fuse_os_version_major_np(); if (major < OSXFUSE_MIN_DARWIN_VERSION) { /* This is not a supported version of Mac OS X */ return EINVAL; } load_prog_path = fuse_resource_path(OSXFUSE_LOAD_PROG); if (!load_prog_path) { fprintf(stderr, "fuse: load program missing\n"); goto Return; } #ifdef MACFUSE_MODE if (osxfuse_is_macfuse_mode_enabled()) { setenv(OSXFUSE_MACFUSE_MODE_ENV, "1", 1); } #endif pid = fork(); if (pid == 0) { result = execl(load_prog_path, load_prog_path, NULL); /* exec failed */ check_noerr_string(result, strerror(errno)); _exit(1); } free(load_prog_path); require_action(pid != -1, Return, result = errno); while ((terminated_pid = wait4(pid, (int *)&status, 0, NULL)) < 0) { /* retry if EINTR, else break out with error */ if (errno != EINTR) { break; } } if ((terminated_pid == pid) && (WIFEXITED(status))) { result = WEXITSTATUS(status); } else { result = -1; } Return: check_noerr_string(result, strerror(errno)); return result; }
static int load_kext(void) { int result = -1; int pid, terminated_pid; union wait status; long major; char *load_prog_path; major = fuse_os_version_major_np(); if (major < OSXFUSE_MIN_DARWIN_VERSION) { /* This is not a supported version of macOS */ return EINVAL; } load_prog_path = OSXFUSE_LOAD_PROG; if (!load_prog_path) { fprintf(stderr, "fuse: load program missing\n"); goto Return; } pid = fork(); if (pid == 0) { /* Drop saved set-user-ID */ setuid(getuid()); setgid(getgid()); result = execl(load_prog_path, load_prog_path, NULL); /* exec failed */ check_noerr_string(result, strerror(errno)); _exit(1); } require_action(pid != -1, Return, result = errno); while ((terminated_pid = wait4(pid, (int *)&status, 0, NULL)) < 0) { /* retry if EINTR, else break out with error */ if (errno != EINTR) { break; } } if ((terminated_pid == pid) && (WIFEXITED(status))) { result = WEXITSTATUS(status); } else { result = -1; } Return: check_noerr_string(result, strerror(errno)); return result; }
static int loadkmod(void) { int result = -1; int pid, terminated_pid; union wait status; long major; major = fuse_os_version_major_np(); if (major < 9) { /* not Mac OS X 10.5+ */ return EINVAL; } pid = fork(); if (pid == 0) { execl(MACFUSE_LOAD_PROG, MACFUSE_LOAD_PROG, NULL); /* exec failed */ exit(ENOENT); } require_action(pid != -1, Return, result = errno); while ((terminated_pid = wait4(pid, (int *)&status, 0, NULL)) < 0) { /* retry if EINTR, else break out with error */ if (errno != EINTR) { break; } } if ((terminated_pid == pid) && (WIFEXITED(status))) { result = WEXITSTATUS(status); } else { result = -1; } Return: check_noerr_string(result, strerror(errno)); return result; }