Commit ea51c14
authored
vfs: close the fs hook gaps for mounted paths
Several `node:fs` entry points behave differently for a mounted path
than for a real one, because of how the call reaches the VFS hooks.
Make them behave as they do for a real path:
* Add the `watchFile`, `unwatchFile` and `promisesWatch` handlers,
backed by the provider's stat watcher and async watcher; those calls
threw a TypeError before. Have `watch` refuse a path that does not
exist with ENOENT instead of handing back a watcher that polls
forever and keeps the process alive.
* Convert timestamps and validate arguments before the hook runs in
`utimes`, `lutimes` and `readdir` (sync, callback and promise forms),
so a mounted path gets the same ERR_INVALID_ARG_* errors and the same
seconds-since-epoch numbers as a real one.
* Pass the mode and times through to the `fchmod` and `futimes` hooks
and route them to the handle's entry, so descriptor operations take
effect like their path forms instead of being no-ops; the memory
handle validates the way a FileHandle would since one calls it
directly.
* Treat a `mkdtemp` prefix as text rather than a path when it ends in a
separator, so the directory is created inside the intended parent.
* Map the first directory a recursive `mkdir` created back under the
mount point instead of returning the provider-relative path.
* Make disposing an already closed virtual `Dir` a no-op, as on the
native `Dir`, instead of rejecting with ERR_DIR_CLOSED.
test-vfs-fs-hook-gaps adds a test per gap, stating the real-fs outcome
as the expectation. The existing file handle test asserted that
`chmod()` and `utimes()` without arguments were no-ops; they now
validate and apply, so it exercises that instead.
Signed-off-by: Philipp Dunkel <pip@pipobscure.com>
PR-URL: #65852
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Filip Skokan <panva.ip@gmail.com>1 parent cfdb7e6 commit ea51c14
8 files changed
Lines changed: 304 additions & 89 deletions
File tree
- lib
- internal
- fs
- vfs
- test/parallel
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1863 | 1863 | | |
1864 | 1864 | | |
1865 | 1865 | | |
1866 | | - | |
1867 | | - | |
1868 | | - | |
1869 | 1866 | | |
1870 | 1867 | | |
1871 | 1868 | | |
1872 | 1869 | | |
1873 | 1870 | | |
1874 | 1871 | | |
1875 | 1872 | | |
| 1873 | + | |
| 1874 | + | |
| 1875 | + | |
1876 | 1876 | | |
1877 | 1877 | | |
1878 | 1878 | | |
| |||
1909 | 1909 | | |
1910 | 1910 | | |
1911 | 1911 | | |
1912 | | - | |
1913 | | - | |
1914 | | - | |
1915 | | - | |
1916 | | - | |
1917 | 1912 | | |
1918 | 1913 | | |
1919 | 1914 | | |
1920 | 1915 | | |
1921 | 1916 | | |
1922 | 1917 | | |
| 1918 | + | |
| 1919 | + | |
| 1920 | + | |
| 1921 | + | |
| 1922 | + | |
| 1923 | + | |
1923 | 1924 | | |
1924 | 1925 | | |
1925 | 1926 | | |
| |||
2422 | 2423 | | |
2423 | 2424 | | |
2424 | 2425 | | |
2425 | | - | |
| 2426 | + | |
2426 | 2427 | | |
2427 | 2428 | | |
2428 | 2429 | | |
| |||
2441 | 2442 | | |
2442 | 2443 | | |
2443 | 2444 | | |
| 2445 | + | |
| 2446 | + | |
2444 | 2447 | | |
2445 | 2448 | | |
2446 | | - | |
| 2449 | + | |
2447 | 2450 | | |
2448 | 2451 | | |
2449 | 2452 | | |
2450 | 2453 | | |
2451 | 2454 | | |
2452 | 2455 | | |
2453 | | - | |
2454 | | - | |
2455 | | - | |
2456 | | - | |
| 2456 | + | |
2457 | 2457 | | |
2458 | 2458 | | |
2459 | 2459 | | |
| |||
2692 | 2692 | | |
2693 | 2693 | | |
2694 | 2694 | | |
| 2695 | + | |
| 2696 | + | |
2695 | 2697 | | |
2696 | 2698 | | |
2697 | 2699 | | |
2698 | 2700 | | |
2699 | 2701 | | |
2700 | 2702 | | |
2701 | | - | |
2702 | | - | |
2703 | | - | |
2704 | | - | |
2705 | | - | |
2706 | | - | |
| 2703 | + | |
2707 | 2704 | | |
2708 | 2705 | | |
2709 | 2706 | | |
| |||
2716 | 2713 | | |
2717 | 2714 | | |
2718 | 2715 | | |
| 2716 | + | |
| 2717 | + | |
2719 | 2718 | | |
2720 | 2719 | | |
2721 | 2720 | | |
2722 | 2721 | | |
2723 | 2722 | | |
2724 | 2723 | | |
2725 | 2724 | | |
2726 | | - | |
2727 | | - | |
2728 | | - | |
2729 | | - | |
2730 | | - | |
| 2725 | + | |
2731 | 2726 | | |
2732 | 2727 | | |
2733 | 2728 | | |
| |||
2745 | 2740 | | |
2746 | 2741 | | |
2747 | 2742 | | |
2748 | | - | |
| 2743 | + | |
2749 | 2744 | | |
2750 | 2745 | | |
2751 | 2746 | | |
| |||
2767 | 2762 | | |
2768 | 2763 | | |
2769 | 2764 | | |
| 2765 | + | |
| 2766 | + | |
| 2767 | + | |
2770 | 2768 | | |
2771 | 2769 | | |
2772 | | - | |
| 2770 | + | |
2773 | 2771 | | |
2774 | 2772 | | |
2775 | 2773 | | |
2776 | 2774 | | |
2777 | 2775 | | |
2778 | 2776 | | |
2779 | 2777 | | |
2780 | | - | |
2781 | | - | |
2782 | | - | |
2783 | | - | |
2784 | | - | |
| 2778 | + | |
2785 | 2779 | | |
2786 | 2780 | | |
2787 | 2781 | | |
| |||
2796 | 2790 | | |
2797 | 2791 | | |
2798 | 2792 | | |
| 2793 | + | |
| 2794 | + | |
2799 | 2795 | | |
2800 | 2796 | | |
2801 | 2797 | | |
2802 | 2798 | | |
2803 | 2799 | | |
2804 | 2800 | | |
2805 | | - | |
2806 | | - | |
2807 | | - | |
2808 | | - | |
2809 | | - | |
2810 | | - | |
| 2801 | + | |
2811 | 2802 | | |
2812 | 2803 | | |
2813 | 2804 | | |
| |||
2820 | 2811 | | |
2821 | 2812 | | |
2822 | 2813 | | |
| 2814 | + | |
| 2815 | + | |
2823 | 2816 | | |
2824 | 2817 | | |
2825 | 2818 | | |
2826 | 2819 | | |
2827 | 2820 | | |
2828 | 2821 | | |
2829 | 2822 | | |
2830 | | - | |
2831 | | - | |
2832 | | - | |
2833 | | - | |
2834 | | - | |
| 2823 | + | |
2835 | 2824 | | |
2836 | 2825 | | |
2837 | 2826 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1725 | 1725 | | |
1726 | 1726 | | |
1727 | 1727 | | |
1728 | | - | |
1729 | | - | |
1730 | | - | |
1731 | | - | |
1732 | | - | |
1733 | 1728 | | |
1734 | 1729 | | |
1735 | 1730 | | |
1736 | 1731 | | |
1737 | 1732 | | |
1738 | 1733 | | |
| 1734 | + | |
| 1735 | + | |
| 1736 | + | |
| 1737 | + | |
| 1738 | + | |
| 1739 | + | |
1739 | 1740 | | |
1740 | 1741 | | |
1741 | 1742 | | |
| |||
2011 | 2012 | | |
2012 | 2013 | | |
2013 | 2014 | | |
| 2015 | + | |
| 2016 | + | |
2014 | 2017 | | |
2015 | 2018 | | |
2016 | 2019 | | |
| |||
2019 | 2022 | | |
2020 | 2023 | | |
2021 | 2024 | | |
2022 | | - | |
2023 | | - | |
2024 | | - | |
2025 | | - | |
2026 | | - | |
2027 | | - | |
| 2025 | + | |
2028 | 2026 | | |
2029 | 2027 | | |
2030 | 2028 | | |
| |||
2044 | 2042 | | |
2045 | 2043 | | |
2046 | 2044 | | |
| 2045 | + | |
| 2046 | + | |
| 2047 | + | |
| 2048 | + | |
2047 | 2049 | | |
2048 | 2050 | | |
2049 | 2051 | | |
2050 | 2052 | | |
2051 | 2053 | | |
2052 | 2054 | | |
2053 | 2055 | | |
2054 | | - | |
2055 | | - | |
2056 | | - | |
2057 | | - | |
2058 | | - | |
2059 | | - | |
| 2056 | + | |
2060 | 2057 | | |
2061 | 2058 | | |
2062 | 2059 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
97 | 103 | | |
98 | 104 | | |
99 | 105 | | |
100 | | - | |
101 | 106 | | |
102 | 107 | | |
103 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
| 24 | + | |
23 | 25 | | |
24 | 26 | | |
25 | 27 | | |
| |||
29 | 31 | | |
30 | 32 | | |
31 | 33 | | |
32 | | - | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
288 | 289 | | |
289 | 290 | | |
290 | 291 | | |
291 | | - | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
292 | 298 | | |
293 | 299 | | |
294 | | - | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
295 | 303 | | |
296 | 304 | | |
297 | 305 | | |
| |||
300 | 308 | | |
301 | 309 | | |
302 | 310 | | |
303 | | - | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
304 | 319 | | |
305 | 320 | | |
306 | | - | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
307 | 324 | | |
308 | 325 | | |
309 | 326 | | |
| |||
681 | 698 | | |
682 | 699 | | |
683 | 700 | | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
| 726 | + | |
| 727 | + | |
684 | 728 | | |
685 | 729 | | |
686 | 730 | | |
| |||
0 commit comments