Commit fe4c68b
committed
vfs: make the reserved root readable through fs
The reserved root `${os.devNull}/vfs`, which holds the mount points of
all virtual file systems, could not be read: fs calls on it fell through
to the real file system, so nothing could list what was mounted.
While any file system is mounted, serve the root as a read-only
directory. It lists every mount point by the last segment of its path, a
recursive listing descends into each mounted file system, and paths
under it that no mount serves report ENOENT. Creating, removing or
changing entries in it fails with EROFS. When nothing is mounted it does
not exist, as before.
Add vfs.vfsBase(), which returns the path of that directory, so that a
program can read it without spelling the path out.
A mount point cannot be removed or renamed, nor replaced by a rename:
rmdir() and rename() fail with EBUSY, and a recursive rm() empties the
file system and then fails the same way. Before, rmdir() of an empty
mount point reported success without doing anything.
The callback and promise forms of readdir() with `withFileTypes` now
report each Dirent's parentPath as a host path, as readdirSync() did,
instead of the provider-relative one, and split recursive names such as
`dir/file.txt` into their directory and base name. A recursive listing
joins subdirectories with the host separator rather than `/`, which
mixed separators on Windows. realpath() of a mount point no longer
returns it with a trailing separator.
Signed-off-by: Philipp Dunkel <pip@pipobscure.com>1 parent 342bf6d commit fe4c68b
8 files changed
Lines changed: 645 additions & 39 deletions
File tree
- doc/api
- lib
- internal/vfs
- test/parallel
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
155 | 178 | | |
156 | 179 | | |
157 | 180 | | |
| |||
187 | 210 | | |
188 | 211 | | |
189 | 212 | | |
190 | | - | |
191 | | - | |
192 | | - | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
193 | 218 | | |
194 | 219 | | |
195 | 220 | | |
| |||
203 | 228 | | |
204 | 229 | | |
205 | 230 | | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
206 | 236 | | |
207 | 237 | | |
208 | 238 | | |
| |||
380 | 410 | | |
381 | 411 | | |
382 | 412 | | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
383 | 439 | | |
384 | 440 | | |
385 | 441 | | |
| |||
711 | 767 | | |
712 | 768 | | |
713 | 769 | | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
714 | 773 | | |
715 | 774 | | |
716 | 775 | | |
| |||
721 | 780 | | |
722 | 781 | | |
723 | 782 | | |
| 783 | + | |
724 | 784 | | |
725 | 785 | | |
726 | 786 | | |
727 | 787 | | |
| 788 | + | |
728 | 789 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
180 | 181 | | |
181 | 182 | | |
182 | 183 | | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
183 | 194 | | |
184 | 195 | | |
185 | 196 | | |
| |||
201 | 212 | | |
202 | 213 | | |
203 | 214 | | |
| 215 | + | |
204 | 216 | | |
205 | 217 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
| 7 | + | |
6 | 8 | | |
7 | 9 | | |
8 | 10 | | |
| |||
21 | 23 | | |
22 | 24 | | |
23 | 25 | | |
| 26 | + | |
24 | 27 | | |
25 | 28 | | |
26 | 29 | | |
| |||
30 | 33 | | |
31 | 34 | | |
32 | 35 | | |
| 36 | + | |
33 | 37 | | |
34 | 38 | | |
35 | 39 | | |
| |||
47 | 51 | | |
48 | 52 | | |
49 | 53 | | |
| 54 | + | |
50 | 55 | | |
51 | 56 | | |
52 | 57 | | |
| |||
80 | 85 | | |
81 | 86 | | |
82 | 87 | | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
83 | 94 | | |
84 | 95 | | |
85 | 96 | | |
| |||
122 | 133 | | |
123 | 134 | | |
124 | 135 | | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
125 | 147 | | |
126 | 148 | | |
127 | 149 | | |
128 | | - | |
129 | 150 | | |
130 | 151 | | |
131 | 152 | | |
| |||
260 | 281 | | |
261 | 282 | | |
262 | 283 | | |
| 284 | + | |
| 285 | + | |
263 | 286 | | |
264 | 287 | | |
265 | 288 | | |
| |||
343 | 366 | | |
344 | 367 | | |
345 | 368 | | |
| 369 | + | |
| 370 | + | |
346 | 371 | | |
347 | | - | |
348 | | - | |
349 | | - | |
350 | | - | |
351 | | - | |
352 | | - | |
353 | | - | |
354 | | - | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
359 | | - | |
360 | | - | |
361 | | - | |
362 | | - | |
363 | | - | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
364 | 396 | | |
365 | 397 | | |
366 | 398 | | |
367 | | - | |
368 | 399 | | |
369 | 400 | | |
370 | 401 | | |
| |||
386 | 417 | | |
387 | 418 | | |
388 | 419 | | |
| 420 | + | |
389 | 421 | | |
390 | 422 | | |
391 | 423 | | |
| |||
406 | 438 | | |
407 | 439 | | |
408 | 440 | | |
| 441 | + | |
| 442 | + | |
409 | 443 | | |
410 | 444 | | |
411 | 445 | | |
| |||
774 | 808 | | |
775 | 809 | | |
776 | 810 | | |
777 | | - | |
| 811 | + | |
| 812 | + | |
778 | 813 | | |
779 | 814 | | |
780 | 815 | | |
| |||
1134 | 1169 | | |
1135 | 1170 | | |
1136 | 1171 | | |
| 1172 | + | |
| 1173 | + | |
1137 | 1174 | | |
1138 | 1175 | | |
1139 | 1176 | | |
| |||
1163 | 1200 | | |
1164 | 1201 | | |
1165 | 1202 | | |
1166 | | - | |
| 1203 | + | |
| 1204 | + | |
1167 | 1205 | | |
1168 | 1206 | | |
1169 | 1207 | | |
| |||
1174 | 1212 | | |
1175 | 1213 | | |
1176 | 1214 | | |
| 1215 | + | |
1177 | 1216 | | |
1178 | 1217 | | |
1179 | 1218 | | |
| |||
1185 | 1224 | | |
1186 | 1225 | | |
1187 | 1226 | | |
| 1227 | + | |
| 1228 | + | |
1188 | 1229 | | |
1189 | 1230 | | |
1190 | 1231 | | |
| |||
1240 | 1281 | | |
1241 | 1282 | | |
1242 | 1283 | | |
1243 | | - | |
| 1284 | + | |
1244 | 1285 | | |
1245 | 1286 | | |
1246 | 1287 | | |
| |||
1316 | 1357 | | |
1317 | 1358 | | |
1318 | 1359 | | |
| 1360 | + | |
1319 | 1361 | | |
1320 | 1362 | | |
0 commit comments