-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Add a checkOpExists helper for common code pattern. NFC #23305
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
8c27f3e
Add a doNodeOp helper for common code pattern. NFC
hoodmane bb5d51d
Automatic rebaseline of codesize expectations. NFC
hoodmane 04ed75e
Add forgotten return
hoodmane aa818f7
use checkExists
hoodmane 9195a5f
Merge branch 'main' into do-node-op
hoodmane 870a18f
checkExists => checkOpExists
hoodmane 3b912a2
Fix reference errors
hoodmane f126175
Add back enoent check
hoodmane 57198a4
Merge branch 'main' into do-node-op
hoodmane 15ae885
Automatic rebaseline of codesize expectations. NFC
hoodmane File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -433,6 +433,12 @@ FS.staticInit(); | |
} | ||
return FS.nodePermissions(node, FS.flagsToPermissionString(flags)); | ||
}, | ||
checkOpExists(op, err) { | ||
if (!op) { | ||
throw new FS.ErrnoError(err); | ||
} | ||
return op; | ||
}, | ||
|
||
// | ||
// streams | ||
|
@@ -895,10 +901,8 @@ FS.staticInit(); | |
readdir(path) { | ||
var lookup = FS.lookupPath(path, { follow: true }); | ||
var node = lookup.node; | ||
if (!node.node_ops.readdir) { | ||
throw new FS.ErrnoError({{{ cDefs.ENOTDIR }}}); | ||
} | ||
return node.node_ops.readdir(node); | ||
var readdir = FS.checkOpExists(node.node_ops.readdir, {{{ cDefs.ENOTDIR }}}); | ||
return readdir(node); | ||
}, | ||
unlink(path) { | ||
var lookup = FS.lookupPath(path, { parent: true }); | ||
|
@@ -951,10 +955,8 @@ FS.staticInit(); | |
if (!node) { | ||
throw new FS.ErrnoError({{{ cDefs.ENOENT }}}); | ||
} | ||
if (!node.node_ops.getattr) { | ||
throw new FS.ErrnoError({{{ cDefs.EPERM }}}); | ||
} | ||
return node.node_ops.getattr(node); | ||
var getattr = FS.checkOpExists(node.node_ops.getattr, {{{ cDefs.EPERM }}}); | ||
return getattr(node); | ||
}, | ||
lstat(path) { | ||
return FS.stat(path, true); | ||
|
@@ -967,10 +969,8 @@ FS.staticInit(); | |
} else { | ||
node = path; | ||
} | ||
if (!node.node_ops.setattr) { | ||
throw new FS.ErrnoError({{{ cDefs.EPERM }}}); | ||
} | ||
node.node_ops.setattr(node, { | ||
var setattr = FS.checkOpExists(node.node_ops.setattr, {{{ cDefs.EPERM }}}); | ||
setattr(node, { | ||
mode: (mode & {{{ cDefs.S_IALLUGO }}}) | (node.mode & ~{{{ cDefs.S_IALLUGO }}}), | ||
ctime: Date.now(), | ||
dontFollow | ||
|
@@ -991,10 +991,8 @@ FS.staticInit(); | |
} else { | ||
node = path; | ||
} | ||
if (!node.node_ops.setattr) { | ||
throw new FS.ErrnoError({{{ cDefs.EPERM }}}); | ||
} | ||
node.node_ops.setattr(node, { | ||
var setattr = FS.checkOpExists(node.node_ops.setattr, {{{ cDefs.EPERM }}}); | ||
setattr(node, { | ||
timestamp: Date.now(), | ||
dontFollow | ||
// we ignore the uid / gid for now | ||
|
@@ -1018,9 +1016,6 @@ FS.staticInit(); | |
} else { | ||
node = path; | ||
} | ||
if (!node.node_ops.setattr) { | ||
throw new FS.ErrnoError({{{ cDefs.EPERM }}}); | ||
} | ||
if (FS.isDir(node.mode)) { | ||
throw new FS.ErrnoError({{{ cDefs.EISDIR }}}); | ||
} | ||
|
@@ -1031,7 +1026,8 @@ FS.staticInit(); | |
if (errCode) { | ||
throw new FS.ErrnoError(errCode); | ||
} | ||
node.node_ops.setattr(node, { | ||
var setattr = FS.checkOpExists(node.node_ops.setattr, {{{ cDefs.EPERM }}}); | ||
setattr(node, { | ||
size: len, | ||
timestamp: Date.now() | ||
}); | ||
|
@@ -1046,7 +1042,8 @@ FS.staticInit(); | |
utime(path, atime, mtime) { | ||
var lookup = FS.lookupPath(path, { follow: true }); | ||
var node = lookup.node; | ||
node.node_ops.setattr(node, { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously there was no error handling for |
||
var setattr = FS.checkOpExists(node.node_ops.setattr, {{{ cDefs.EPERM }}}); | ||
setattr(node, { | ||
atime: atime, | ||
mtime: mtime | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
8343 | ||
8350 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
20271 | ||
20272 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
8325 | ||
8334 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
20239 | ||
20240 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
9346 | ||
9349 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
24039 | ||
24040 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
8288 | ||
8296 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
20164 | ||
20165 |
2 changes: 1 addition & 1 deletion
2
test/other/codesize/test_codesize_cxx_except_wasm_exnref.gzsize
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
8288 | ||
8296 |
2 changes: 1 addition & 1 deletion
2
test/other/codesize/test_codesize_cxx_except_wasm_exnref.jssize
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
20164 | ||
20165 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
8357 | ||
8364 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
20347 | ||
20348 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
9351 | ||
9355 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
24039 | ||
24040 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
8343 | ||
8350 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
20271 | ||
20272 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
7650 | ||
7652 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
18817 | ||
18819 |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes which error we throw if there are multiple problems.