reflink, reflinkat - fast copy source file to destination file
int reflink(const char *path1, const char *path2, int preserve); int reflinkat(int fd1, const char *path1, int fd2, const char *path2, int preserve, int flags);
The reflink() function creates the file named by path2 with the contents of the file named by path1. Reflink does not read or write the underlying data blocks. The path1 argument points to a pathname naming an existing file. The path2 argument points to a pathname naming the new directory entry to be created.
Both files must be in the same ZFS pool. The files named by path1 and path2 should not be directories. Reflink will not create directories. Path2 directory should not be read-only.
Upon successful completion, the reflink() function marks to update the st_ctime field of the file. Also, the st_ctime and st_mtime fields of the directory that contains the new entry are marked for update.
If the reflinkat() function is passed, the special value AT_FDCWD in the fd1 or fd2 parameter, uses the current working directory for the respective path argument. If the AT_SYMLINK_FOLLOW flag is set in the flag argument and the path1 argument names a symbolic link, the symbolic link path1 is dereferenced to provide the source of the reflink.
Upon successful completion, 0 is returned. Otherwise, -1 is returned, no link is created, and errno is set to indicate the error.
The reflink() and reflinkat() functions will fail if:
A component of either path prefix denies search permission, or the requested link requires writing in a directory with a mode that denies write permission.
The path1 or path2 argument does not specify an absolute path and the fd1 or fd2 argument, respectively, is neither AT_FDCWD nor a valid file descriptor open for reading.
The directory where the entry for the new link is being placed cannot be extended because the user's quota of disk blocks on that file system has been exhausted.
The path1 or path2 argument points to an illegal address.
The path argument includes non-UTF8 characters and the file system accepts only file names where all characters are part of the UTF-8 character codeset.
A signal is caught during the execution of the reflink() function.
The value of the preserve or flag argument is not valid.
Too many symbolic links were encountered in translating path.
The length of the path1 or path2 argument exceeds PATH_MAX, or the length of a path1 or path2 component exceeds NAME_MAX while _POSIX_NO_TRUNC is in effect.
The path1 or path2 argument is a null pathname. A component of either path prefix does not exist, or the file named by path1 does not exist.
The path1 or path2 argument is not an absolute path and fd1 or fd2, respectively, is neither AT_FDCWD nor a file descriptor associated with a directory.
Operation not supported.
The file named by path1 is a directory.
The effective user ID does not match the owner of the file and the {PRIV_FILE_LINK_ANY} privilege is not asserted in the effective set of the calling process.
The path2 filesystem is read-only.
The path1 and path2 filesystems are not in the same pool, or path1 and path2 are in different filesystems with one or or both having encryption enabled.
The file named by path2 is an existing file.
See attributes(5) for descriptions of the following attributes:
|