Skip to content

Commit d2d09db

Browse files
committed
Merge branch 'main' into open-broken-link-create
2 parents 6304e9c + 81b7179 commit d2d09db

File tree

67 files changed

+126
-67
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+126
-67
lines changed

ChangeLog.md

Lines changed: 1 addition & 0 deletions

src/library_syscall.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -695,9 +695,9 @@ var SyscallsLibrary = {
695695
var pos = 0;
696696
var off = FS.llseek(stream, 0, {{{ cDefs.SEEK_CUR }}});
697697
698-
var idx = Math.floor(off / struct_size);
699-
700-
while (idx < stream.getdents.length && pos + struct_size <= count) {
698+
var startIdx = Math.floor(off / struct_size);
699+
var endIdx = Math.min(stream.getdents.length, startIdx + Math.floor(count/struct_size))
700+
for (var idx = startIdx; idx < endIdx; idx++) {
701701
var id;
702702
var type;
703703
var name = stream.getdents[idx];
@@ -711,7 +711,17 @@ var SyscallsLibrary = {
711711
type = 4; // DT_DIR
712712
}
713713
else {
714-
var child = FS.lookupNode(stream.node, name);
714+
var child;
715+
try {
716+
child = FS.lookupNode(stream.node, name);
717+
} catch (e) {
718+
// If the entry is not a directory, file, or symlink, nodefs
719+
// lookupNode will raise EINVAL. Skip these and continue.
720+
if (e?.errno === {{{ cDefs.EINVAL }}}) {
721+
continue;
722+
}
723+
throw e;
724+
}
715725
id = child.id;
716726
type = FS.isChrdev(child.mode) ? 2 : // DT_CHR, character device.
717727
FS.isDir(child.mode) ? 4 : // DT_DIR, directory.
@@ -727,7 +737,6 @@ var SyscallsLibrary = {
727737
{{{ makeSetValue('dirp + pos', C_STRUCTS.dirent.d_type, 'type', 'i8') }}};
728738
stringToUTF8(name, dirp + pos + {{{ C_STRUCTS.dirent.d_name }}}, 256);
729739
pos += struct_size;
730-
idx += 1;
731740
}
732741
FS.llseek(stream, idx * struct_size, {{{ cDefs.SEEK_SET }}});
733742
return pos;

src/preamble.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ function getBinaryPromise(binaryFile) {
663663
#endif
664664

665665
// Otherwise, getBinarySync should be able to get it synchronously
666-
return Promise.resolve().then(() => getBinarySync(binaryFile));
666+
return Promise.resolve(getBinarySync(binaryFile));
667667
}
668668

669669
#if LOAD_SOURCE_MAP

test/fs/test_nodefs_readdir.out

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
listing contents of dir=/
2+
.
3+
..
4+
tmp
5+
home
6+
dev
7+
proc
8+
listing contents of dir=/working
9+
existing
10+
stdout
11+
test_nodefs_readdir.js
12+
test_nodefs_readdir.wasm
13+
success
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
listing contents of dir=/
2+
.
3+
..
4+
tmp
5+
home
6+
dev
7+
proc
8+
listing contents of dir=/working
9+
existing
10+
stdout
11+
test_nodefs_readdir.js
12+
success
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
listing contents of dir=/
2+
.
3+
..
4+
dev
5+
tmp
6+
listing contents of dir=/working
7+
.
8+
..
9+
existing
10+
named_pipe
11+
stdout
12+
test_nodefs_readdir.js
13+
test_nodefs_readdir.wasm
14+
success
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8432
1+
8430
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20676
1+
20665
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8416
1+
8413
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20644
1+
20633

0 commit comments

Comments
 (0)