Skip to content

Commit

Permalink
fixed some issues after codereview
Browse files Browse the repository at this point in the history
  • Loading branch information
elwerene committed Aug 9, 2013
1 parent e86efab commit 030e7e5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
18 changes: 0 additions & 18 deletions example/jsonFS.js
Expand Up @@ -389,24 +389,6 @@ function init(cb) {

//---------------------------------------------------------------------------

/*
* Handler for the destroy() FUSE hook. You can perform clean up tasks here.
* cb: a callback to call when you're done. It takes no arguments.
*/
function destroy(cb) {
if (options.outJson) {
try {
fs.writeFileSync(options.outJson, JSON.stringify(obj, null, ' '), 'utf8');
} catch (e) {
console.log("Exception when writing file: " + e);
}
}
console.log("File system stopped");
cb();
}

//---------------------------------------------------------------------------

/*
* Handler for the setxattr() FUSE hook.
* The arguments differ between different operating systems.
Expand Down
9 changes: 5 additions & 4 deletions fuse4js.cc
Expand Up @@ -387,11 +387,12 @@ void *fuse_thread(void *)
const char* debugOption = f4js.enableFuseDebug? "-d":"-f";
char *argv[] = { (char*)"dummy", (char*)"-s", (char*)debugOption, (char*)f4js.root.c_str() };

char **argvIncludingExtraArgs = (char**)malloc(sizeof(argv)+sizeof(char*)*f4js.extraArgc);
int initialArgc = sizeof(argv) / sizeof(char*);
char **argvIncludingExtraArgs = (char**)malloc(sizeof(char*) * (initialArgc + f4js.extraArgc));
memcpy(argvIncludingExtraArgs, argv, sizeof(argv));
memcpy(argvIncludingExtraArgs+sizeof(argv)/sizeof(char*), f4js.extraArgv, sizeof(char*)*f4js.extraArgc);
memcpy(argvIncludingExtraArgs + initialArgc, f4js.extraArgv, sizeof(char*) * f4js.extraArgc);

if (fuse_main((sizeof(argv)/sizeof(char*) + f4js.extraArgc), argvIncludingExtraArgs, &ops, NULL)) {
if (fuse_main((initialArgc + f4js.extraArgc), argvIncludingExtraArgs, &ops, NULL)) {
// Error occured
f4js_destroy(NULL);
}
Expand Down Expand Up @@ -813,6 +814,7 @@ Handle<Value> Start(const Arguments& args)
f4js.enableFuseDebug = debug->BooleanValue();
}

f4js.extraArgc = 0;
if (args.Length() >= 4) {
if (!args[3]->IsArray()) {
ThrowException(Exception::TypeError(String::New("Wrong argument types")));
Expand All @@ -821,7 +823,6 @@ Handle<Value> Start(const Arguments& args)

Handle<Array> mountArgs = Handle<Array>::Cast(args[3]);
f4js.extraArgv = (char**)malloc(mountArgs->Length() * sizeof(char*));
f4js.extraArgc = 0;

for (uint32_t i = 0; i < mountArgs->Length(); i++) {
Local<Value> arg = mountArgs->Get(i);
Expand Down

0 comments on commit 030e7e5

Please sign in to comment.