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