diff options
author | Anthony Pesch <inolen@gmail.com> | 2013-07-15 20:25:21 -0700 |
---|---|---|
committer | Anthony Pesch <inolen@gmail.com> | 2013-07-15 21:22:11 -0700 |
commit | 13b8be215de6213eabb23bd68c34622f00452954 (patch) | |
tree | dfc218a0936d28c88d2da102ff579189db969ca5 /src/library.js | |
parent | 9bf755607fc7a0e7f446a5e2d6c82738d77d876f (diff) |
- rmdir / unlink no longer follow the final symlink
- rmdir / unlink no longer check write permission on the found object, but on its parent
- rmdir should return EBUSY when path matches the root / cwd
- unlinking a directory should return EPERM according to POSIX (EISDIR is a Linux convention)
Diffstat (limited to 'src/library.js')
-rw-r--r-- | src/library.js | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/src/library.js b/src/library.js index c5618b53..b6e8b908 100644 --- a/src/library.js +++ b/src/library.js @@ -1867,42 +1867,42 @@ LibraryManager.library = { rmdir: function(path) { // int rmdir(const char *path); // http://pubs.opengroup.org/onlinepubs/000095399/functions/rmdir.html - path = FS.analyzePath(Pointer_stringify(path)); + path = Pointer_stringify(path); + path = FS.analyzePath(path, true); if (!path.parentExists || !path.exists) { ___setErrNo(path.error); return -1; - } else if (!path.object.write || path.isRoot) { + } else if (!path.parentObject.write) { ___setErrNo(ERRNO_CODES.EACCES); return -1; } else if (!path.object.isFolder) { ___setErrNo(ERRNO_CODES.ENOTDIR); return -1; + } else if (path.isRoot || path.path == FS.currentPath) { + ___setErrNo(ERRNO_CODES.EBUSY); + return -1; } else { for (var i in path.object.contents) { ___setErrNo(ERRNO_CODES.ENOTEMPTY); return -1; } - if (path.path == FS.currentPath) { - ___setErrNo(ERRNO_CODES.EBUSY); - return -1; - } else { - delete path.parentObject.contents[path.name]; - return 0; - } + delete path.parentObject.contents[path.name]; + return 0; } }, unlink__deps: ['$FS', '__setErrNo', '$ERRNO_CODES'], unlink: function(path) { // int unlink(const char *path); // http://pubs.opengroup.org/onlinepubs/000095399/functions/unlink.html - path = FS.analyzePath(Pointer_stringify(path)); + path = Pointer_stringify(path); + path = FS.analyzePath(path, true); if (!path.parentExists || !path.exists) { ___setErrNo(path.error); return -1; } else if (path.object.isFolder) { - ___setErrNo(ERRNO_CODES.EISDIR); + ___setErrNo(ERRNO_CODES.EPERM); return -1; - } else if (!path.object.write) { + } else if (!path.parentObject.write) { ___setErrNo(ERRNO_CODES.EACCES); return -1; } else { |