xref: /illumos-gate/usr/src/cmd/filesync/filesync.h (revision dfc115332c94a2f62058ac7f2bce7631fbd20b3d)
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 #pragma ident	"%W%	%E% SMI"
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 #include <sys/types.h>
43 
44 /*
45  * arbitrary limits
46  */
47 #define	MAX_NAME	256		/* longest path component	*/
48 #define	MAX_PATH	1024		/* longest total path length	*/
49 #define	MAX_RLIST	32		/* max number of -r arguments	*/
50 #define	MAX_LINE	1024		/* longest input line		*/
51 #define	MAX_DEPTH	20		/* how deep to recurse		*/
52 #define	COPY_BSIZE	8192		/* block size for file copies	*/
53 #define	MIN_HOLE	1024		/* minimum hole in sparse file	*/
54 #define	HASH_SIZE	99		/* ignore list hash table	*/
55 
56 /*
57  * sanity check limits
58  */
59 #define	CONFIRM_MIN	4		/* min # deletetes to confirm	*/
60 #define	CONFIRM_PCT	25		/* min pctg of files to confirm	*/
61 
62 /*
63  * special types used in the program
64  */
65 typedef enum {
66 	FALSE = 0,
67 	TRUE  = 1,
68 	MAYBE = 2			/* only partially true		*/
69 } bool_t;
70 
71 typedef enum {
72 	OPT_BASE = 0,			/* use the baseline data	*/
73 	OPT_SRC = 1,			/* use the source side		*/
74 	OPT_DST = 2,			/* use the destination side	*/
75 	OPT_OLD = 3,			/* use the old one		*/
76 	OPT_NEW = 4			/* use the new one		*/
77 } side_t;
78 
79 /*
80  * values for debug mask
81  */
82 typedef	long dbgmask_t;			/* type for debug masks		*/
83 #define	DBG_BASE	0x0001		/* baseline changes		*/
84 #define	DBG_RULE	0x0002		/* rule base changes		*/
85 #define	DBG_STAT	0x0004		/* file stats			*/
86 #define	DBG_ANAL	0x0008		/* analysis tracing		*/
87 #define	DBG_RECON	0x0010		/* reconciliation tracing	*/
88 #define	DBG_VARS	0x0020		/* variable tracing		*/
89 #define	DBG_FILES	0x0040		/* file reading/writing		*/
90 #define	DBG_LIST	0x0080		/* include list building	*/
91 #define	DBG_EVAL	0x0100		/* evaluation tracing		*/
92 #define	DBG_IGNORE	0x0200		/* ignore tracing		*/
93 #define	DBG_MISC	0x0400		/* catch-all everything else	*/
94 
95 /*
96  * values for error codes
97  */
98 typedef int errmask_t;			/* type for error masks		*/
99 #define	ERR_OK		0		/* everything is fine		*/
100 #define	ERR_RESOLVABLE	1		/* resolvable conflicts		*/
101 #define	ERR_UNRESOLVED	2		/* unresolvable conflicts	*/
102 #define	ERR_MISSING	4		/* some files missing		*/
103 #define	ERR_PERM	8		/* insufficient access		*/
104 #define	ERR_FILES	16		/* file format or I/O errors	*/
105 #define	ERR_INVAL	32		/* invalid arguments		*/
106 #define	ERR_NOBASE	64		/* inaccessable base directory	*/
107 #define	ERR_OTHER	128		/* anything else		*/
108 
109 /* errors that will prevent reconciliation from taking place		*/
110 #define	ERR_FATAL	(ERR_FILES|ERR_INVAL|ERR_NOBASE|ERR_OTHER)
111 
112 /* errors that will cause reconciliation to stop with -h specified	*/
113 #define	ERR_ABORT	(ERR_FILES|ERR_PERM)
114 
115 /*
116  * program defaults
117  */
118 #define	DFLT_PRFX	"$HOME/"		/* default location/pfx	*/
119 #define	SUFX_RULES	".packingrules"		/* rules v1.1 location	*/
120 #define	SUFX_BASE	".filesync-base"	/* baseline location	*/
121 #define	SUFX_OLD	".filesync-rules"	/* rules v1.0 location	*/
122 
123 /*
124  * global variables for command line options
125  */
126 extern bool_t  opt_acls;	/* enable acl checking/preservation	*/
127 extern bool_t  opt_mtime;	/* preserve modification times		*/
128 extern bool_t  opt_notouch;	/* don't actually make any changes	*/
129 extern side_t  opt_force;	/* designated winner for conflicts	*/
130 extern side_t  opt_oneway;	/* one way only propagation		*/
131 extern side_t  opt_onesided;	/* permit one sided analysis		*/
132 extern bool_t  opt_everything;	/* everything must agree (modes/uid/gid) */
133 extern bool_t  opt_quiet;	/* stiffle reconciliaton descriptions	*/
134 extern bool_t  opt_verbose;	/* generate analysis commentary		*/
135 extern bool_t  opt_errors;	/* simulate errors on specified files	*/
136 extern bool_t  opt_halt;	/* halt on any propagation error	*/
137 extern dbgmask_t opt_debug;	/* debugging options			*/
138 
139 /*
140  * information gained during startup that other people may need
141  */
142 extern uid_t my_uid;	/* User ID for files I create			*/
143 extern gid_t my_gid;	/* Group ID for files I create			*/
144 
145 /* error and warning routines						*/
146 void confirm(char *);		/* ask user if they're sure		*/
147 void nomem(char *);		/* die from malloc failure		*/
148 
149 /* routines for dealing with strings and file names			*/
150 const char *prefix(const char *, const char *); /* does s1 begin with s2 */
151 char *qualify(char *);		/* validate and fully qualify		*/
152 char *expand(char *);		/* expand variables in name		*/
153 char *lex(FILE *);		/* lex off one token			*/
154 extern int lex_linenum;		/* current input file line number	*/
155 const char *noblanks(const char *);	/* escape strings for embedded blanks */
156 bool_t wildcards(const char *);	/* does name contain wildcards		*/
157 bool_t suffix(const char *, const char *);	/* does s1 end with s2	*/
158 bool_t contains(const char *, const char *);	/* does s1 contain s2	*/
159 
160 #ifdef	__cplusplus
161 }
162 #endif
163 
164 #endif	/* _FILESYNC_H */
165