2015-08-06 17:24:38 +00:00
|
|
|
#include "abstractions.h"
|
|
|
|
|
2015-08-06 19:33:27 +00:00
|
|
|
#ifdef __APPLE__
|
|
|
|
|
2015-08-06 17:24:38 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
|
|
|
|
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
|
|
|
|
|
|
void thread_create (thread_t* thread, thread_fn fn, void* data) {
|
|
|
|
pthread_attr_t attr;
|
|
|
|
pthread_attr_init(&attr);
|
|
|
|
pthread_create(thread, &attr, fn, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
void thread_join (thread_t thread) {
|
|
|
|
pthread_join(thread, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void fusermount (char *path) {
|
|
|
|
char *argv[] = {(char *) "umount", path, NULL};
|
|
|
|
|
|
|
|
pid_t cpid = vfork();
|
|
|
|
if (cpid > 0) waitpid(cpid, NULL, 0);
|
|
|
|
else execvp(argv[0], argv);
|
|
|
|
}
|
|
|
|
|
2015-08-06 19:33:27 +00:00
|
|
|
#elif defined(_WIN32)
|
|
|
|
|
|
|
|
HANDLE mutex = CreateMutex(NULL, false, NULL);
|
|
|
|
|
|
|
|
void thread_create (HANDLE* thread, thread_fn fn, void* data) {
|
|
|
|
*thread = CreateThread(NULL, 0, fn, data, 0, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void thread_join (HANDLE thread) {
|
|
|
|
WaitForSingleObject(thread, INFINITE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void fusermount (char *path) {
|
|
|
|
// TODO
|
|
|
|
}
|
|
|
|
|
2015-08-06 17:24:38 +00:00
|
|
|
#else
|
|
|
|
|
2015-08-06 19:33:27 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <sys/wait.h>
|
|
|
|
|
2015-08-06 17:24:38 +00:00
|
|
|
pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
|
|
|
|
|
|
|
|
void thread_create (thread_t* thread, thread_fn fn, void* data) {
|
|
|
|
pthread_attr_t attr;
|
|
|
|
pthread_attr_init(&attr);
|
|
|
|
pthread_create(thread, &attr, fn, data);
|
|
|
|
}
|
|
|
|
|
|
|
|
void thread_join (thread_t thread) {
|
|
|
|
pthread_join(thread, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
void fusermount (char *path) {
|
|
|
|
char *argv[] = {(char *) "fusermount", (char *) "-q", (char *) "-u", path, NULL};
|
|
|
|
|
|
|
|
pid_t cpid = vfork();
|
|
|
|
if (cpid > 0) waitpid(cpid, NULL, 0);
|
|
|
|
else execvp(argv[0], argv);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|