xref: /illumos-gate/usr/src/cmd/filesync/filesync.h (revision 2a8bcb4efb45d99ac41c94a75c396b362c414f7f)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1996 Sun Microsystems, Inc.  All Rights Reserved
24  * Copyright (c) 2016 by Delphix. All rights reserved.
25  *
26  * module:
27  *	filesync.h
28  *
29  * purpose:
30  *	general defines for use throughout the program
31  */
32 
33 #ifndef	_FILESYNC_H
34 #define	_FILESYNC_H
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 #include <sys/types.h>
41 
42 /*
43  * arbitrary limits
44  */
45 #define	MAX_NAME	256		/* longest path component	*/
46 #define	MAX_PATH	1024		/* longest total path length	*/
47 #define	MAX_RLIST	32		/* max number of -r arguments	*/
48 #define	MAX_LINE	1024		/* longest input line		*/
49 #define	MAX_DEPTH	20		/* how deep to recurse		*/
50 #define	COPY_BSIZE	8192		/* block size for file copies	*/
51 #define	MIN_HOLE	1024		/* minimum hole in sparse file	*/
52 #define	HASH_SIZE	99		/* ignore list hash table	*/
53 
54 /*
55  * sanity check limits
56  */
57 #define	CONFIRM_MIN	4		/* min # deletetes to confirm	*/
58 #define	CONFIRM_PCT	25		/* min pctg of files to confirm	*/
59 
60 /*
61  * special types used in the program
62  */
63 typedef enum {
64 	FALSE = 0,
65 	TRUE  = 1,
66 	MAYBE = 2			/* only partially true		*/
67 } bool_t;
68 
69 typedef enum {
70 	OPT_BASE = 0,			/* use the baseline data	*/
71 	OPT_SRC = 1,			/* use the source side		*/
72 	OPT_DST = 2,			/* use the destination side	*/
73 	OPT_OLD = 3,			/* use the old one		*/
74 	OPT_NEW = 4			/* use the new one		*/
75 } side_t;
76 
77 /*
78  * values for debug mask
79  */
80 typedef	long dbgmask_t;			/* type for debug masks		*/
81 #define	DBG_BASE	0x0001		/* baseline changes		*/
82 #define	DBG_RULE	0x0002		/* rule base changes		*/
83 #define	DBG_STAT	0x0004		/* file stats			*/
84 #define	DBG_ANAL	0x0008		/* analysis tracing		*/
85 #define	DBG_RECON	0x0010		/* reconciliation tracing	*/
86 #define	DBG_VARS	0x0020		/* variable tracing		*/
87 #define	DBG_FILES	0x0040		/* file reading/writing		*/
88 #define	DBG_LIST	0x0080		/* include list building	*/
89 #define	DBG_EVAL	0x0100		/* evaluation tracing		*/
90 #define	DBG_IGNORE	0x0200		/* ignore tracing		*/
91 #define	DBG_MISC	0x0400		/* catch-all everything else	*/
92 
93 /*
94  * values for error codes
95  */
96 typedef int errmask_t;			/* type for error masks		*/
97 #define	ERR_OK		0		/* everything is fine		*/
98 #define	ERR_RESOLVABLE	1		/* resolvable conflicts		*/
99 #define	ERR_UNRESOLVED	2		/* unresolvable conflicts	*/
100 #define	ERR_MISSING	4		/* some files missing		*/
101 #define	ERR_PERM	8		/* insufficient access		*/
102 #define	ERR_FILES	16		/* file format or I/O errors	*/
103 #define	ERR_INVAL	32		/* invalid arguments		*/
104 #define	ERR_NOBASE	64		/* inaccessable base directory	*/
105 #define	ERR_OTHER	128		/* anything else		*/
106 
107 /* errors that will prevent reconciliation from taking place		*/
108 #define	ERR_FATAL	(ERR_FILES|ERR_INVAL|ERR_NOBASE|ERR_OTHER)
109 
110 /* errors that will cause reconciliation to stop with -h specified	*/
111 #define	ERR_ABORT	(ERR_FILES|ERR_PERM)
112 
113 /*
114  * program defaults
115  */
116 #define	DFLT_PRFX	"$HOME/"		/* default location/pfx	*/
117 #define	SUFX_RULES	".packingrules"		/* rules v1.1 location	*/
118 #define	SUFX_BASE	".filesync-base"	/* baseline location	*/
119 #define	SUFX_OLD	".filesync-rules"	/* rules v1.0 location	*/
120 
121 /*
122  * global variables for command line options
123  */
124 extern bool_t  opt_acls;	/* enable acl checking/preservation	*/
125 extern bool_t  opt_mtime;	/* preserve modification times		*/
126 extern bool_t  opt_notouch;	/* don't actually make any changes	*/
127 extern side_t  opt_force;	/* designated winner for conflicts	*/
128 extern side_t  opt_oneway;	/* one way only propagation		*/
129 extern side_t  opt_onesided;	/* permit one sided analysis		*/
130 extern bool_t  opt_everything;	/* everything must agree (modes/uid/gid) */
131 extern bool_t  opt_quiet;	/* stiffle reconciliaton descriptions	*/
132 extern bool_t  opt_verbose;	/* generate analysis commentary		*/
133 extern bool_t  opt_errors;	/* simulate errors on specified files	*/
134 extern bool_t  opt_halt;	/* halt on any propagation error	*/
135 extern dbgmask_t opt_debug;	/* debugging options			*/
136 
137 /*
138  * information gained during startup that other people may need
139  */
140 extern uid_t my_uid;	/* User ID for files I create			*/
141 extern gid_t my_gid;	/* Group ID for files I create			*/
142 
143 /* error and warning routines						*/
144 void confirm(char *);		/* ask user if they're sure		*/
145 void nomem(char *);		/* die from malloc failure		*/
146 
147 /* routines for dealing with strings and file names			*/
148 const char *prefix(const char *, const char *); /* does s1 begin with s2 */
149 char *qualify(char *);		/* validate and fully qualify		*/
150 char *expand(char *);		/* expand variables in name		*/
151 char *lex(FILE *);		/* lex off one token			*/
152 extern int lex_linenum;		/* current input file line number	*/
153 const char *noblanks(const char *);	/* escape strings for embedded blanks */
154 bool_t wildcards(const char *);	/* does name contain wildcards		*/
155 bool_t suffix(const char *, const char *);	/* does s1 end with s2	*/
156 bool_t contains(const char *, const char *);	/* does s1 contain s2	*/
157 
158 #ifdef	__cplusplus
159 }
160 #endif
161 
162 #endif	/* _FILESYNC_H */
163