diff --git a/README.md b/README.md index 6d2c10b..4fd5c2a 100644 --- a/README.md +++ b/README.md @@ -217,6 +217,10 @@ Called when ownership of a path is being changed Called when the mode of a path is being changed +#### `ops.mknod(path, mode, dev, cb)` + +Called when the a new device file is being made. + #### `ops.setxattr(path, name, buffer, length, offset, flags, cb)` Called when extended attributes is being set (see the extended docs for your platform). diff --git a/fuse-bindings.cc b/fuse-bindings.cc index 81b4357..a0c52bb 100644 --- a/fuse-bindings.cc +++ b/fuse-bindings.cc @@ -37,6 +37,7 @@ enum bindings_ops_t { OP_READLINK, OP_CHOWN, OP_CHMOD, + OP_MKNOD, OP_SETXATTR, OP_GETXATTR, OP_OPEN, @@ -96,6 +97,7 @@ struct bindings_t { NanCallback *ops_readlink; NanCallback *ops_chown; NanCallback *ops_chmod; + NanCallback *ops_mknod; NanCallback *ops_setxattr; NanCallback *ops_getxattr; NanCallback *ops_open; @@ -126,6 +128,7 @@ struct bindings_t { off_t length; void *data; // various structs int mode; + int dev; int uid; int gid; int result; @@ -222,6 +225,17 @@ static bindings_t *bindings_get_context () { return b; } +static int bindings_mknod (const char *path, mode_t mode, dev_t dev) { + bindings_t *b = bindings_get_context(); + + b->op = OP_MKNOD; + b->path = (char *) path; + b->mode = mode; + b->dev = dev; + + return bindings_call(b); +} + static int bindings_truncate (const char *path, off_t size) { bindings_t *b = bindings_get_context(); @@ -592,6 +606,7 @@ static void bindings_free (bindings_t *b) { if (b->ops_readlink != NULL) delete b->ops_readlink; if (b->ops_chown != NULL) delete b->ops_chown; if (b->ops_chmod != NULL) delete b->ops_chmod; + if (b->ops_mknod != NULL) delete b->ops_mknod; if (b->ops_setxattr != NULL) delete b->ops_setxattr; if (b->ops_getxattr != NULL) delete b->ops_getxattr; if (b->ops_statfs != NULL) delete b->ops_statfs; @@ -644,6 +659,7 @@ static void *bindings_thread (void *data) { if (b->ops_readlink != NULL) ops.readlink = bindings_readlink; if (b->ops_chown != NULL) ops.chown = bindings_chown; if (b->ops_chmod != NULL) ops.chmod = bindings_chmod; + if (b->ops_mknod != NULL) ops.mknod = bindings_mknod; if (b->ops_setxattr != NULL) ops.setxattr = bindings_setxattr; if (b->ops_getxattr != NULL) ops.getxattr = bindings_getxattr; if (b->ops_statfs != NULL) ops.statfs = bindings_statfs; @@ -809,6 +825,7 @@ NAN_METHOD(OpCallback) { case OP_FTRUNCATE: case OP_CHOWN: case OP_CHMOD: + case OP_MKNOD: case OP_SETXATTR: case OP_GETXATTR: case OP_READ: @@ -984,6 +1001,12 @@ static void bindings_dispatch (uv_async_t* handle, int status) { } return; + case OP_MKNOD: { + Local tmp[] = {NanNew(b->path), NanNew(b->mode), NanNew(b->dev), callback}; + bindings_call_op(b, b->ops_mknod, 4, tmp); + } + return; + case OP_CHOWN: { Local tmp[] = {NanNew(b->path), NanNew(b->uid), NanNew(b->gid), callback}; bindings_call_op(b, b->ops_chown, 4, tmp); @@ -1127,6 +1150,7 @@ NAN_METHOD(Mount) { b->ops_readlink = ops->Has(NanNew("readlink")) ? new NanCallback(ops->Get(NanNew("readlink")).As()) : NULL; b->ops_chown = ops->Has(NanNew("chown")) ? new NanCallback(ops->Get(NanNew("chown")).As()) : NULL; b->ops_chmod = ops->Has(NanNew("chmod")) ? new NanCallback(ops->Get(NanNew("chmod")).As()) : NULL; + b->ops_mknod = ops->Has(NanNew("mknod")) ? new NanCallback(ops->Get(NanNew("mknod")).As()) : NULL; b->ops_setxattr = ops->Has(NanNew("setxattr")) ? new NanCallback(ops->Get(NanNew("setxattr")).As()) : NULL; b->ops_getxattr = ops->Has(NanNew("getxattr")) ? new NanCallback(ops->Get(NanNew("getxattr")).As()) : NULL; b->ops_open = ops->Has(NanNew("open")) ? new NanCallback(ops->Get(NanNew("open")).As()) : NULL;