diff --git a/src/filesystem/implementation.js b/src/filesystem/implementation.js index 60eed43..9c58fa1 100644 --- a/src/filesystem/implementation.js +++ b/src/filesystem/implementation.js @@ -356,17 +356,21 @@ function set_extended_attribute (context, path_or_fd, name, value, flag, callbac } /** - * make_root_directory + * ensure_root_directory. Creates a root node if necessary. + * + * Note: this should only be invoked when formatting a new file system. + * Multiple invocations of this by separate instances will still result + * in only a single super node. */ -// Note: this should only be invoked when formatting a new file system -function make_root_directory(context, callback) { +function ensure_root_directory(context, callback) { var superNode; var directoryNode; var directoryData; - function write_super_node(error, existingNode) { + function ensure_super_node(error, existingNode) { if(!error && existingNode) { - callback(new Errors.EEXIST()); + // Another instance has beat us and already created the super node. + callback(); } else if(error && !(error instanceof Errors.ENOENT)) { callback(error); } else { @@ -406,7 +410,7 @@ function make_root_directory(context, callback) { } } - context.get(SUPER_NODE_ID, write_super_node); + context.get(SUPER_NODE_ID, ensure_super_node); } /** @@ -2048,7 +2052,7 @@ function ftruncate(fs, context, fd, length, callback) { } module.exports = { - makeRootDirectory: make_root_directory, + ensureRootDirectory: ensure_root_directory, open: open, close: close, mknod: mknod, diff --git a/src/filesystem/interface.js b/src/filesystem/interface.js index 89fada2..38f31a8 100644 --- a/src/filesystem/interface.js +++ b/src/filesystem/interface.js @@ -244,7 +244,7 @@ function FileSystem(options, callback) { complete(err); return; } - impl.makeRootDirectory(context, complete); + impl.ensureRootDirectory(context, complete); }); }); }