Skip to content

Commit

Permalink
Avoid hardcoded stat bits in nodejs code. NFC (emscripten-core#21904)
Browse files Browse the repository at this point in the history
I noticed this while reviewing emscripten-core#21902.
  • Loading branch information
sbc100 authored May 7, 2024
1 parent 2fefc19 commit e7e3b25
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/generated_struct_info32.json
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,10 @@
"S_IFMT": 61440,
"S_IFREG": 32768,
"S_IFSOCK": 49152,
"S_IRGRP": 32,
"S_IROTH": 4,
"S_IRUGO": 292,
"S_IRUSR": 256,
"S_IRWXO": 7,
"S_IRWXUGO": 511,
"S_ISVTX": 512,
Expand Down
3 changes: 3 additions & 0 deletions src/generated_struct_info64.json
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,10 @@
"S_IFMT": 61440,
"S_IFREG": 32768,
"S_IFSOCK": 49152,
"S_IRGRP": 32,
"S_IROTH": 4,
"S_IRUGO": 292,
"S_IRUSR": 256,
"S_IRWXO": 7,
"S_IRWXUGO": 511,
"S_ISVTX": 512,
Expand Down
2 changes: 1 addition & 1 deletion src/library_nodefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ addToLibrary({
if (NODEFS.isWindows) {
// Node.js on Windows never represents permission bit 'x', so
// propagate read bits to execute bits
stat.mode = stat.mode | ((stat.mode & 292) >> 2);
stat.mode |= (stat.mode & {{{ cDefs.S_IRUSR | cDefs.S_IRGRP | cDefs.S_IROTH }}}) >> 2;
}
} catch (e) {
if (!e.code) throw e;
Expand Down
2 changes: 1 addition & 1 deletion src/library_wasmfs_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ addToLibrary({
if (wasmfsNodeIsWindows) {
// Node.js on Windows never represents permission bit 'x', so
// propagate read bits to execute bits
stat.mode = stat.mode | ((stat.mode & 292) >> 2);
stat.mode |= (stat.mode & {{{ cDefs.S_IRUSR | cDefs.S_IRGRP | cDefs.S_IROTH }}}) >> 2;
}
return stat;
},
Expand Down
5 changes: 4 additions & 1 deletion src/struct_info.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@
"S_IFSOCK",
"S_IFBLK",
"S_IFLNK",
"S_IFCHR"
"S_IFCHR",
"S_IRUSR",
"S_IRGRP",
"S_IROTH"
],
"structs": {
"stat": [
Expand Down

0 comments on commit e7e3b25

Please sign in to comment.