|
|
@ -4,13 +4,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include <fuse.h>
|
|
|
|
#include <fuse.h>
|
|
|
|
#include <fuse_opt.h>
|
|
|
|
#include <fuse_opt.h>
|
|
|
|
#include <fuse_lowlevel.h>
|
|
|
|
// #include <fuse_lowlevel.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <sys/mount.h>
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "abstractions.h"
|
|
|
|
#include "abstractions.h"
|
|
|
@ -116,8 +115,8 @@ struct bindings_t {
|
|
|
|
struct fuse_file_info *info;
|
|
|
|
struct fuse_file_info *info;
|
|
|
|
char *path;
|
|
|
|
char *path;
|
|
|
|
char *name;
|
|
|
|
char *name;
|
|
|
|
off_t offset;
|
|
|
|
FUSE_OFF_T offset;
|
|
|
|
off_t length;
|
|
|
|
FUSE_OFF_T length;
|
|
|
|
void *data; // various structs
|
|
|
|
void *data; // various structs
|
|
|
|
int mode;
|
|
|
|
int mode;
|
|
|
|
int dev;
|
|
|
|
int dev;
|
|
|
@ -194,7 +193,7 @@ static int bindings_mknod (const char *path, mode_t mode, dev_t dev) {
|
|
|
|
return bindings_call(b);
|
|
|
|
return bindings_call(b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int bindings_truncate (const char *path, off_t size) {
|
|
|
|
static int bindings_truncate (const char *path, FUSE_OFF_T size) {
|
|
|
|
bindings_t *b = bindings_get_context();
|
|
|
|
bindings_t *b = bindings_get_context();
|
|
|
|
|
|
|
|
|
|
|
|
b->op = OP_TRUNCATE;
|
|
|
|
b->op = OP_TRUNCATE;
|
|
|
@ -204,7 +203,7 @@ static int bindings_truncate (const char *path, off_t size) {
|
|
|
|
return bindings_call(b);
|
|
|
|
return bindings_call(b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int bindings_ftruncate (const char *path, off_t size, struct fuse_file_info *info) {
|
|
|
|
static int bindings_ftruncate (const char *path, FUSE_OFF_T size, struct fuse_file_info *info) {
|
|
|
|
bindings_t *b = bindings_get_context();
|
|
|
|
bindings_t *b = bindings_get_context();
|
|
|
|
|
|
|
|
|
|
|
|
b->op = OP_FTRUNCATE;
|
|
|
|
b->op = OP_FTRUNCATE;
|
|
|
@ -268,7 +267,7 @@ static int bindings_fsyncdir (const char *path, int datasync, struct fuse_file_i
|
|
|
|
return bindings_call(b);
|
|
|
|
return bindings_call(b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int bindings_readdir (const char *path, void *buf, fuse_fill_dir_t filler, off_t offset, struct fuse_file_info *info) {
|
|
|
|
static int bindings_readdir (const char *path, void *buf, fuse_fill_dir_t filler, FUSE_OFF_T offset, struct fuse_file_info *info) {
|
|
|
|
bindings_t *b = bindings_get_context();
|
|
|
|
bindings_t *b = bindings_get_context();
|
|
|
|
|
|
|
|
|
|
|
|
b->op = OP_READDIR;
|
|
|
|
b->op = OP_READDIR;
|
|
|
@ -399,7 +398,7 @@ static int bindings_opendir (const char *path, struct fuse_file_info *info) {
|
|
|
|
return bindings_call(b);
|
|
|
|
return bindings_call(b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int bindings_read (const char *path, char *buf, size_t len, off_t offset, struct fuse_file_info *info) {
|
|
|
|
static int bindings_read (const char *path, char *buf, size_t len, FUSE_OFF_T offset, struct fuse_file_info *info) {
|
|
|
|
bindings_t *b = bindings_get_context();
|
|
|
|
bindings_t *b = bindings_get_context();
|
|
|
|
|
|
|
|
|
|
|
|
b->op = OP_READ;
|
|
|
|
b->op = OP_READ;
|
|
|
@ -412,7 +411,7 @@ static int bindings_read (const char *path, char *buf, size_t len, off_t offset,
|
|
|
|
return bindings_call(b);
|
|
|
|
return bindings_call(b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int bindings_write (const char *path, const char *buf, size_t len, off_t offset, struct fuse_file_info * info) {
|
|
|
|
static int bindings_write (const char *path, const char *buf, size_t len, FUSE_OFF_T offset, struct fuse_file_info * info) {
|
|
|
|
bindings_t *b = bindings_get_context();
|
|
|
|
bindings_t *b = bindings_get_context();
|
|
|
|
|
|
|
|
|
|
|
|
b->op = OP_WRITE;
|
|
|
|
b->op = OP_WRITE;
|
|
|
@ -600,7 +599,7 @@ static void bindings_on_close (uv_handle_t *handle) {
|
|
|
|
mutex_unlock(&mutex);
|
|
|
|
mutex_unlock(&mutex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void *bindings_thread (void *data) {
|
|
|
|
static thread_fn_rtn_t bindings_thread (void *data) {
|
|
|
|
bindings_t *b = (bindings_t *) data;
|
|
|
|
bindings_t *b = (bindings_t *) data;
|
|
|
|
|
|
|
|
|
|
|
|
struct fuse_operations ops = { };
|
|
|
|
struct fuse_operations ops = { };
|
|
|
@ -671,7 +670,7 @@ static void *bindings_thread (void *data) {
|
|
|
|
|
|
|
|
|
|
|
|
uv_close((uv_handle_t*) &(b->async), &bindings_on_close);
|
|
|
|
uv_close((uv_handle_t*) &(b->async), &bindings_on_close);
|
|
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NAN_INLINE static Local<Date> bindings_get_date (struct timespec *out) {
|
|
|
|
NAN_INLINE static Local<Date> bindings_get_date (struct timespec *out) {
|
|
|
@ -697,6 +696,7 @@ NAN_INLINE static void bindings_set_stat (struct stat *stat, Local<Object> obj)
|
|
|
|
if (obj->Has(NanNew<String>("gid"))) stat->st_gid = obj->Get(NanNew<String>("gid"))->NumberValue();
|
|
|
|
if (obj->Has(NanNew<String>("gid"))) stat->st_gid = obj->Get(NanNew<String>("gid"))->NumberValue();
|
|
|
|
if (obj->Has(NanNew<String>("rdev"))) stat->st_rdev = obj->Get(NanNew<String>("rdev"))->NumberValue();
|
|
|
|
if (obj->Has(NanNew<String>("rdev"))) stat->st_rdev = obj->Get(NanNew<String>("rdev"))->NumberValue();
|
|
|
|
if (obj->Has(NanNew<String>("size"))) stat->st_size = obj->Get(NanNew<String>("size"))->NumberValue();
|
|
|
|
if (obj->Has(NanNew<String>("size"))) stat->st_size = obj->Get(NanNew<String>("size"))->NumberValue();
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
if (obj->Has(NanNew<String>("blksize"))) stat->st_blksize = obj->Get(NanNew<String>("blksize"))->NumberValue();
|
|
|
|
if (obj->Has(NanNew<String>("blksize"))) stat->st_blksize = obj->Get(NanNew<String>("blksize"))->NumberValue();
|
|
|
|
if (obj->Has(NanNew<String>("blocks"))) stat->st_blocks = obj->Get(NanNew<String>("blocks"))->NumberValue();
|
|
|
|
if (obj->Has(NanNew<String>("blocks"))) stat->st_blocks = obj->Get(NanNew<String>("blocks"))->NumberValue();
|
|
|
|
#ifdef __APPLE__
|
|
|
|
#ifdef __APPLE__
|
|
|
@ -708,6 +708,7 @@ NAN_INLINE static void bindings_set_stat (struct stat *stat, Local<Object> obj)
|
|
|
|
if (obj->Has(NanNew<String>("ctime"))) bindings_set_date(&stat->st_ctim, obj->Get(NanNew("ctime")).As<Date>());
|
|
|
|
if (obj->Has(NanNew<String>("ctime"))) bindings_set_date(&stat->st_ctim, obj->Get(NanNew("ctime")).As<Date>());
|
|
|
|
if (obj->Has(NanNew<String>("atime"))) bindings_set_date(&stat->st_atim, obj->Get(NanNew("atime")).As<Date>());
|
|
|
|
if (obj->Has(NanNew<String>("atime"))) bindings_set_date(&stat->st_atim, obj->Get(NanNew("atime")).As<Date>());
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
NAN_INLINE static void bindings_set_statfs (struct statvfs *statfs, Local<Object> obj) { // from http://linux.die.net/man/2/stat
|
|
|
|
NAN_INLINE static void bindings_set_statfs (struct statvfs *statfs, Local<Object> obj) { // from http://linux.die.net/man/2/stat
|
|
|
@ -768,7 +769,7 @@ NAN_METHOD(OpCallback) {
|
|
|
|
case OP_READLINK: {
|
|
|
|
case OP_READLINK: {
|
|
|
|
if (args.Length() > 2 && args[2]->IsString()) {
|
|
|
|
if (args.Length() > 2 && args[2]->IsString()) {
|
|
|
|
NanUtf8String path(args[2]);
|
|
|
|
NanUtf8String path(args[2]);
|
|
|
|
stpcpy((char *) b->data, *path);
|
|
|
|
strcpy((char *) b->data, *path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -1130,8 +1131,8 @@ NAN_METHOD(Mount) {
|
|
|
|
Local<Value> tmp[] = {NanNew<Number>(index), NanNew<FunctionTemplate>(OpCallback)->GetFunction()};
|
|
|
|
Local<Value> tmp[] = {NanNew<Number>(index), NanNew<FunctionTemplate>(OpCallback)->GetFunction()};
|
|
|
|
b->callback = new NanCallback(callback_constructor->Call(2, tmp).As<Function>());
|
|
|
|
b->callback = new NanCallback(callback_constructor->Call(2, tmp).As<Function>());
|
|
|
|
|
|
|
|
|
|
|
|
stpcpy(b->mnt, *path);
|
|
|
|
strcpy(b->mnt, *path);
|
|
|
|
stpcpy(b->mntopts, "-o");
|
|
|
|
strcpy(b->mntopts, "-o");
|
|
|
|
|
|
|
|
|
|
|
|
Local<Array> options = ops->Get(NanNew<String>("options")).As<Array>();
|
|
|
|
Local<Array> options = ops->Get(NanNew<String>("options")).As<Array>();
|
|
|
|
if (options->IsArray()) {
|
|
|
|
if (options->IsArray()) {
|
|
|
@ -1203,7 +1204,7 @@ NAN_METHOD(Unmount) {
|
|
|
|
Local<Function> callback = args[1].As<Function>();
|
|
|
|
Local<Function> callback = args[1].As<Function>();
|
|
|
|
|
|
|
|
|
|
|
|
char *path_alloc = (char *) malloc(1024);
|
|
|
|
char *path_alloc = (char *) malloc(1024);
|
|
|
|
stpcpy(path_alloc, *path);
|
|
|
|
strcpy(path_alloc, *path);
|
|
|
|
|
|
|
|
|
|
|
|
NanAsyncQueueWorker(new UnmountWorker(new NanCallback(callback), path_alloc));
|
|
|
|
NanAsyncQueueWorker(new UnmountWorker(new NanCallback(callback), path_alloc));
|
|
|
|
NanReturnUndefined();
|
|
|
|
NanReturnUndefined();
|
|
|
|