xref: /onnv-gate/usr/src/cmd/bart/bart.h (revision 13116:4fa15249a57b)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
52813Srm88369  * Common Development and Distribution License (the "License").
62813Srm88369  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
22*13116SJan.Parcel@Sun.COM  * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
230Sstevel@tonic-gate  */
240Sstevel@tonic-gate 
250Sstevel@tonic-gate #ifndef	_BART_H
260Sstevel@tonic-gate #define	_BART_H
270Sstevel@tonic-gate 
280Sstevel@tonic-gate #ifdef	__cplusplus
290Sstevel@tonic-gate extern "C" {
300Sstevel@tonic-gate #endif
310Sstevel@tonic-gate 
320Sstevel@tonic-gate #include <stdio.h>
330Sstevel@tonic-gate #include <stdlib.h>
340Sstevel@tonic-gate #include <ctype.h>
350Sstevel@tonic-gate #include <limits.h>
360Sstevel@tonic-gate #include <sys/stat.h>
370Sstevel@tonic-gate #include <strings.h>
380Sstevel@tonic-gate #include <errno.h>
390Sstevel@tonic-gate #include <fcntl.h>
400Sstevel@tonic-gate #include <sys/types.h>
410Sstevel@tonic-gate #include <md5.h>
420Sstevel@tonic-gate #include <ftw.h>
430Sstevel@tonic-gate #include <libintl.h>
440Sstevel@tonic-gate #include "msgs.h"
450Sstevel@tonic-gate 
460Sstevel@tonic-gate #define	EXIT		0
470Sstevel@tonic-gate #define	WARNING_EXIT	1
480Sstevel@tonic-gate #define	FATAL_EXIT	2
490Sstevel@tonic-gate 
50*13116SJan.Parcel@Sun.COM #define	NO_EXCLUDE	0
51*13116SJan.Parcel@Sun.COM #define	EXCLUDE_SKIP	1
52*13116SJan.Parcel@Sun.COM #define	EXCLUDE_PRUNE	2
53*13116SJan.Parcel@Sun.COM 
540Sstevel@tonic-gate #define	CHECK		0
550Sstevel@tonic-gate #define	NOCHECK		1
560Sstevel@tonic-gate 
570Sstevel@tonic-gate #define	CHECK_KEYWORD(s)	(strcmp(s, "CHECK") == 0)
580Sstevel@tonic-gate #define	IGNORE_KEYWORD(s)	(strcmp(s, "IGNORE") == 0)
590Sstevel@tonic-gate 
600Sstevel@tonic-gate #define	ALL_KEYWORD		"all"
610Sstevel@tonic-gate #define	CONTENTS_KEYWORD	"contents"
620Sstevel@tonic-gate #define	TYPE_KEYWORD		"type"
630Sstevel@tonic-gate #define	SIZE_KEYWORD		"size"
640Sstevel@tonic-gate #define	MODE_KEYWORD		"mode"
650Sstevel@tonic-gate #define	ACL_KEYWORD		"acl"
660Sstevel@tonic-gate #define	UID_KEYWORD		"uid"
670Sstevel@tonic-gate #define	GID_KEYWORD		"gid"
680Sstevel@tonic-gate #define	MTIME_KEYWORD		"mtime"
690Sstevel@tonic-gate #define	LNMTIME_KEYWORD		"lnmtime"
700Sstevel@tonic-gate #define	DIRMTIME_KEYWORD	"dirmtime"
710Sstevel@tonic-gate #define	DEST_KEYWORD		"dest"
720Sstevel@tonic-gate #define	DEVNODE_KEYWORD		"devnode"
730Sstevel@tonic-gate #define	ADD_KEYWORD		"add"
740Sstevel@tonic-gate #define	DELETE_KEYWORD		"delete"
750Sstevel@tonic-gate 
760Sstevel@tonic-gate #define	MANIFEST_VER	"! Version 1.0\n"
770Sstevel@tonic-gate #define	FORMAT_STR	"# Format:\n\
780Sstevel@tonic-gate #fname D size mode acl dirmtime uid gid\n\
790Sstevel@tonic-gate #fname P size mode acl mtime uid gid\n\
800Sstevel@tonic-gate #fname S size mode acl mtime uid gid\n\
810Sstevel@tonic-gate #fname F size mode acl mtime uid gid contents\n\
820Sstevel@tonic-gate #fname L size mode acl lnmtime uid gid dest\n\
830Sstevel@tonic-gate #fname B size mode acl mtime uid gid devnode\n\
840Sstevel@tonic-gate #fname C size mode acl mtime uid gid devnode\n"
850Sstevel@tonic-gate 
860Sstevel@tonic-gate /*
870Sstevel@tonic-gate  * size of buffer - used in several places
880Sstevel@tonic-gate  */
890Sstevel@tonic-gate #define	BUF_SIZE	65536
900Sstevel@tonic-gate 
910Sstevel@tonic-gate /*
920Sstevel@tonic-gate  * size of ACL buffer - used in several places
930Sstevel@tonic-gate  */
940Sstevel@tonic-gate #define	ACL_SIZE	1024
950Sstevel@tonic-gate 
960Sstevel@tonic-gate /*
970Sstevel@tonic-gate  * size of MISC buffer - used in several places
980Sstevel@tonic-gate  */
990Sstevel@tonic-gate #define	MISC_SIZE	20
1000Sstevel@tonic-gate 
1010Sstevel@tonic-gate /*
1020Sstevel@tonic-gate  * size of TYPE buffer - used in several places
1030Sstevel@tonic-gate  */
1040Sstevel@tonic-gate #define	TYPE_SIZE	2
1050Sstevel@tonic-gate 
1060Sstevel@tonic-gate struct tree_modifier {
1070Sstevel@tonic-gate 	char			*mod_str;
108*13116SJan.Parcel@Sun.COM 	boolean_t		include;
109*13116SJan.Parcel@Sun.COM 	boolean_t		is_dir;
1100Sstevel@tonic-gate 	struct tree_modifier	*next;
1110Sstevel@tonic-gate };
1120Sstevel@tonic-gate 
1130Sstevel@tonic-gate struct attr_keyword {
1140Sstevel@tonic-gate 	char    *ak_name;
1150Sstevel@tonic-gate 	int	ak_flags;
1160Sstevel@tonic-gate };
1170Sstevel@tonic-gate 
1180Sstevel@tonic-gate 
1190Sstevel@tonic-gate #define	ATTR_ALL ((uint_t)~0)
1200Sstevel@tonic-gate #define	ATTR_CONTENTS 0x0001
1210Sstevel@tonic-gate #define	ATTR_TYPE 0x0002
1220Sstevel@tonic-gate #define	ATTR_SIZE 0x0004
1230Sstevel@tonic-gate #define	ATTR_MODE 0x0008
1240Sstevel@tonic-gate #define	ATTR_UID 0x0010
1250Sstevel@tonic-gate #define	ATTR_GID 0x0020
1260Sstevel@tonic-gate #define	ATTR_ACL 0x0040
1270Sstevel@tonic-gate #define	ATTR_DEST 0x0080
1280Sstevel@tonic-gate #define	ATTR_DEVNODE 0x0100
1290Sstevel@tonic-gate #define	ATTR_MTIME 0x0200
1300Sstevel@tonic-gate #define	ATTR_LNMTIME 0x0400
1310Sstevel@tonic-gate #define	ATTR_DIRMTIME 0x0800
1320Sstevel@tonic-gate #define	ATTR_ADD 0x1000
1330Sstevel@tonic-gate #define	ATTR_DELETE 0x2000
1340Sstevel@tonic-gate 
1350Sstevel@tonic-gate struct rule {
1360Sstevel@tonic-gate 	char			subtree[PATH_MAX];
1370Sstevel@tonic-gate 	uint_t			attr_list;
1380Sstevel@tonic-gate 	struct tree_modifier	*modifiers;
1390Sstevel@tonic-gate 	struct rule		*next;
1400Sstevel@tonic-gate 	struct rule		*prev;
1410Sstevel@tonic-gate };
1420Sstevel@tonic-gate 
1430Sstevel@tonic-gate struct dir_component {
1440Sstevel@tonic-gate 	char			dirname[PATH_MAX];
1450Sstevel@tonic-gate 	struct dir_component	*next;
1460Sstevel@tonic-gate };
1470Sstevel@tonic-gate 
1480Sstevel@tonic-gate 
1490Sstevel@tonic-gate struct attr_keyword *attr_keylookup(char *);
1500Sstevel@tonic-gate void usage(void);
1510Sstevel@tonic-gate int bart_create(int, char **);
1520Sstevel@tonic-gate int bart_compare(int, char **);
1530Sstevel@tonic-gate struct rule *check_rules(const char *, char);
1540Sstevel@tonic-gate int exclude_fname(const char *, char, struct rule *);
1550Sstevel@tonic-gate struct rule *get_first_subtree(void);
1560Sstevel@tonic-gate struct rule *get_next_subtree(struct rule *);
1570Sstevel@tonic-gate void process_glob_ignores(char *, uint_t *);
1580Sstevel@tonic-gate void *safe_calloc(size_t);
1590Sstevel@tonic-gate char *safe_strdup(char *);
1600Sstevel@tonic-gate int read_rules(FILE *, char *, uint_t, int);
1610Sstevel@tonic-gate int read_line(FILE *, char *, int, int, char **, char *);
1620Sstevel@tonic-gate #ifdef	__cplusplus
1630Sstevel@tonic-gate }
1640Sstevel@tonic-gate #endif
1650Sstevel@tonic-gate 
1660Sstevel@tonic-gate #endif	/* _BART_H */
167