Skip to content

Commit b5fc476

Browse files
committed
Merge branch 'main' into lookup-path-nonrecursive
2 parents 4d87d91 + 06cebfc commit b5fc476

40 files changed

+192
-103
lines changed

ChangeLog.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@ to browse the changes between the tags.
1818

1919
See docs/process.md for more on how version tagging works.
2020

21-
3.1.73 (in development)
21+
3.1.74 (in development)
2222
-----------------------
23+
24+
3.1.73 - 11/28/24
25+
-----------------
2326
- libunwind was updated to LLVM 19.1.4. (#22394)
2427

2528
3.1.72 - 11/19/24

emscripten-version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.1.73-git
1+
3.1.74-git

src/library_fs.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,29 @@ FS.staticInit();
652652
}
653653
return parent.node_ops.mknod(parent, name, mode, dev);
654654
},
655+
statfs(path) {
656+
657+
// NOTE: None of the defaults here are true. We're just returning safe and
658+
// sane values.
659+
var rtn = {
660+
bsize: 4096,
661+
frsize: 4096,
662+
blocks: 1e6,
663+
bfree: 5e5,
664+
bavail: 5e5,
665+
files: FS.nextInode,
666+
ffree: FS.nextInode - 1,
667+
fsid: 42,
668+
flags: 2,
669+
namelen: 255,
670+
};
671+
672+
var parent = FS.lookupPath(path, {follow: true}).node;
673+
if (parent?.node_ops.statfs) {
674+
Object.assign(rtn, parent.node_ops.statfs(parent.mount.opts.root));
675+
}
676+
return rtn;
677+
},
655678
// helpers to create specific types of nodes
656679
create(path, mode = 0o666) {
657680
mode &= {{{ cDefs.S_IALLUGO }}};
@@ -793,7 +816,7 @@ FS.staticInit();
793816
// do the underlying fs rename
794817
try {
795818
old_dir.node_ops.rename(old_node, new_dir, new_name);
796-
// update old node (we do this here to avoid each backend
819+
// update old node (we do this here to avoid each backend
797820
// needing to)
798821
old_node.parent = new_dir;
799822
} catch (e) {
@@ -888,7 +911,7 @@ FS.staticInit();
888911
if (!link.node_ops.readlink) {
889912
throw new FS.ErrnoError({{{ cDefs.EINVAL }}});
890913
}
891-
return PATH_FS.resolve(FS.getPath(link.parent), link.node_ops.readlink(link));
914+
return link.node_ops.readlink(link);
892915
},
893916
stat(path, dontFollow) {
894917
var lookup = FS.lookupPath(path, { follow: !dontFollow });
@@ -1364,7 +1387,7 @@ FS.staticInit();
13641387
FS.mkdir('/proc/self/fd');
13651388
FS.mount({
13661389
mount() {
1367-
var node = FS.createNode(proc_self, 'fd', {{{ cDefs.S_IFDIR }}} | {{{ 0777 }}}, {{{ cDefs.S_IXUGO }}});
1390+
var node = FS.createNode(proc_self, 'fd', {{{ cDefs.S_IFDIR | 0o777 }}}, {{{ cDefs.S_IXUGO }}});
13681391
node.node_ops = {
13691392
lookup(parent, name) {
13701393
var fd = +name;

src/library_lz4.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
addToLibrary({
99
$LZ4__deps: ['$FS', '$preloadPlugins'],
1010
$LZ4: {
11-
DIR_MODE: {{{ cDefs.S_IFDIR }}} | 511 /* 0777 */,
12-
FILE_MODE: {{{ cDefs.S_IFREG }}} | 511 /* 0777 */,
11+
DIR_MODE: {{{ cDefs.S_IFDIR | 0o777 }}},
12+
FILE_MODE: {{{ cDefs.S_IFREG | 0o777 }}},
1313
CHUNK_SIZE: -1,
1414
codec: null,
1515
init() {

src/library_memfs.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ addToLibrary({
1818
$MEMFS: {
1919
ops_table: null,
2020
mount(mount) {
21-
return MEMFS.createNode(null, '/', {{{ cDefs.S_IFDIR }}} | 511 /* 0777 */, 0);
21+
return MEMFS.createNode(null, '/', {{{ cDefs.S_IFDIR | 0o777 }}}, 0);
2222
},
2323
createNode(parent, name, mode, dev) {
2424
if (FS.isBlkdev(mode) || FS.isFIFO(mode)) {
@@ -232,7 +232,7 @@ addToLibrary({
232232
return entries;
233233
},
234234
symlink(parent, newname, oldpath) {
235-
var node = MEMFS.createNode(parent, newname, 511 /* 0777 */ | {{{ cDefs.S_IFLNK }}}, 0);
235+
var node = MEMFS.createNode(parent, newname, 0o777 | {{{ cDefs.S_IFLNK }}}, 0);
236236
node.link = oldpath;
237237
return node;
238238
},

src/library_nodefs.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,13 @@ addToLibrary({
219219
var path = NODEFS.realPath(node);
220220
return NODEFS.tryFSOperation(() => fs.readlinkSync(path));
221221
},
222+
statfs(path) {
223+
var stats = NODEFS.tryFSOperation(() => fs.statfsSync(path));
224+
// Node.js doesn't provide frsize (fragment size). Set it to bsize (block size)
225+
// as they're often the same in many file systems. May not be accurate for all.
226+
stats.frsize = stats.bsize;
227+
return stats;
228+
}
222229
},
223230
stream_ops: {
224231
open(stream) {

src/library_pipefs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ addToLibrary({
1212
mount(mount) {
1313
// Do not pollute the real root directory or its child nodes with pipes
1414
// Looks like it is OK to create another pseudo-root node not linked to the FS.root hierarchy this way
15-
return FS.createNode(null, '/', {{{ cDefs.S_IFDIR }}} | 511 /* 0777 */, 0);
15+
return FS.createNode(null, '/', {{{ cDefs.S_IFDIR }}} | 0o777, 0);
1616
},
1717
createPipe() {
1818
var pipe = {

src/library_sdl.js

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2762,11 +2762,13 @@ var LibrarySDL = {
27622762
27632763
if (bytes !== undefined && SDL.webAudioAvailable() && canPlayWithWebAudio) {
27642764
audio = undefined;
2765-
webAudio = {};
2766-
// The audio decoding process is asynchronous, which gives trouble if user code plays the audio data back immediately
2767-
// after loading. Therefore prepare an array of callback handlers to run when this audio decoding is complete, which
2768-
// will then start the playback (with some delay).
2769-
webAudio.onDecodeComplete = []; // While this member array exists, decoding hasn't finished yet.
2765+
webAudio = {
2766+
// The audio decoding process is asynchronous, which gives trouble if user
2767+
// code plays the audio data back immediately after loading. Therefore
2768+
// prepare an array of callback handlers to run when this audio decoding
2769+
// is complete, which will then start the playback (with some delay).
2770+
onDecodeComplete: [], // While this member array exists, decoding hasn't finished yet.
2771+
}
27702772
var onDecodeComplete = (data) => {
27712773
webAudio.decodedBuffer = data;
27722774
// Call all handlers that were waiting for this decode to finish, and clear the handler list.
@@ -2815,8 +2817,7 @@ var LibrarySDL = {
28152817
}
28162818
28172819
if (SDL.webAudioAvailable()) {
2818-
webAudio = {};
2819-
webAudio.decodedBuffer = buffer;
2820+
webAudio = { decodedBuffer: buffer };
28202821
} else {
28212822
audio = new Audio();
28222823
audio.mozAudioChannelType = 'content'; // bugzilla 910340
@@ -2873,13 +2874,14 @@ var LibrarySDL = {
28732874
var audio;
28742875
if (info.webAudio) {
28752876
// Create an instance of the WebAudio object.
2876-
audio = {};
2877-
audio.resource = info; // This new object is an instance that refers to this existing resource.
2878-
audio.paused = false;
2879-
audio.currentPosition = 0;
28802877
// Make our instance look similar to the instance of a <media> to make api simple.
2881-
audio.play = function() { SDL.playWebAudio(this); }
2882-
audio.pause = function() { SDL.pauseWebAudio(this); }
2878+
audio = {
2879+
resource: info, // This new object is an instance that refers to this existing resource.
2880+
paused: false,
2881+
currentPosition: 0,
2882+
play() { SDL.playWebAudio(this); },
2883+
pause() { SDL.pauseWebAudio(this); },
2884+
};
28832885
} else {
28842886
// We clone the audio node to utilize the preloaded audio buffer, since
28852887
// the browser has already preloaded the audio file.
@@ -2964,12 +2966,13 @@ var LibrarySDL = {
29642966
var audio;
29652967
if (info.webAudio) { // Play via Web Audio API
29662968
// Create an instance of the WebAudio object.
2967-
audio = {};
2968-
audio.resource = info; // This new webAudio object is an instance that refers to this existing resource.
2969-
audio.paused = false;
2970-
audio.currentPosition = 0;
2971-
audio.play = function() { SDL.playWebAudio(this); }
2972-
audio.pause = function() { SDL.pauseWebAudio(this); }
2969+
audio = {
2970+
resource: info, // This new webAudio object is an instance that refers to this existing resource.
2971+
paused: false,
2972+
currentPosition: 0,
2973+
play() { SDL.playWebAudio(this); },
2974+
pause() { SDL.pauseWebAudio(this); },
2975+
};
29732976
} else if (info.audio) { // Play via the <audio> element
29742977
audio = info.audio;
29752978
}

src/library_sockfs.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ addToLibrary({
4141
SOCKFS.on('close', (fd) => dbg(`websocket: close fd = ${fd}`));
4242
#endif
4343

44-
return FS.createNode(null, '/', {{{ cDefs.S_IFDIR }}} | 511 /* 0777 */, 0);
44+
return FS.createNode(null, '/', {{{ cDefs.S_IFDIR | 0o777 }}}, 0);
4545
},
4646
createSocket(family, type, protocol) {
4747
type &= ~{{{ cDefs.SOCK_CLOEXEC | cDefs.SOCK_NONBLOCK }}}; // Some applications may pass it; it makes no sense for a single process.

src/library_syscall.js

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -790,22 +790,20 @@ var SyscallsLibrary = {
790790
},
791791
792792
__syscall_statfs64: (path, size, buf) => {
793-
path = SYSCALLS.getStr(path);
794793
#if ASSERTIONS
795794
assert(size === {{{ C_STRUCTS.statfs.__size__ }}});
796795
#endif
797-
// NOTE: None of the constants here are true. We're just returning safe and
798-
// sane values.
799-
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_bsize, '4096', 'i32') }}};
800-
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_frsize, '4096', 'i32') }}};
801-
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_blocks, '1000000', 'i32') }}};
802-
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_bfree, '500000', 'i32') }}};
803-
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_bavail, '500000', 'i32') }}};
804-
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_files, 'FS.nextInode', 'i32') }}};
805-
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_ffree, '1000000', 'i32') }}};
806-
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_fsid, '42', 'i32') }}};
807-
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_flags, '2', 'i32') }}}; // ST_NOSUID
808-
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_namelen, '255', 'i32') }}};
796+
var stats = FS.statfs(SYSCALLS.getStr(path));
797+
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_bsize, 'stats.bsize', 'i32') }}};
798+
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_frsize, 'stats.bsize', 'i32') }}};
799+
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_blocks, 'stats.blocks', 'i32') }}};
800+
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_bfree, 'stats.bfree', 'i32') }}};
801+
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_bavail, 'stats.bavail', 'i32') }}};
802+
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_files, 'stats.files', 'i32') }}};
803+
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_ffree, 'stats.ffree', 'i32') }}};
804+
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_fsid, 'stats.fsid', 'i32') }}};
805+
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_flags, 'stats.flags', 'i32') }}}; // ST_NOSUID
806+
{{{ makeSetValue('buf', C_STRUCTS.statfs.f_namelen, 'stats.namelen', 'i32') }}};
809807
return 0;
810808
},
811809
__syscall_fstatfs64__deps: ['__syscall_statfs64'],

0 commit comments

Comments
 (0)