Skip to content

Commit e7e3b25

Browse files
authored
Avoid hardcoded stat bits in nodejs code. NFC (#21904)
I noticed this while reviewing #21902.
1 parent 2fefc19 commit e7e3b25

5 files changed

+12
-3
lines changed

src/generated_struct_info32.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,10 @@
383383
"S_IFMT": 61440,
384384
"S_IFREG": 32768,
385385
"S_IFSOCK": 49152,
386+
"S_IRGRP": 32,
387+
"S_IROTH": 4,
386388
"S_IRUGO": 292,
389+
"S_IRUSR": 256,
387390
"S_IRWXO": 7,
388391
"S_IRWXUGO": 511,
389392
"S_ISVTX": 512,

src/generated_struct_info64.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,10 @@
383383
"S_IFMT": 61440,
384384
"S_IFREG": 32768,
385385
"S_IFSOCK": 49152,
386+
"S_IRGRP": 32,
387+
"S_IROTH": 4,
386388
"S_IRUGO": 292,
389+
"S_IRUSR": 256,
387390
"S_IRWXO": 7,
388391
"S_IRWXUGO": 511,
389392
"S_ISVTX": 512,

src/library_nodefs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ addToLibrary({
7171
if (NODEFS.isWindows) {
7272
// Node.js on Windows never represents permission bit 'x', so
7373
// propagate read bits to execute bits
74-
stat.mode = stat.mode | ((stat.mode & 292) >> 2);
74+
stat.mode |= (stat.mode & {{{ cDefs.S_IRUSR | cDefs.S_IRGRP | cDefs.S_IROTH }}}) >> 2;
7575
}
7676
} catch (e) {
7777
if (!e.code) throw e;

src/library_wasmfs_node.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ addToLibrary({
2121
if (wasmfsNodeIsWindows) {
2222
// Node.js on Windows never represents permission bit 'x', so
2323
// propagate read bits to execute bits
24-
stat.mode = stat.mode | ((stat.mode & 292) >> 2);
24+
stat.mode |= (stat.mode & {{{ cDefs.S_IRUSR | cDefs.S_IRGRP | cDefs.S_IROTH }}}) >> 2;
2525
}
2626
return stat;
2727
},

src/struct_info.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@
3030
"S_IFSOCK",
3131
"S_IFBLK",
3232
"S_IFLNK",
33-
"S_IFCHR"
33+
"S_IFCHR",
34+
"S_IRUSR",
35+
"S_IRGRP",
36+
"S_IROTH"
3437
],
3538
"structs": {
3639
"stat": [

0 commit comments

Comments
 (0)