• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2.. _fs:
3
4File system operations
5======================
6
7libuv provides a wide variety of cross-platform sync and async file system
8operations. All functions defined in this document take a callback, which is
9allowed to be NULL. If the callback is NULL the request is completed synchronously,
10otherwise it will be performed asynchronously.
11
12All file operations are run on the threadpool. See :ref:`threadpool` for information
13on the threadpool size.
14
15.. note::
16     On Windows `uv_fs_*` functions use utf-8 encoding.
17
18Data types
19----------
20
21.. c:type:: uv_fs_t
22
23    File system request type.
24
25.. c:type:: uv_timespec_t
26
27    Portable equivalent of ``struct timespec``.
28
29    ::
30
31        typedef struct {
32            long tv_sec;
33            long tv_nsec;
34        } uv_timespec_t;
35
36.. c:type:: uv_stat_t
37
38    Portable equivalent of ``struct stat``.
39
40    ::
41
42        typedef struct {
43            uint64_t st_dev;
44            uint64_t st_mode;
45            uint64_t st_nlink;
46            uint64_t st_uid;
47            uint64_t st_gid;
48            uint64_t st_rdev;
49            uint64_t st_ino;
50            uint64_t st_size;
51            uint64_t st_blksize;
52            uint64_t st_blocks;
53            uint64_t st_flags;
54            uint64_t st_gen;
55            uv_timespec_t st_atim;
56            uv_timespec_t st_mtim;
57            uv_timespec_t st_ctim;
58            uv_timespec_t st_birthtim;
59        } uv_stat_t;
60
61.. c:enum:: uv_fs_type
62
63    File system request type.
64
65    ::
66
67        typedef enum {
68            UV_FS_UNKNOWN = -1,
69            UV_FS_CUSTOM,
70            UV_FS_OPEN,
71            UV_FS_CLOSE,
72            UV_FS_READ,
73            UV_FS_WRITE,
74            UV_FS_SENDFILE,
75            UV_FS_STAT,
76            UV_FS_LSTAT,
77            UV_FS_FSTAT,
78            UV_FS_FTRUNCATE,
79            UV_FS_UTIME,
80            UV_FS_FUTIME,
81            UV_FS_ACCESS,
82            UV_FS_CHMOD,
83            UV_FS_FCHMOD,
84            UV_FS_FSYNC,
85            UV_FS_FDATASYNC,
86            UV_FS_UNLINK,
87            UV_FS_RMDIR,
88            UV_FS_MKDIR,
89            UV_FS_MKDTEMP,
90            UV_FS_RENAME,
91            UV_FS_SCANDIR,
92            UV_FS_LINK,
93            UV_FS_SYMLINK,
94            UV_FS_READLINK,
95            UV_FS_CHOWN,
96            UV_FS_FCHOWN,
97            UV_FS_REALPATH,
98            UV_FS_COPYFILE,
99            UV_FS_LCHOWN,
100            UV_FS_OPENDIR,
101            UV_FS_READDIR,
102            UV_FS_CLOSEDIR,
103            UV_FS_MKSTEMP,
104            UV_FS_LUTIME
105        } uv_fs_type;
106
107.. c:type:: uv_statfs_t
108
109    Reduced cross platform equivalent of ``struct statfs``.
110    Used in :c:func:`uv_fs_statfs`.
111
112    ::
113
114        typedef struct uv_statfs_s {
115            uint64_t f_type;
116            uint64_t f_bsize;
117            uint64_t f_blocks;
118            uint64_t f_bfree;
119            uint64_t f_bavail;
120            uint64_t f_files;
121            uint64_t f_ffree;
122            uint64_t f_spare[4];
123        } uv_statfs_t;
124
125.. c:enum:: uv_dirent_t
126
127    Cross platform (reduced) equivalent of ``struct dirent``.
128    Used in :c:func:`uv_fs_scandir_next`.
129
130    ::
131
132        typedef enum {
133            UV_DIRENT_UNKNOWN,
134            UV_DIRENT_FILE,
135            UV_DIRENT_DIR,
136            UV_DIRENT_LINK,
137            UV_DIRENT_FIFO,
138            UV_DIRENT_SOCKET,
139            UV_DIRENT_CHAR,
140            UV_DIRENT_BLOCK
141        } uv_dirent_type_t;
142
143        typedef struct uv_dirent_s {
144            const char* name;
145            uv_dirent_type_t type;
146        } uv_dirent_t;
147
148.. c:type:: uv_dir_t
149
150    Data type used for streaming directory iteration.
151    Used by :c:func:`uv_fs_opendir()`, :c:func:`uv_fs_readdir()`, and
152    :c:func:`uv_fs_closedir()`. `dirents` represents a user provided array of
153    `uv_dirent_t`s used to hold results. `nentries` is the user provided maximum
154    array size of `dirents`.
155
156    ::
157
158        typedef struct uv_dir_s {
159            uv_dirent_t* dirents;
160            size_t nentries;
161        } uv_dir_t;
162
163
164Public members
165^^^^^^^^^^^^^^
166
167.. c:member:: uv_loop_t* uv_fs_t.loop
168
169    Loop that started this request and where completion will be reported.
170    Readonly.
171
172.. c:member:: uv_fs_type uv_fs_t.fs_type
173
174    FS request type.
175
176.. c:member:: const char* uv_fs_t.path
177
178    Path affecting the request.
179
180.. c:member:: ssize_t uv_fs_t.result
181
182    Result of the request. < 0 means error, success otherwise. On requests such
183    as :c:func:`uv_fs_read` or :c:func:`uv_fs_write` it indicates the amount of
184    data that was read or written, respectively.
185
186.. c:member:: uv_stat_t uv_fs_t.statbuf
187
188    Stores the result of :c:func:`uv_fs_stat` and other stat requests.
189
190.. c:member:: void* uv_fs_t.ptr
191
192    Stores the result of :c:func:`uv_fs_readlink` and
193    :c:func:`uv_fs_realpath` and serves as an alias to `statbuf`.
194
195.. seealso:: The :c:type:`uv_req_t` members also apply.
196
197
198API
199---
200
201.. c:function:: void uv_fs_req_cleanup(uv_fs_t* req)
202
203    Cleanup request. Must be called after a request is finished to deallocate
204    any memory libuv might have allocated.
205
206.. c:function:: int uv_fs_close(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb)
207
208    Equivalent to :man:`close(2)`.
209
210.. c:function:: int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, int mode, uv_fs_cb cb)
211
212    Equivalent to :man:`open(2)`.
213
214    .. note::
215        On Windows libuv uses `CreateFileW` and thus the file is always opened
216        in binary mode. Because of this the O_BINARY and O_TEXT flags are not
217        supported.
218
219.. c:function:: int uv_fs_read(uv_loop_t* loop, uv_fs_t* req, uv_file file, const uv_buf_t bufs[], unsigned int nbufs, int64_t offset, uv_fs_cb cb)
220
221    Equivalent to :man:`preadv(2)`.
222
223    .. warning::
224        On Windows, under non-MSVC environments (e.g. when GCC or Clang is used
225        to build libuv), files opened using ``UV_FS_O_FILEMAP`` may cause a fatal
226        crash if the memory mapped read operation fails.
227
228.. c:function:: int uv_fs_unlink(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb)
229
230    Equivalent to :man:`unlink(2)`.
231
232.. c:function:: int uv_fs_write(uv_loop_t* loop, uv_fs_t* req, uv_file file, const uv_buf_t bufs[], unsigned int nbufs, int64_t offset, uv_fs_cb cb)
233
234    Equivalent to :man:`pwritev(2)`.
235
236    .. warning::
237        On Windows, under non-MSVC environments (e.g. when GCC or Clang is used
238        to build libuv), files opened using ``UV_FS_O_FILEMAP`` may cause a fatal
239        crash if the memory mapped write operation fails.
240
241.. c:function:: int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, uv_fs_cb cb)
242
243    Equivalent to :man:`mkdir(2)`.
244
245    .. note::
246        `mode` is currently not implemented on Windows.
247
248.. c:function:: int uv_fs_mkdtemp(uv_loop_t* loop, uv_fs_t* req, const char* tpl, uv_fs_cb cb)
249
250    Equivalent to :man:`mkdtemp(3)`. The result can be found as a null terminated string at `req->path`.
251
252.. c:function:: int uv_fs_mkstemp(uv_loop_t* loop, uv_fs_t* req, const char* tpl, uv_fs_cb cb)
253
254    Equivalent to :man:`mkstemp(3)`. The created file path can be found as a null terminated string at `req->path`.
255    The file descriptor can be found as an integer at `req->result`.
256
257    .. versionadded:: 1.34.0
258
259.. c:function:: int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb)
260
261    Equivalent to :man:`rmdir(2)`.
262
263.. c:function:: int uv_fs_opendir(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb)
264
265    Opens `path` as a directory stream. On success, a `uv_dir_t` is allocated
266    and returned via `req->ptr`. This memory is not freed by
267    `uv_fs_req_cleanup()`, although `req->ptr` is set to `NULL`. The allocated
268    memory must be freed by calling `uv_fs_closedir()`. On failure, no memory
269    is allocated.
270
271    The contents of the directory can be iterated over by passing the resulting
272    `uv_dir_t` to `uv_fs_readdir()`.
273
274    .. versionadded:: 1.28.0
275
276.. c:function:: int uv_fs_closedir(uv_loop_t* loop, uv_fs_t* req, uv_dir_t* dir, uv_fs_cb cb)
277
278    Closes the directory stream represented by `dir` and frees the memory
279    allocated by `uv_fs_opendir()`.
280
281    .. versionadded:: 1.28.0
282
283.. c:function:: int uv_fs_readdir(uv_loop_t* loop, uv_fs_t* req, uv_dir_t* dir, uv_fs_cb cb)
284
285    Iterates over the directory stream, `dir`, returned by a successful
286    `uv_fs_opendir()` call. Prior to invoking `uv_fs_readdir()`, the caller
287    must set `dir->dirents` and `dir->nentries`, representing the array of
288    :c:type:`uv_dirent_t` elements used to hold the read directory entries and
289    its size.
290
291    On success, the result is an integer >= 0 representing the number of entries
292    read from the stream.
293
294    .. versionadded:: 1.28.0
295
296    .. warning::
297        `uv_fs_readdir()` is not thread safe.
298
299    .. note::
300        This function does not return the "." and ".." entries.
301
302    .. note::
303        On success this function allocates memory that must be freed using
304        `uv_fs_req_cleanup()`. `uv_fs_req_cleanup()` must be called before
305        closing the directory with `uv_fs_closedir()`.
306
307.. c:function:: int uv_fs_scandir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags, uv_fs_cb cb)
308.. c:function:: int uv_fs_scandir_next(uv_fs_t* req, uv_dirent_t* ent)
309
310    Equivalent to :man:`scandir(3)`, with a slightly different API. Once the callback
311    for the request is called, the user can use :c:func:`uv_fs_scandir_next` to
312    get `ent` populated with the next directory entry data. When there are no
313    more entries ``UV_EOF`` will be returned.
314
315    .. note::
316        Unlike `scandir(3)`, this function does not return the "." and ".." entries.
317
318    .. note::
319        On Linux, getting the type of an entry is only supported by some file systems (btrfs, ext2,
320        ext3 and ext4 at the time of this writing), check the :man:`getdents(2)` man page.
321
322.. c:function:: int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb)
323.. c:function:: int uv_fs_fstat(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb)
324.. c:function:: int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb)
325
326    Equivalent to :man:`stat(2)`, :man:`fstat(2)` and :man:`lstat(2)` respectively.
327
328.. c:function:: int uv_fs_statfs(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb)
329
330    Equivalent to :man:`statfs(2)`. On success, a `uv_statfs_t` is allocated
331    and returned via `req->ptr`. This memory is freed by `uv_fs_req_cleanup()`.
332
333    .. note::
334        Any fields in the resulting `uv_statfs_t` that are not supported by the
335        underlying operating system are set to zero.
336
337    .. versionadded:: 1.31.0
338
339.. c:function:: int uv_fs_rename(uv_loop_t* loop, uv_fs_t* req, const char* path, const char* new_path, uv_fs_cb cb)
340
341    Equivalent to :man:`rename(2)`.
342
343.. c:function:: int uv_fs_fsync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb)
344
345    Equivalent to :man:`fsync(2)`.
346
347    .. note::
348        For AIX, `uv_fs_fsync` returns `UV_EBADF` on file descriptors referencing
349        non regular files.
350
351.. c:function:: int uv_fs_fdatasync(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_fs_cb cb)
352
353    Equivalent to :man:`fdatasync(2)`.
354
355.. c:function:: int uv_fs_ftruncate(uv_loop_t* loop, uv_fs_t* req, uv_file file, int64_t offset, uv_fs_cb cb)
356
357    Equivalent to :man:`ftruncate(2)`.
358
359.. c:function:: int uv_fs_copyfile(uv_loop_t* loop, uv_fs_t* req, const char* path, const char* new_path, int flags, uv_fs_cb cb)
360
361    Copies a file from `path` to `new_path`. Supported `flags` are described below.
362
363    - `UV_FS_COPYFILE_EXCL`: If present, `uv_fs_copyfile()` will fail with
364      `UV_EEXIST` if the destination path already exists. The default behavior
365      is to overwrite the destination if it exists.
366    - `UV_FS_COPYFILE_FICLONE`: If present, `uv_fs_copyfile()` will attempt to
367      create a copy-on-write reflink. If the underlying platform does not
368      support copy-on-write, or an error occurs while attempting to use
369      copy-on-write, a fallback copy mechanism based on
370      :c:func:`uv_fs_sendfile()` is used.
371    - `UV_FS_COPYFILE_FICLONE_FORCE`: If present, `uv_fs_copyfile()` will
372      attempt to create a copy-on-write reflink. If the underlying platform does
373      not support copy-on-write, or an error occurs while attempting to use
374      copy-on-write, then an error is returned.
375
376    .. warning::
377        If the destination path is created, but an error occurs while copying
378        the data, then the destination path is removed. There is a brief window
379        of time between closing and removing the file where another process
380        could access the file.
381
382    .. versionadded:: 1.14.0
383
384    .. versionchanged:: 1.20.0 `UV_FS_COPYFILE_FICLONE` and
385        `UV_FS_COPYFILE_FICLONE_FORCE` are supported.
386
387    .. versionchanged:: 1.33.0 If an error occurs while using
388        `UV_FS_COPYFILE_FICLONE_FORCE`, that error is returned. Previously,
389        all errors were mapped to `UV_ENOTSUP`.
390
391.. c:function:: int uv_fs_sendfile(uv_loop_t* loop, uv_fs_t* req, uv_file out_fd, uv_file in_fd, int64_t in_offset, size_t length, uv_fs_cb cb)
392
393    Limited equivalent to :man:`sendfile(2)`.
394
395.. c:function:: int uv_fs_access(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, uv_fs_cb cb)
396
397    Equivalent to :man:`access(2)` on Unix. Windows uses ``GetFileAttributesW()``.
398
399.. c:function:: int uv_fs_chmod(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode, uv_fs_cb cb)
400.. c:function:: int uv_fs_fchmod(uv_loop_t* loop, uv_fs_t* req, uv_file file, int mode, uv_fs_cb cb)
401
402    Equivalent to :man:`chmod(2)` and :man:`fchmod(2)` respectively.
403
404.. c:function:: int uv_fs_utime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime, double mtime, uv_fs_cb cb)
405.. c:function:: int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file file, double atime, double mtime, uv_fs_cb cb)
406.. c:function:: int uv_fs_lutime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime, double mtime, uv_fs_cb cb)
407
408    Equivalent to :man:`utime(2)`, :man:`futimes(3)` and :man:`lutimes(3)` respectively.
409
410    .. note::
411      z/OS: `uv_fs_lutime()` is not implemented for z/OS. It can still be called but will return
412      ``UV_ENOSYS``.
413
414    .. note::
415      AIX: `uv_fs_futime()` and `uv_fs_lutime()` functions only work for AIX 7.1 and newer.
416      They can still be called on older versions but will return ``UV_ENOSYS``.
417
418    .. versionchanged:: 1.10.0 sub-second precission is supported on Windows
419
420.. c:function:: int uv_fs_link(uv_loop_t* loop, uv_fs_t* req, const char* path, const char* new_path, uv_fs_cb cb)
421
422    Equivalent to :man:`link(2)`.
423
424.. c:function:: int uv_fs_symlink(uv_loop_t* loop, uv_fs_t* req, const char* path, const char* new_path, int flags, uv_fs_cb cb)
425
426    Equivalent to :man:`symlink(2)`.
427
428    .. note::
429        On Windows the `flags` parameter can be specified to control how the symlink will
430        be created:
431
432            * ``UV_FS_SYMLINK_DIR``: indicates that `path` points to a directory.
433
434            * ``UV_FS_SYMLINK_JUNCTION``: request that the symlink is created
435              using junction points.
436
437.. c:function:: int uv_fs_readlink(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb)
438
439    Equivalent to :man:`readlink(2)`.
440    The resulting string is stored in `req->ptr`.
441
442.. c:function:: int uv_fs_realpath(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb)
443
444    Equivalent to :man:`realpath(3)` on Unix. Windows uses `GetFinalPathNameByHandle <https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfinalpathnamebyhandlea>`_.
445    The resulting string is stored in `req->ptr`.
446
447    .. warning::
448        This function has certain platform-specific caveats that were discovered when used in Node.
449
450        * macOS and other BSDs: this function will fail with UV_ELOOP if more than 32 symlinks are
451          found while resolving the given path.  This limit is hardcoded and cannot be sidestepped.
452        * Windows: while this function works in the common case, there are a number of corner cases
453          where it doesn't:
454
455          - Paths in ramdisk volumes created by tools which sidestep the Volume Manager (such as ImDisk)
456            cannot be resolved.
457          - Inconsistent casing when using drive letters.
458          - Resolved path bypasses subst'd drives.
459
460        While this function can still be used, it's not recommended if scenarios such as the
461        above need to be supported.
462
463        The background story and some more details on these issues can be checked
464        `here <https://github.com/nodejs/node/issues/7726>`_.
465
466    .. note::
467      This function is not implemented on Windows XP and Windows Server 2003.
468      On these systems, UV_ENOSYS is returned.
469
470    .. versionadded:: 1.8.0
471
472.. c:function:: int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_uid_t uid, uv_gid_t gid, uv_fs_cb cb)
473.. c:function:: int uv_fs_fchown(uv_loop_t* loop, uv_fs_t* req, uv_file file, uv_uid_t uid, uv_gid_t gid, uv_fs_cb cb)
474.. c:function:: int uv_fs_lchown(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_uid_t uid, uv_gid_t gid, uv_fs_cb cb)
475
476    Equivalent to :man:`chown(2)`, :man:`fchown(2)` and :man:`lchown(2)` respectively.
477
478    .. note::
479        These functions are not implemented on Windows.
480
481    .. versionchanged:: 1.21.0 implemented uv_fs_lchown
482
483.. c:function:: uv_fs_type uv_fs_get_type(const uv_fs_t* req)
484
485    Returns `req->fs_type`.
486
487    .. versionadded:: 1.19.0
488
489.. c:function:: ssize_t uv_fs_get_result(const uv_fs_t* req)
490
491    Returns `req->result`.
492
493    .. versionadded:: 1.19.0
494
495.. c:function:: int uv_fs_get_system_error(const uv_fs_t* req)
496
497    Returns the platform specific error code - `GetLastError()` value on Windows
498    and `-(req->result)` on other platforms.
499
500    .. versionadded:: 1.38.0
501
502.. c:function:: void* uv_fs_get_ptr(const uv_fs_t* req)
503
504    Returns `req->ptr`.
505
506    .. versionadded:: 1.19.0
507
508.. c:function:: const char* uv_fs_get_path(const uv_fs_t* req)
509
510    Returns `req->path`.
511
512    .. versionadded:: 1.19.0
513
514.. c:function:: uv_stat_t* uv_fs_get_statbuf(uv_fs_t* req)
515
516    Returns `&req->statbuf`.
517
518    .. versionadded:: 1.19.0
519
520.. seealso:: The :c:type:`uv_req_t` API functions also apply.
521
522Helper functions
523----------------
524
525.. c:function:: uv_os_fd_t uv_get_osfhandle(int fd)
526
527   For a file descriptor in the C runtime, get the OS-dependent handle.
528   On UNIX, returns the ``fd`` intact. On Windows, this calls `_get_osfhandle <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/get-osfhandle?view=vs-2019>`_.
529   Note that the return value is still owned by the C runtime,
530   any attempts to close it or to use it after closing the fd may lead to malfunction.
531
532    .. versionadded:: 1.12.0
533
534.. c:function:: int uv_open_osfhandle(uv_os_fd_t os_fd)
535
536   For a OS-dependent handle, get the file descriptor in the C runtime.
537   On UNIX, returns the ``os_fd`` intact. On Windows, this calls `_open_osfhandle <https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/open-osfhandle?view=vs-2019>`_.
538   Note that this consumes the argument, any attempts to close it or to use it
539   after closing the return value may lead to malfunction.
540
541    .. versionadded:: 1.23.0
542
543File open constants
544-------------------
545
546.. c:macro:: UV_FS_O_APPEND
547
548    The file is opened in append mode. Before each write, the file offset is
549    positioned at the end of the file.
550
551.. c:macro:: UV_FS_O_CREAT
552
553    The file is created if it does not already exist.
554
555.. c:macro:: UV_FS_O_DIRECT
556
557    File I/O is done directly to and from user-space buffers, which must be
558    aligned. Buffer size and address should be a multiple of the physical sector
559    size of the block device.
560
561    .. note::
562        `UV_FS_O_DIRECT` is supported on Linux, and on Windows via
563        `FILE_FLAG_NO_BUFFERING <https://docs.microsoft.com/en-us/windows/win32/fileio/file-buffering>`_.
564        `UV_FS_O_DIRECT` is not supported on macOS.
565
566.. c:macro:: UV_FS_O_DIRECTORY
567
568    If the path is not a directory, fail the open.
569
570    .. note::
571        `UV_FS_O_DIRECTORY` is not supported on Windows.
572
573.. c:macro:: UV_FS_O_DSYNC
574
575    The file is opened for synchronous I/O. Write operations will complete once
576    all data and a minimum of metadata are flushed to disk.
577
578    .. note::
579        `UV_FS_O_DSYNC` is supported on Windows via
580        `FILE_FLAG_WRITE_THROUGH <https://docs.microsoft.com/en-us/windows/win32/fileio/file-buffering>`_.
581
582.. c:macro:: UV_FS_O_EXCL
583
584    If the `O_CREAT` flag is set and the file already exists, fail the open.
585
586    .. note::
587        In general, the behavior of `O_EXCL` is undefined if it is used without
588        `O_CREAT`. There is one exception: on Linux 2.6 and later, `O_EXCL` can
589        be used without `O_CREAT` if pathname refers to a block device. If the
590        block device is in use by the system (e.g., mounted), the open will fail
591        with the error `EBUSY`.
592
593.. c:macro:: UV_FS_O_EXLOCK
594
595    Atomically obtain an exclusive lock.
596
597    .. note::
598        `UV_FS_O_EXLOCK` is only supported on macOS and Windows.
599
600    .. versionchanged:: 1.17.0 support is added for Windows.
601
602.. c:macro:: UV_FS_O_FILEMAP
603
604    Use a memory file mapping to access the file. When using this flag, the
605    file cannot be open multiple times concurrently.
606
607    .. note::
608        `UV_FS_O_FILEMAP` is only supported on Windows.
609
610.. c:macro:: UV_FS_O_NOATIME
611
612    Do not update the file access time when the file is read.
613
614    .. note::
615        `UV_FS_O_NOATIME` is not supported on Windows.
616
617.. c:macro:: UV_FS_O_NOCTTY
618
619    If the path identifies a terminal device, opening the path will not cause
620    that terminal to become the controlling terminal for the process (if the
621    process does not already have one).
622
623    .. note::
624        `UV_FS_O_NOCTTY` is not supported on Windows.
625
626.. c:macro:: UV_FS_O_NOFOLLOW
627
628    If the path is a symbolic link, fail the open.
629
630    .. note::
631        `UV_FS_O_NOFOLLOW` is not supported on Windows.
632
633.. c:macro:: UV_FS_O_NONBLOCK
634
635    Open the file in nonblocking mode if possible.
636
637    .. note::
638        `UV_FS_O_NONBLOCK` is not supported on Windows.
639
640.. c:macro:: UV_FS_O_RANDOM
641
642    Access is intended to be random. The system can use this as a hint to
643    optimize file caching.
644
645    .. note::
646        `UV_FS_O_RANDOM` is only supported on Windows via
647        `FILE_FLAG_RANDOM_ACCESS <https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea>`_.
648
649.. c:macro:: UV_FS_O_RDONLY
650
651    Open the file for read-only access.
652
653.. c:macro:: UV_FS_O_RDWR
654
655    Open the file for read-write access.
656
657.. c:macro:: UV_FS_O_SEQUENTIAL
658
659    Access is intended to be sequential from beginning to end. The system can
660    use this as a hint to optimize file caching.
661
662    .. note::
663        `UV_FS_O_SEQUENTIAL` is only supported on Windows via
664        `FILE_FLAG_SEQUENTIAL_SCAN <https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea>`_.
665
666.. c:macro:: UV_FS_O_SHORT_LIVED
667
668    The file is temporary and should not be flushed to disk if possible.
669
670    .. note::
671        `UV_FS_O_SHORT_LIVED` is only supported on Windows via
672        `FILE_ATTRIBUTE_TEMPORARY <https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea>`_.
673
674.. c:macro:: UV_FS_O_SYMLINK
675
676    Open the symbolic link itself rather than the resource it points to.
677
678.. c:macro:: UV_FS_O_SYNC
679
680    The file is opened for synchronous I/O. Write operations will complete once
681    all data and all metadata are flushed to disk.
682
683    .. note::
684        `UV_FS_O_SYNC` is supported on Windows via
685        `FILE_FLAG_WRITE_THROUGH <https://docs.microsoft.com/en-us/windows/win32/fileio/file-buffering>`_.
686
687.. c:macro:: UV_FS_O_TEMPORARY
688
689    The file is temporary and should not be flushed to disk if possible.
690
691    .. note::
692        `UV_FS_O_TEMPORARY` is only supported on Windows via
693        `FILE_ATTRIBUTE_TEMPORARY <https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea>`_.
694
695.. c:macro:: UV_FS_O_TRUNC
696
697    If the file exists and is a regular file, and the file is opened
698    successfully for write access, its length shall be truncated to zero.
699
700.. c:macro:: UV_FS_O_WRONLY
701
702    Open the file for write-only access.
703