]> git.saurik.com Git - apple/copyfile.git/blame - copyfile.3
copyfile-173.40.2.tar.gz
[apple/copyfile.git] / copyfile.3
CommitLineData
b3aa0442
A
1.\"
2.\" Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
3.\"
62b275d9 4.Dd July 22, 2019
b3aa0442
A
5.Dt COPYFILE 3
6.Os
7.Sh NAME
8.Nm copyfile , fcopyfile ,
9.Nm copyfile_state_alloc , copyfile_state_free ,
10.Nm copyfile_state_get , copyfile_state_set
11.Nd copy a file
12.Sh LIBRARY
13.Lb libc
14.Sh SYNOPSIS
15.In copyfile.h
16.Ft int
17.Fn copyfile "const char *from" "const char *to" "copyfile_state_t state" "copyfile_flags_t flags"
18.Ft int
19.Fn fcopyfile "int from" "int to" "copyfile_state_t state" "copyfile_flags_t flags"
20.Ft copyfile_state_t
21.Fn copyfile_state_alloc "void"
22.Ft int
23.Fn copyfile_state_free "copyfile_state_t state"
24.Ft int
25.Fn copyfile_state_get "copyfile_state_t state" "uint32_t flag" "void * dst"
26.Ft int
27.Fn copyfile_state_set "copyfile_state_t state" "uint32_t flag" "const void * src"
659640e4
A
28.Ft typedef int
29.Fn (*copyfile_callback_t) "int what" "int stage" "copyfile_state_t state" "const char * src" "const char * dst" "void * ctx"
b3aa0442
A
30.Sh DESCRIPTION
31These functions are used to copy a file's data and/or metadata. (Metadata
32consists of permissions, extended attributes, access control lists, and so
33forth.)
34.Pp
35The
36.Fn copyfile_state_alloc
37function initializes a
38.Vt copyfile_state_t
39object (which is an opaque data type).
40This object can be passed to
41.Fn copyfile
42and
43.Fn fcopyfile ;
44.Fn copyfile_state_get
45and
46.Fn copyfile_state_set
47can be used to manipulate the state (see below).
48The
49.Fn copyfile_state_free
50function is used to deallocate the object and its contents.
51.Pp
52The
53.Fn copyfile
54function can copy the named
55.Va from
56file to the named
57.Va to
58file; the
59.Fn fcopyfile
60function does the same, but using the file descriptors of already-opened
61files.
62If the
63.Va state
64parameter is the return value from
65.Fn copyfile_state_alloc ,
66then
67.Fn copyfile
68and
69.Fn fcopyfile
70will use the information from the state object; if it is
71.Dv NULL ,
72then both functions will work normally, but less control will be available to the caller.
73The
74.Va flags
75parameter controls which contents are copied:
76.Bl -tag -width COPYFILE_XATTR
77.It Dv COPYFILE_ACL
78Copy the source file's access control lists.
79.It Dv COPYFILE_STAT
80Copy the source file's POSIX information (mode, modification time, etc.).
81.It Dv COPYFILE_XATTR
82Copy the source file's extended attributes.
83.It Dv COPYFILE_DATA
84Copy the source file's data.
85.El
86.Pp
87These values may be or'd together; several convenience macros are provided:
88.Bl -tag -width COPYFILE_SECURITY
89.It Dv COPYFILE_SECURITY
90Copy the source file's POSIX and ACL information; equivalent to
91.Dv (COPYFILE_STAT|COPYFILE_ACL) .
92.It Dv COPYFILE_METADATA
93Copy the metadata; equivalent to
94.Dv (COPYFILE_SECURITY|COPYFILE_XATTR) .
95.It Dv COPYFILE_ALL
96Copy the entire file; equivalent to
97.Dv (COPYFILE_METADATA|COPYFILE_DATA) .
98.El
99.Pp
100The
101.Fn copyfile
102and
103.Fn fcopyfile
104functions can also have their behavior modified by the following flags:
105.Bl -tag -width COPYFILE_NOFOLLOW_SRC
659640e4
A
106.It Dv COPYFILE_RECURSIVE
107Causes
108.Fn copyfile
3f81d1c4 109to recursively copy a hierarchy.
659640e4
A
110This flag is not used by
111.Fn fcopyfile ;
112see below for more information.
b3aa0442
A
113.It Dv COPYFILE_CHECK
114Return a bitmask (corresponding to the
115.Va flags
116argument) indicating which contents would be copied; no data are actually
117copied. (E.g., if
118.Va flags
119was set to
120.Dv COPYFILE_CHECK|COPYFILE_METADATA ,
121and the
122.Va from
123file had extended attributes but no ACLs, the return value would be
124.Dv COPYFILE_XATTR .)
125.It Dv COPYFILE_PACK
126Serialize the
127.Va from
85b8a2cb
A
128file.
129The
b3aa0442
A
130.Va to
131file is an AppleDouble-format file.
132.It Dv COPYFILE_UNPACK
133Unserialize the
134.Va from
85b8a2cb
A
135file.
136The
b3aa0442
A
137.Va from
138file is an AppleDouble-format file; the
139.Va to
140file will have the extended attributes, ACLs, resource fork, and
141FinderInfo data from the
142.Va to
143file, regardless of the
144.Va flags
145argument passed in.
146.It Dv COPYFILE_EXCL
147Fail if the
148.Va to
149file already exists. (This is only applicable for the
150.Fn copyfile
151function.)
152.It Dv COPYFILE_NOFOLLOW_SRC
153Do not follow the
154.Va from
155file, if it is a symbolic link. (This is only applicable for the
156.Fn copyfile
157function.)
158.It Dv COPYFILE_NOFOLLOW_DST
159Do not follow the
160.Va to
161file, if it is a symbolic link. (This is only applicable for the
162.Fn copyfile
163function.)
164.It Dv COPYFILE_MOVE
3f81d1c4
A
165Unlink (using
166.Xr remove 3 )
167the
b3aa0442
A
168.Fa from
169file. (This is only applicable for the
170.Fn copyfile
3f81d1c4
A
171function.) No error is returned if
172.Xr remove 3
85b8a2cb
A
173fails.
174Note that
3f81d1c4
A
175.Xr remove 3
176removes a symbolic link itself, not the
177target of the link.
b3aa0442
A
178.It Dv COPYFILE_UNLINK
179Unlink the
180.Va to
181file before starting. (This is only applicable for the
182.Fn copyfile
183function.)
1f4df596 184.It Dv COPYFILE_CLONE_FORCE
f475fe66 185Clone the file instead.
1f4df596 186This is a force flag i.e. if cloning fails, an error is returned.
dcb8fd50
A
187This flag is equivalent to (COPYFILE_EXCL | COPYFILE_ACL | COPYFILE_STAT | COPYFILE_XATTR | COPYFILE_DATA
188| COPYFILE_NOFOLLOW_SRC).
189Note that if cloning is successful, progress callbacks will not be invoked.
f475fe66 190Note also that there is no support for cloning directories: if a directory is provided as the source,
85b8a2cb
A
191an error will be returned.
192Since this flag implies COPYFILE_NOFOLLOW_SRC, symbolic links themselves will be cloned instead of their targets.
f475fe66
A
193(This is only applicable for the
194.Fn copyfile
195function.)
1f4df596 196.It Dv COPYFILE_CLONE
f475fe66 197Try to clone the file instead.
1f4df596 198This is a best try flag i.e. if cloning fails, fallback to copying the file.
dcb8fd50
A
199This flag is equivalent to (COPYFILE_EXCL | COPYFILE_ACL | COPYFILE_STAT | COPYFILE_XATTR | COPYFILE_DATA
200| COPYFILE_NOFOLLOW_SRC).
201Note that if cloning is successful, progress callbacks will not be invoked.
202Note also that there is no support for cloning directories: if a directory is provided as the source and
85b8a2cb
A
203COPYFILE_CLONE_FORCE is not passed, this will instead copy the directory.
204Since this flag implies COPYFILE_NOFOLLOW_SRC, symbolic links themselves will be cloned instead of their targets.
205Recursive copying however is supported, see below for more information.
f475fe66
A
206(This is only applicable for the
207.Fn copyfile
208function.)
937356ff
A
209.It Dv COPYFILE_DATA_SPARSE
210Copy a file sparsely.
211This requires that the source and destination file systems support sparse files with hole sizes
212at least as large as their block sizes.
213This also requires that the source file is sparse, and for
214.Fn fcopyfile
215the source file descriptor's offset be a multiple of the minimum hole size.
216If COPYFILE_DATA is also specified, this will fall back to a full copy
217if sparse copying cannot be performed for any reason; otherwise, an error is returned.
b3aa0442
A
218.It Dv COPYFILE_NOFOLLOW
219This is a convenience macro, equivalent to
f475fe66 220.Dv (COPYFILE_NOFOLLOW_DST | COPYFILE_NOFOLLOW_SRC) .
1f4df596 221.It Dv COPYFILE_RUN_IN_PLACE
85b8a2cb
A
222If the src file has quarantine information, add the QTN_FLAG_DO_NOT_TRANSLOCATE flag to the quarantine information of the dst file.
223This allows a bundle to run in place instead of being translocated.
62b275d9
A
224.It Dv COPYFILE_PRESERVE_DST_TRACKED
225Preserve the UF_TRACKED flag at
226.Va to
227when copying metadata, regardless of whether
228.Va from
85b8a2cb
A
229has it set.
230This flag is used in conjunction with COPYFILE_STAT, or COPYFILE_CLONE (for its fallback case).
b3aa0442
A
231.El
232.Pp
85b8a2cb
A
233Copying files into a directory is supported.
234If
23896e53
A
235.Va to
236is a directory,
237.Va from
238will be copied into
239.Va to
240(if
241.Va from
242is a directory,
243copying its contents requires use of the COPYFILE_RECURSIVE parameter,
244which is documented below).
245.Pp
b3aa0442
A
246The
247.Fn copyfile_state_get
248and
249.Fn copyfile_state_set
250functions can be used to manipulate the
251.Ft copyfile_state_t
252object returned by
253.Fn copyfile_state_alloc .
254In both functions, the
255.Va dst
256parameter's type depends on the
257.Va flag
258parameter that is passed in.
259.Bl -tag -width COPYFILE_STATE_DST_FILENAME
260.It Dv COPYFILE_STATE_SRC_FD
261.It Dv COPYFILE_STATE_DST_FD
262Get or set the file descriptor associated with the source (or destination)
263file.
264If this has not been initialized yet, the value will be -2.
265The
266.Va dst
267(for
268.Fn copyfile_state_get )
269and
270.Va src
271(for
272.Fn copyfile_state_set )
273parameters are pointers to
274.Vt int .
275.It Dv COPYFILE_STATE_SRC_FILENAME
276.It Dv COPYFILE_STATE_DST_FILENAME
277Get or set the filename associated with the source (or destination)
85b8a2cb
A
278file.
279If it has not been initialized yet, the value will be
b3aa0442
A
280.Dv NULL .
281For
282.Fn copyfile_state_set ,
283the
284.Va src
285parameter is a pointer to a C string
286(i.e.,
287.Vt char* );
288.Fn copyfile_state_set
289makes a private copy of this string.
290For
291.Fn copyfile_state_get
292function, the
293.Va dst
294parameter is a pointer to a pointer to a C string
295(i.e.,
296.Vt char** );
297the returned value is a pointer to the
298.Va state 's
299copy, and must not be modified or released.
659640e4
A
300.It Dv COPYFILE_STATE_STATUS_CB
301Get or set the callback status function (currently
302only used for recursive copies; see below for details).
303The
304.Va src
305parameter is a pointer to a function of type
306.Vt copyfile_callback_t
307(see above).
308.It Dv COPYFILE_STATE_STATUS_CTX
309Get or set the context parameter for the status
310call-back function (see below for details).
311The
312.Va src
313parameter is a
314.Vt void\ * .
b3aa0442
A
315.It Dv COPYFILE_STATE_QUARANTINE
316Get or set the quarantine information with the source file.
317The
318.Va src
659640e4
A
319parameter is a pointer to an opaque
320object (type
321.Vt void\ *
322).
323.It Dv COPYFILE_STATE_COPIED
324Get the number of data bytes copied so far.
325(Only valid for
326.Fn copyfile_state_get ;
327see below for more details about callbacks.)
1f4df596
A
328If a
329.Dv COPYFILE_CLONE
330or
331.Dv COPYFILE_CLONE_FORCE
332operation successfully cloned the requested objects, then this value will be 0.
659640e4
A
333The
334.Va dst
335parameter is a pointer to
336.Vt off_t
337(type
338.Vt off_t\ * ).
3f81d1c4
A
339.It Dv COPYFILE_STATE_XATTRNAME
340Get the name of the extended attribute during a callback
341for
342.Dv COPYFILE_COPY_XATTR
343(see below for details). This field cannot be set,
344and may be
345.Dv NULL .
1f4df596
A
346.It Dv COPYFILE_STATE_WAS_CLONED
347True if a
348.Dv COPYFILE_CLONE
349or
350.Dv COPYFILE_CLONE_FORCE
351operation successfully cloned the requested objects.
352The
353.Va dst
354parameter is a pointer to
355.Vt bool
356(type
357.Vt bool\ * ).
659640e4
A
358.El
359.Sh Recursive Copies
360When given the
361.Dv COPYFILE_RECURSIVE
362flag,
363.Fn copyfile
364(but not
365.Fn fcopyfile )
366will use the
367.Xr fts 3
368functions to recursively descend into the source file-system object.
369It then calls
370.Fn copyfile
371on each of the entries it finds that way.
372If a call-back function is given (using
373.Fn copyfile_state_set
374and
375.Dv COPYFILE_STATE_STATUS_CB ),
376the call-back function will be called four times for each directory
377object, and twice for all other objects. (Each directory will
378be examined twice, once on entry -- before copying each of the
379objects contained in the directory -- and once on exit -- after
380copying each object contained in the directory, in order to perform
381some final cleanup.)
382.Pp
383The call-back function will have one of the following values
384as the first argument, indicating what is being copied:
385.Bl -tag -width COPYFILE_RECURSE_DIR_CLEANUP
386.It Dv COPYFILE_RECURSE_FILE
387The object being copied is a file (or, rather,
388something other than a directory).
389.It Dv COPYFILE_RECURSE_DIR
390The object being copied is a directory, and is being
391entered. (That is, none of the filesystem objects contained
392within the directory have been copied yet.)
393.It Dv COPYFILE_RECURSE_DIR_CLEANUP
394The object being copied is a directory, and all of the
85b8a2cb
A
395objects contained have been copied.
396At this stage, the destination directory
659640e4
A
397being copied will have any extra permissions that were added to
398allow the copying will be removed.
399.It Dv COPYFILE_RECURSE_ERROR
400There was an error in processing an element of the source hierarchy;
401this happens when
402.Xr fts 3
403returns an error or unknown file type.
404(Currently, the second argument to the call-back function will always
405be
406.Dv COPYFILE_ERR
407in this case.)
408.El
409.Pp
410The second argument to the call-back function will indicate
411the stage of the copy, and will be one of the following values:
412.Bl -tag -width COPYFILE_FINISH
413.It Dv COPYFILE_START
85b8a2cb
A
414Before copying has begun.
415The third parameter will be a newly-created
659640e4
A
416.Vt copyfile_state_t
417object with the call-back function and context pre-loaded.
418.It Dv COPYFILE_FINISH
419After copying has successfully finished.
420.It Dv COPYFILE_ERR
85b8a2cb
A
421Indicates an error has happened at some stage.
422If the first argument to the call-back function is
659640e4
A
423.Dv COPYFILE_RECURSE_ERROR ,
424then an error occurred while processing the source hierarchy;
425otherwise, it will indicate what type of object was being copied,
426and
427.Dv errno
428will be set to indicate the error.
429.El
430.Pp
431The fourth and fifth
432parameters are the source and destination paths that
433are to be copied (or have been copied, or failed to copy, depending on
434the second argument).
435.Pp
436The last argument to the call-back function will be the value
437set by
438.Dv COPYFILE_STATE_STATUS_CTX ,
439if any.
440.Pp
441The call-back function is required to return one of the following
442values:
443.Bl -tag -width COPYFILE_CONTINUE
444.It Dv COPYFILE_CONTINUE
445The copy will continue as expected.
446.It Dv COPYFILE_SKIP
447This object will be skipped, and the next object will
85b8a2cb
A
448be processed.
449(Note that, when entering a directory, returning
659640e4
A
450.Dv COPYFILE_SKIP
451from the call-back function will prevent the contents
452of the directory from being copied.)
453.It Dv COPYFILE_QUIT
85b8a2cb
A
454The entire copy is aborted at this stage.
455Any filesystem
659640e4
A
456objects created up to this point will remain.
457.Fn copyfile
458will return -1, but
459.Dv errno
460will be unmodified.
461.El
462.Pp
463The call-back function must always return one of the values listed
464above; if not, the results are undefined.
465.Pp
466The call-back function will be called twice for each object
467(and an additional two times for directory cleanup); the first
468call will have a
469.Ar stage
470parameter of
471.Dv COPYFILE_START ;
472the second time, that value will be either
473.Dv COPYFILE_FINISH
474or
475.Dv COPYFILE_ERR
476to indicate a successful completion, or an error during
477processing.
478In the event of an error, the
479.Dv errno
480value will be set appropriately.
481.Pp
dcb8fd50
A
482Note that recursive cloning is also supported with the
483.Dv COPYFILE_CLONE
484flag (but not the
485.Dv COPYFILE_CLONE_FORCE
85b8a2cb
A
486flag).
487A recursive clone operation invokes
dcb8fd50
A
488.Fn copyfile
489with
490.Dv COPYFILE_CLONE
85b8a2cb
A
491on every entry found in the source file-system object.
492Because
dcb8fd50
A
493.Fn copyfile
494does not allow the cloning of directories, a recursive clone will
495instead copy any directory it finds (while cloning its contents).
496As symbolic links may point to directories, they are not followed
497during recursive clones even if the source is a symbolic link.
498Additionally, because the
499.Dv COPYFILE_CLONE
500flag implies the
501.Dv COPYFILE_EXCL
502flag, recursive clones require a nonexistent destination.
503.Pp
659640e4
A
504The
505.Dv COPYFILE_PACK ,
506.Dv COPYFILE_UNPACK ,
507.Dv COPYFILE_MOVE ,
508and
509.Dv COPYFILE_UNLINK
510flags are not used during a recursive copy, and will result
511in an error being returned.
23896e53
A
512.Pp
513Note that if the source path ends in a
514.Va /
515its contents are copied rather than the directory itself (like cp(1)).
516The behavior of a recursive copy on a directory hierarchy also depends
85b8a2cb
A
517on the contents of the destination.
518If the destination is a directory, the source directory (or its contents,
519if the source path ends in a
23896e53 520.Va /
85b8a2cb
A
521) will be copied into it.
522If the destination exists but is not a
23896e53
A
523directory, and the source is a non-empty directory, the copy will fail;
524the exact error set depends on the flags provided to
525.Fn copyfile
526initially.
659640e4
A
527.Sh Progress Callback
528In addition to the recursive callbacks described above,
529.Fn copyfile
530and
531.Fn fcopyfile
3f81d1c4 532will also use a callback to report data (e.g.,
659640e4 533.Dv COPYFILE_DATA )
85b8a2cb
A
534progress.
535If given, the callback will be invoked on each
659640e4 536.Xr write 2
85b8a2cb
A
537call.
538The first argument to the callback function will be
659640e4
A
539.Dv COPYFILE_COPY_DATA .
540The second argument will either be
3f81d1c4 541.Dv COPYFILE_PROGRESS
659640e4
A
542(indicating that the write was successful), or
543.Dv COPYFILE_ERR
544(indicating that there was an error of some sort).
545.Pp
546The amount of data bytes copied so far can be retrieved using
547.Fn copyfile_state_get ,
548with the
549.Dv COPYFILE_STATE_COPIED
550requestor (the argument type is a pointer to
551.Vt off_t ).
552.Pp
3f81d1c4
A
553When copying extended attributes, the first argument to the
554callback function will be
555.Dv COPYFILE_COPY_XATTR .
556The other arguments will be as described for
557.Dv COPYFILE_COPY_DATA ;
558the name of the extended attribute being copied may be
559retrieved using
560.Fn copyfile_state_get
561and the parameter
562.Dv COPYFILE_STATE_XATTRNAME .
563When using
564.Dv COPYFILE_PACK ,
565the callback may be called with
566.Dv COPYFILE_START
567for each of the extended attributes first, followed by
568.Dv COPYFILE_PROGRESS
569before getting and packing the data for each
570individual attribute, and then
571.Dv COPYFILE_FINISH
572when finished with each individual attribute.
573(That is,
574.Dv COPYFILE_START
575may be called for all of the extended attributes, before
576the first callback with
577.Dv COPYFILE_PROGRESS
85b8a2cb
A
578is invoked.)
579Any attribute skipped by returning
3f81d1c4
A
580.Dv COPYFILE_SKIP
581from the
582.Dv COPYFILE_START
583callback will not be placed into the packed output file.
584.Pp
659640e4
A
585The return value for the data callback must be one of
586.Bl -tag -width COPYFILE_CONTINUE
587.It Dv COPYFILE_CONTINUE
588The copy will continue as expected.
589(In the case of error, it will attempt to write the data again.)
590.It Dv COPYFILE_SKIP
591The data copy will be aborted, but without error.
592.It Dv COPYFILE_QUIT
593The data copy will be aborted; in the case of
3f81d1c4 594.Dv COPYFILE_PROGRESS ,
659640e4
A
595.Dv errno
596will be set to
597.Dv ECANCELED .
b3aa0442 598.El
659640e4
A
599.Pp
600While the
601.Va src
602and
603.Va dst
604parameters will be passed in, they may be
605.Dv NULL
606in the case of
607.Fn fcopyfile .
dcb8fd50
A
608.Pp
609Note that progress callbacks are not invoked when a clone is requested
610(e.g.
611.Dv COPYFILE_CLONE )
612unless the clone cannot be performed and a copy is performed instead.
b3aa0442
A
613.Sh RETURN VALUES
614Except when given the
615.Dv COPYFILE_CHECK
616flag,
617.Fn copyfile
618and
619.Fn fcopyfile
620return less than 0 on error, and 0 on success.
621All of the other functions return 0 on success, and less than 0
622on error.
659640e4
A
623.Sh WARNING
624Both
625.Fn copyfile
626and
627.Fn fcopyfile
628can copy symbolic links; there is a gap between when the source
3f81d1c4 629link is examined and the actual copy is started, and this can
659640e4
A
630be a potential security risk, especially if the process has
631elevated privileges.
632.Pp
633When performing a recursive copy, if the source hierarchy
634changes while the copy is occurring, the results are undefined.
3f81d1c4
A
635.Pp
636.Fn fcopyfile
637does not reset the seek position for either source or destination.
638This can result in the destination file being a different size
639than the source file.
85b8a2cb
A
640.Sh EXAMPLES
641.Bd -literal -offset indent
642/* Initialize a state variable */
643copyfile_state_t s;
644s = copyfile_state_alloc();
645/* Copy the data and extended attributes of one file to another */
646copyfile("/tmp/f1", "/tmp/f2", s, COPYFILE_DATA | COPYFILE_XATTR);
647/* Convert a file to an AppleDouble file for serialization */
648copyfile("/tmp/f2", "/tmp/tmpfile", NULL, COPYFILE_ALL | COPYFILE_PACK);
649/* Release the state variable */
650copyfile_state_free(s);
651/* A more complex way to call copyfile() */
652s = copyfile_state_alloc();
653copyfile_state_set(s, COPYFILE_STATE_SRC_FILENAME, "/tmp/foo");
654/* One of src or dst must be set... rest can come from the state */
655copyfile(NULL, "/tmp/bar", s, COPYFILE_ALL);
656/* Now copy the same source file to another destination file */
657copyfile(NULL, "/tmp/car", s, COPYFILE_ALL);
658copyfile_state_free(s);
659/* Remove extended attributes from a file */
660copyfile("/dev/null", "/tmp/bar", NULL, COPYFILE_XATTR);
661.Ed
b3aa0442
A
662.Sh ERRORS
663.Fn copyfile
664and
665.Fn fcopyfile
666will fail if:
667.Bl -tag -width Er
668.It Bq Er EINVAL
659640e4
A
669An invalid flag was passed in with
670.Dv COPYFILE_RECURSIVE .
671.It Bq Er EINVAL
672The
b3aa0442
A
673.Va from
674or
675.Va to
659640e4
A
676parameter to
677.Fn copyfile
678was a
b3aa0442 679.Dv NULL
659640e4
A
680pointer.
681.It Bq Er EINVAL
682The
683.Va from
684or
685.Va to
686parameter to
f475fe66 687.Fn fcopyfile
659640e4 688was a negative number.
b3aa0442
A
689.It Bq Er ENOMEM
690A memory allocation failed.
691.It Bq Er ENOTSUP
692The source file was not a directory, symbolic link, or regular file.
937356ff
A
693.It Bq Er ENOTSUP
694COPYFILE_CLONE_FORCE was specified and file cloning is not supported.
695.It Bq Er ENOTSUP
696COPYFILE_DATA_SPARSE was specified, sparse copying is not supported,
697and COPYFILE_DATA was not specified.
659640e4
A
698.It Bq Er ECANCELED
699The copy was cancelled by callback.
f475fe66
A
700.It Bq Er EEXIST
701The
702.Va to
703parameter to
704.Fn copyfile
705already existed and was passed in with
706.Dv COPYFILE_EXCL .
707.It Bq Er ENOENT
708The
709.Va from
710parameter to
711.Fn copyfile
712did not exist.
713.It Bq Er EACCES
714Search permission is denied for a component of the path prefix for
715the
716.Va from
717or
718.Va to
719parameters.
720.It Bq Er EACCES
721Write permission is denied for a component of the path prefix for the
722.Va to
723parameter.
b3aa0442 724.El
f475fe66 725.Pp
b3aa0442
A
726In addition, both functions may set
727.Dv errno
728via an underlying library or system call.
659640e4 729.Sh SEE ALSO
659640e4 730.Xr getxattr 2 ,
85b8a2cb 731.Xr listxattr 2 ,
659640e4
A
732.Xr setxattr 2 ,
733.Xr acl 3
85b8a2cb
A
734.Sh HISTORY
735The
736.Fn copyfile
737API was introduced in Mac OS X 10.5.
b3aa0442
A
738.Sh BUGS
739Both
740.Fn copyfile
741functions lack a way to set the input or output block size.
659640e4
A
742.Pp
743Recursive copies do not honor hard links.