Skip to content

Commit 2d1a04c

Browse files
committed
Take two make nodefs inode numbers match
Fix problem with directory permissions
1 parent 61762e6 commit 2d1a04c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

src/library_nodefs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ addToLibrary({
138138
}
139139
return {
140140
dev: stat.dev,
141-
ino: stat.ino,
141+
ino: node.id,
142142
mode: stat.mode,
143143
nlink: stat.nlink,
144144
uid: stat.uid,

test/fs/test_fs_readdir_ino_matches_stat_ino.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ void setup() {
3131
EM_ASM(FS.mount(NODEFS, { root: '.' }, 'working'));
3232
changedir("working");
3333
#endif
34+
mkdir("sub", 0775);
35+
changedir("sub");
3436
}
3537

3638
int main() {
@@ -45,6 +47,13 @@ int main() {
4547
dirp = fdopendir(dirfd);
4648
assert(dirp != NULL);
4749
struct dirent *ep;
50+
struct stat sta, stb;
51+
assert(lstat("a", &sta) == 0);
52+
assert(lstat("b", &stb) == 0);
53+
// Remove execute permission from directory. This prevents us from stat'ing
54+
// files in the directory in the implementation of readdir which we tried to
55+
// use to fix this.
56+
assert(chmod(".", 0675) == 0);
4857
int a_ino = -1;
4958
int b_ino = -1;
5059
while ((ep = readdir(dirp))) {
@@ -55,11 +64,10 @@ int main() {
5564
b_ino = ep->d_ino;
5665
}
5766
}
67+
assert(errno == 0);
5868
assert(a_ino >= 0);
5969
assert(b_ino >= 0);
60-
struct stat sta, stb;
61-
assert(lstat("a", &sta) == 0);
62-
assert(lstat("b", &stb) == 0);
70+
assert(chmod(".", 0775) == 0);
6371
printf("readdir a_ino: %d, b_ino: %d\n", a_ino, b_ino);
6472
printf("stat a_ino: %llu, b_ino: %llu\n", sta.st_ino, stb.st_ino);
6573
assert(a_ino == sta.st_ino);

0 commit comments

Comments
 (0)