Skip to content

Commit 54ae637

Browse files
committed
Remove second argument to ErrnoError. NFC
There was only one single place (out of hundreds) where this was set and one single place in `doStat` where it was read. I removed the `doStat` workaround by updating `mayLookup` instead.
1 parent 7e6366d commit 54ae637

16 files changed

+18
-26
lines changed

src/library_fs.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ FS.staticInit();` +
231231
lookupNode(parent, name) {
232232
var errCode = FS.mayLookup(parent);
233233
if (errCode) {
234-
throw new FS.ErrnoError(errCode, parent);
234+
throw new FS.ErrnoError(errCode);
235235
}
236236
var hash = FS.hashName(parent.id, name);
237237
#if CASE_INSENSITIVE_FS
@@ -316,6 +316,7 @@ FS.staticInit();` +
316316
return 0;
317317
},
318318
mayLookup(dir) {
319+
if (!FS.isDir(dir.mode)) return {{{ cDefs.ENOTDIR }}};
319320
var errCode = FS.nodePermissions(dir, 'x');
320321
if (errCode) return errCode;
321322
if (!dir.node_ops.lookup) return {{{ cDefs.EACCES }}};
@@ -1408,15 +1409,14 @@ FS.staticInit();` +
14081409
},
14091410
ensureErrnoError() {
14101411
if (FS.ErrnoError) return;
1411-
FS.ErrnoError = /** @this{Object} */ function ErrnoError(errno, node) {
1412+
FS.ErrnoError = /** @this{Object} */ function ErrnoError(errno) {
14121413
// We set the `name` property to be able to identify `FS.ErrnoError`
14131414
// - the `name` is a standard ECMA-262 property of error objects. Kind of good to have it anyway.
14141415
// - when using PROXYFS, an error can come from an underlying FS
14151416
// as different FS objects have their own FS.ErrnoError each,
14161417
// the test `err instanceof FS.ErrnoError` won't detect an error coming from another filesystem, causing bugs.
14171418
// we'll use the reliable test `err.name == "ErrnoError"` instead
14181419
this.name = 'ErrnoError';
1419-
this.node = node;
14201420
this.setErrno = /** @this{Object} */ function(errno) {
14211421
this.errno = errno;
14221422
#if ASSERTIONS

src/library_syscall.js

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,7 @@ var SyscallsLibrary = {
4242
},
4343

4444
doStat(func, path, buf) {
45-
try {
46-
var stat = func(path);
47-
} catch (e) {
48-
if (e && e.node && PATH.normalize(path) !== PATH.normalize(FS.getPath(e.node))) {
49-
// an error occurred while trying to look up the path; we should just report ENOTDIR
50-
return -{{{ cDefs.ENOTDIR }}};
51-
}
52-
throw e;
53-
}
45+
var stat = func(path);
5446
{{{ makeSetValue('buf', C_STRUCTS.stat.st_dev, 'stat.dev', 'i32') }}};
5547
{{{ makeSetValue('buf', C_STRUCTS.stat.st_mode, 'stat.mode', 'i32') }}};
5648
{{{ makeSetValue('buf', C_STRUCTS.stat.st_nlink, 'stat.nlink', SIZE_TYPE) }}};
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9936
1+
9932
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
24683
1+
24693
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9921
1+
9915
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
24651
1+
24661
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
11015
1+
11010
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
28573
1+
28583
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9903
1+
9899
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
24576
1+
24586
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
11021
1+
11016
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
28573
1+
28583
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
9936
1+
9932
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
24683
1+
24693
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7874
1+
7871
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
19705
1+
19715

0 commit comments

Comments
 (0)