diff --git a/doc/api/fs.md b/doc/api/fs.md
index 8f2a75d54964a4..837ef0256a49e9 100644
--- a/doc/api/fs.md
+++ b/doc/api/fs.md
@@ -1159,8 +1159,18 @@ operation. If an error occurs after the destination file has been opened for
writing, Node.js will attempt to remove the destination.
`flags` is an optional integer that specifies the behavior
-of the copy operation. The only supported flag is `fs.constants.COPYFILE_EXCL`,
-which causes the copy operation to fail if `dest` already exists.
+of the copy operation. It is possible to create a mask consisting of the bitwise
+OR of two or more values (e.g.
+`fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`).
+
+* `fs.constants.COPYFILE_EXCL` - The copy operation will fail if `dest` already
+exists.
+* `fs.constants.COPYFILE_FICLONE` - The copy operation will attempt to create a
+copy-on-write reflink. If the platform does not support copy-on-write, then a
+fallback copy mechanism is used.
+* `fs.constants.COPYFILE_FICLONE_FORCE` - The copy operation will attempt to
+create a copy-on-write reflink. If the platform does not support copy-on-write,
+then the operation will fail.
Example:
@@ -1200,8 +1210,18 @@ atomicity of the copy operation. If an error occurs after the destination file
has been opened for writing, Node.js will attempt to remove the destination.
`flags` is an optional integer that specifies the behavior
-of the copy operation. The only supported flag is `fs.constants.COPYFILE_EXCL`,
-which causes the copy operation to fail if `dest` already exists.
+of the copy operation. It is possible to create a mask consisting of the bitwise
+OR of two or more values (e.g.
+`fs.constants.COPYFILE_EXCL | fs.constants.COPYFILE_FICLONE`).
+
+* `fs.constants.COPYFILE_EXCL` - The copy operation will fail if `dest` already
+exists.
+* `fs.constants.COPYFILE_FICLONE` - The copy operation will attempt to create a
+copy-on-write reflink. If the platform does not support copy-on-write, then a
+fallback copy mechanism is used.
+* `fs.constants.COPYFILE_FICLONE_FORCE` - The copy operation will attempt to
+create a copy-on-write reflink. If the platform does not support copy-on-write,
+then the operation will fail.
Example:
@@ -3336,6 +3356,34 @@ The following constants are meant for use with [`fs.access()`][].
+### File Copy Constants
+
+The following constants are meant for use with [`fs.copyFile()`][].
+
+
+
+
Constant
+
Description
+
+
+
COPYFILE_EXCL
+
If present, the copy operation will fail with an error if the
+ destination path already exists.
+
+
+
COPYFILE_FICLONE
+
If present, the copy operation will attempt to create a
+ copy-on-write reflink. If the underlying platform does not support
+ copy-on-write, then a fallback copy mechanism is used.
+
+
+
COPYFILE_FICLONE_FORCE
+
If present, the copy operation will attempt to create a
+ copy-on-write reflink. If the underlying platform does not support
+ copy-on-write, then the operation will fail with an error.
+
+
+
### File Open Constants
The following constants are meant for use with `fs.open()`.
diff --git a/lib/fs.js b/lib/fs.js
index 5d3bae1550e298..f89c501e41f188 100644
--- a/lib/fs.js
+++ b/lib/fs.js
@@ -1920,7 +1920,15 @@ fs.mkdtempSync = function(prefix, options) {
// Define copyFile() flags.
Object.defineProperties(fs.constants, {
- COPYFILE_EXCL: { enumerable: true, value: constants.UV_FS_COPYFILE_EXCL }
+ COPYFILE_EXCL: { enumerable: true, value: constants.UV_FS_COPYFILE_EXCL },
+ COPYFILE_FICLONE: {
+ enumerable: true,
+ value: constants.UV_FS_COPYFILE_FICLONE
+ },
+ COPYFILE_FICLONE_FORCE: {
+ enumerable: true,
+ value: constants.UV_FS_COPYFILE_FICLONE_FORCE
+ }
});
diff --git a/src/node_constants.cc b/src/node_constants.cc
index d478d434000fca..be1965a12c0c38 100644
--- a/src/node_constants.cc
+++ b/src/node_constants.cc
@@ -1317,6 +1317,8 @@ void DefineConstants(v8::Isolate* isolate, Local