xref: /freebsd/bin/cp/extern.h (revision c3efa16dc9bcdcbe128c6b3c4b000867bbaf7991)
14b88c807SRodney W. Grimes /*-
28a16b7a1SPedro F. Giffuni  * SPDX-License-Identifier: BSD-3-Clause
38a16b7a1SPedro F. Giffuni  *
44b88c807SRodney W. Grimes  * Copyright (c) 1991, 1993, 1994
54b88c807SRodney W. Grimes  *	The Regents of the University of California.  All rights reserved.
64b88c807SRodney W. Grimes  *
74b88c807SRodney W. Grimes  * Redistribution and use in source and binary forms, with or without
84b88c807SRodney W. Grimes  * modification, are permitted provided that the following conditions
94b88c807SRodney W. Grimes  * are met:
104b88c807SRodney W. Grimes  * 1. Redistributions of source code must retain the above copyright
114b88c807SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer.
124b88c807SRodney W. Grimes  * 2. Redistributions in binary form must reproduce the above copyright
134b88c807SRodney W. Grimes  *    notice, this list of conditions and the following disclaimer in the
144b88c807SRodney W. Grimes  *    documentation and/or other materials provided with the distribution.
15fbbd9655SWarner Losh  * 3. Neither the name of the University nor the names of its contributors
164b88c807SRodney W. Grimes  *    may be used to endorse or promote products derived from this software
174b88c807SRodney W. Grimes  *    without specific prior written permission.
184b88c807SRodney W. Grimes  *
194b88c807SRodney W. Grimes  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
204b88c807SRodney W. Grimes  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
214b88c807SRodney W. Grimes  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
224b88c807SRodney W. Grimes  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
234b88c807SRodney W. Grimes  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
244b88c807SRodney W. Grimes  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
254b88c807SRodney W. Grimes  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
264b88c807SRodney W. Grimes  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
274b88c807SRodney W. Grimes  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
284b88c807SRodney W. Grimes  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
294b88c807SRodney W. Grimes  * SUCH DAMAGE.
304b88c807SRodney W. Grimes  */
314b88c807SRodney W. Grimes 
324b88c807SRodney W. Grimes typedef struct {
3382fc0d09SDag-Erling Smørgrav 	int		 dir;		/* base directory handle */
34b3fe9014SDag-Erling Smørgrav 	char		 base[PATH_MAX + 1];	/* base directory path */
3582fc0d09SDag-Erling Smørgrav 	char		*end;		/* pointer to NUL at end of path */
3682fc0d09SDag-Erling Smørgrav 	char		 path[PATH_MAX];	/* target path */
374b88c807SRodney W. Grimes } PATH_T;
384b88c807SRodney W. Grimes 
394b88c807SRodney W. Grimes extern PATH_T to;
40*c3efa16dSDag-Erling Smørgrav extern bool Nflag, fflag, iflag, lflag, nflag, pflag, sflag, vflag;
41947193d9SMatthew N. Dodd extern volatile sig_atomic_t info;
424b88c807SRodney W. Grimes 
434b88c807SRodney W. Grimes __BEGIN_DECLS
4482fc0d09SDag-Erling Smørgrav int	copy_fifo(struct stat *, bool, bool);
4582fc0d09SDag-Erling Smørgrav int	copy_file(const FTSENT *, bool, bool);
4682fc0d09SDag-Erling Smørgrav int	copy_link(const FTSENT *, bool, bool);
4782fc0d09SDag-Erling Smørgrav int	copy_special(struct stat *, bool, bool);
4882fc0d09SDag-Erling Smørgrav int	setfile(struct stat *, int, bool);
4982fc0d09SDag-Erling Smørgrav int	preserve_dir_acls(const char *, const char *);
509b4261c9SChristian S.J. Peron int	preserve_fd_acls(int, int);
51e9746806SAlfonso Gregory void	usage(void) __dead2;
524b88c807SRodney W. Grimes __END_DECLS
5382fc0d09SDag-Erling Smørgrav 
5482fc0d09SDag-Erling Smørgrav /*
5582fc0d09SDag-Erling Smørgrav  * The FreeBSD and Darwin kernels return ENOTCAPABLE when a path lookup
5682fc0d09SDag-Erling Smørgrav  * violates a RESOLVE_BENEATH constraint.  This results in confusing error
5782fc0d09SDag-Erling Smørgrav  * messages, so translate it to the more widely recognized EACCES.
5882fc0d09SDag-Erling Smørgrav  */
5982fc0d09SDag-Erling Smørgrav #ifdef ENOTCAPABLE
6082fc0d09SDag-Erling Smørgrav #define warn(...)							\
6182fc0d09SDag-Erling Smørgrav 	warnc(errno == ENOTCAPABLE ? EACCES : errno, __VA_ARGS__)
6282fc0d09SDag-Erling Smørgrav #define err(rv, ...)							\
6382fc0d09SDag-Erling Smørgrav 	errc(rv, errno == ENOTCAPABLE ? EACCES : errno, __VA_ARGS__)
6482fc0d09SDag-Erling Smørgrav #endif
65