Skip to content

Commit 5ac384b

Browse files
authored
[nodefs] Remove compatibility code for ancient node versions (#23316)
1 parent cbf40dc commit 5ac384b

17 files changed

+73
-31
lines changed

.circleci/config.yml

+53-1
Original file line numberDiff line numberDiff line change
@@ -766,14 +766,66 @@ jobs:
766766
- run-tests:
767767
title: "node (oldest / 10.19.0)"
768768
extra-cflags: "-sMIN_NODE_VERSION=101900"
769+
# We include most but not all of the nodefs and node rawfs tests here.
770+
# test_fs_nodefs_rw, test_fs_nodefs_statvfs, and test_unistd_io_nodefs_bigint fail.
769771
test_targets: "
770772
other.test_gen_struct_info
771773
other.test_native_call_before_init
772774
other.test_js_optimizer_verbose
773775
other.test_node_unhandled_rejection
774776
other.test_full_js_library*
775777
core2.test_hello_world
776-
core2.test_fs_write_rawfs"
778+
core2.test_fcntl_open_nodefs
779+
core2.test_fcntl_open_rawfs
780+
core2.test_fgetc_ungetc_nodefs
781+
core2.test_fgetc_ungetc_rawfs
782+
core2.test_fs_append_rawfs
783+
core2.test_fs_emptyPath_rawfs
784+
core2.test_fs_enotdir_nodefs
785+
core2.test_fs_enotdir_rawfs
786+
core2.test_fs_errorstack_rawfs
787+
core2.test_fs_llseek_rawfs
788+
core2.test_fs_mkdir_dotdot_nodefs
789+
core2.test_fs_mkdir_dotdot_rawfs
790+
core2.test_fs_mmap_nodefs
791+
core2.test_fs_mmap_rawfs
792+
core2.test_fs_nodefs_cloexec
793+
core2.test_fs_nodefs_cloexec_rawfs
794+
core2.test_fs_nodefs_dup
795+
core2.test_fs_nodefs_dup_rawfs
796+
core2.test_fs_nodefs_home
797+
core2.test_fs_nodefs_nofollow
798+
core2.test_fs_nodefs_readdir
799+
core2.test_fs_noderawfs_nofollow
800+
core2.test_fs_readdir_ino_matches_stat_ino_nodefs
801+
core2.test_fs_readdir_ino_matches_stat_ino_rawfs
802+
core2.test_fs_readv_rawfs
803+
core2.test_fs_rename_on_existing_nodefs
804+
core2.test_fs_rename_on_existing_rawfs
805+
core2.test_fs_symlink_resolution_nodefs
806+
core2.test_fs_symlink_resolution_rawfs
807+
core2.test_fs_writeFile_rawfs
808+
core2.test_fs_writeFile_wasmfs_rawfs
809+
core2.test_fs_write_rawfs
810+
core2.test_fs_writev_rawfs
811+
core2.test_futimens_rawfs
812+
core2.test_readdir_rawfs
813+
core2.test_stat_chmod_rawfs
814+
core2.test_unistd_access_nodefs
815+
core2.test_unistd_access_rawfs
816+
core2.test_unistd_close_rawfs
817+
core2.test_unistd_dup_rawfs
818+
core2.test_unistd_io_nodefs
819+
core2.test_unistd_links_nodefs
820+
core2.test_unistd_misc_nodefs
821+
core2.test_unistd_pipe_rawfs
822+
core2.test_unistd_symlink_on_nodefs
823+
core2.test_unistd_truncate_nodefs
824+
core2.test_unistd_truncate_rawfs
825+
core2.test_unistd_unlink_nodefs
826+
core2.test_unistd_unlink_rawfs
827+
core2.test_unistd_write_broken_link_rawfs
828+
"
777829
# Run a few test with the most recent version of node
778830
# In particular we have some tests that require node flags on older
779831
# versions of node but not with the most recent version.

src/closure-externs/node-externs.js

+5
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ fs.Stats.prototype.mtimeMs;
126126
*/
127127
fs.Stats.prototype.ctimeMs;
128128

129+
/**
130+
* @type {number}
131+
*/
132+
fs.Stats.prototype.blksize;
133+
129134
/**
130135
* @param {string} p
131136
* @return {boolean}

src/library_nodefs.js

+1-16
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ addToLibrary({
1919
isWindows: false,
2020
staticInit() {
2121
NODEFS.isWindows = !!process.platform.match(/^win/);
22-
var flags = process.binding("constants");
23-
// Node.js 4 compatibility: it has no namespaces for constants
24-
if (flags["fs"]) {
25-
flags = flags["fs"];
26-
}
22+
var flags = process.binding("constants")["fs"];
2723
NODEFS.flagsForNodeMap = {
2824
"{{{ cDefs.O_APPEND }}}": flags["O_APPEND"],
2925
"{{{ cDefs.O_CREAT }}}": flags["O_CREAT"],
@@ -123,15 +119,6 @@ addToLibrary({
123119
var stat;
124120
NODEFS.tryFSOperation(() => stat = fs.lstatSync(path));
125121
if (NODEFS.isWindows) {
126-
// node.js v0.10.20 doesn't report blksize and blocks on Windows. Fake
127-
// them with default blksize of 4096.
128-
// See http://support.microsoft.com/kb/140365
129-
if (!stat.blksize) {
130-
stat.blksize = 4096;
131-
}
132-
if (!stat.blocks) {
133-
stat.blocks = (stat.size+stat.blksize-1)/stat.blksize|0;
134-
}
135122
// Windows does not report the 'x' permission bit, so propagate read
136123
// bits to execute bits.
137124
stat.mode |= (stat.mode & {{{ cDefs.S_IRUGO }}}) >> 2;
@@ -261,8 +248,6 @@ addToLibrary({
261248
stream.shared.refcount++;
262249
},
263250
read(stream, buffer, offset, length, position) {
264-
// Node.js < 6 compatibility: node errors on 0 length reads
265-
if (length === 0) return 0;
266251
return NODEFS.tryFSOperation(() =>
267252
fs.readSync(stream.nfd, new Int8Array(buffer.buffer, offset, length), 0, length, position)
268253
);
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20272
1+
20283
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8334
1+
8332
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20240
1+
20251
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
24040
1+
24051
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8296
1+
8298
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20165
1+
20176
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8296
1+
8298
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20165
1+
20176
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8364
1+
8362
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20348
1+
20358
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
24040
1+
24051
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20272
1+
20283
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
7652
1+
7653
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
18819
1+
18830

0 commit comments

Comments
 (0)