Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #749, #620: implement lchown() #752

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 45 additions & 5 deletions src/filesystem/implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,52 @@ function find_node(context, path, callback) {
}

/**
* find_lnode
* find_symlink_node
*/
// in: file or directory path
// out: node structure, or error
function find_symbolic_node(context, path, callback) {
lstat_file(context, path, callback);
// out: symlink node structure, or error
function find_symlink_node(context, path, callback) {
path = normalize(path);
var name = basename(path);
var parentPath = dirname(path);

var directoryNode;
var directoryData;

if(ROOT_DIRECTORY_NAME === name) {
find_node(context, path, callback);
} else {
find_node(context, parentPath, read_directory_data);
humphd marked this conversation as resolved.
Show resolved Hide resolved
}

function read_directory_data(error, result) {
if(error) {
callback(error);
} else {
directoryNode = result;
context.getObject(directoryNode.data, check_if_file_exists);
}
}

function create_node(error, data) {
if(error) {
return callback(error);
}
Node.create(data, callback);
}

function check_if_file_exists(error, result) {
if(error) {
callback(error);
} else {
directoryData = result;
if(!directoryData.hasOwnProperty(name)) {
callback(new Errors.ENOENT('a component of the path does not name an existing file', path));
} else {
context.getObject(directoryData[name].id, create_node);
}
}
}
}

/**
Expand Down Expand Up @@ -2078,7 +2118,7 @@ function lchown_file(context, path, uid, gid, callback) {
update_node_times(context, path, node, { mtime: Date.now() }, callback);
}
}
find_symbolic_node(context, path, update_owner);
find_symlink_node(context, path, update_owner);
}

function getxattr(context, path, name, callback) {
Expand Down
1 change: 0 additions & 1 deletion src/filesystem/interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,6 @@ function FileSystem(options, callback) {
{ name: 'futimes' },
{ name: 'getxattr', promises: true, absPathArgs: [0] },
{ name: 'lchown' },
andrewkoung marked this conversation as resolved.
Show resolved Hide resolved
// lchmod - https://github.com/filerjs/filer/issues/619
{ name: 'link', promises: true, absPathArgs: [0, 1] },
{ name: 'lseek' },
{ name: 'lstat', promises: true },
Expand Down