1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright 2003 Sun Microsystems, Inc. All rights reserved. 24*7c478bd9Sstevel@tonic-gate * Use is subject to license terms. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _BART_H 28*7c478bd9Sstevel@tonic-gate #define _BART_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 33*7c478bd9Sstevel@tonic-gate extern "C" { 34*7c478bd9Sstevel@tonic-gate #endif 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #include <stdio.h> 37*7c478bd9Sstevel@tonic-gate #include <stdlib.h> 38*7c478bd9Sstevel@tonic-gate #include <ctype.h> 39*7c478bd9Sstevel@tonic-gate #include <limits.h> 40*7c478bd9Sstevel@tonic-gate #include <sys/stat.h> 41*7c478bd9Sstevel@tonic-gate #include <strings.h> 42*7c478bd9Sstevel@tonic-gate #include <errno.h> 43*7c478bd9Sstevel@tonic-gate #include <fcntl.h> 44*7c478bd9Sstevel@tonic-gate #include <sys/types.h> 45*7c478bd9Sstevel@tonic-gate #include <md5.h> 46*7c478bd9Sstevel@tonic-gate #include <ftw.h> 47*7c478bd9Sstevel@tonic-gate #include <libintl.h> 48*7c478bd9Sstevel@tonic-gate #include "msgs.h" 49*7c478bd9Sstevel@tonic-gate 50*7c478bd9Sstevel@tonic-gate #define EXIT 0 51*7c478bd9Sstevel@tonic-gate #define WARNING_EXIT 1 52*7c478bd9Sstevel@tonic-gate #define FATAL_EXIT 2 53*7c478bd9Sstevel@tonic-gate 54*7c478bd9Sstevel@tonic-gate #define CHECK 0 55*7c478bd9Sstevel@tonic-gate #define NOCHECK 1 56*7c478bd9Sstevel@tonic-gate 57*7c478bd9Sstevel@tonic-gate #define CHECK_KEYWORD(s) (strcmp(s, "CHECK") == 0) 58*7c478bd9Sstevel@tonic-gate #define IGNORE_KEYWORD(s) (strcmp(s, "IGNORE") == 0) 59*7c478bd9Sstevel@tonic-gate 60*7c478bd9Sstevel@tonic-gate #define ALL_KEYWORD "all" 61*7c478bd9Sstevel@tonic-gate #define CONTENTS_KEYWORD "contents" 62*7c478bd9Sstevel@tonic-gate #define TYPE_KEYWORD "type" 63*7c478bd9Sstevel@tonic-gate #define SIZE_KEYWORD "size" 64*7c478bd9Sstevel@tonic-gate #define MODE_KEYWORD "mode" 65*7c478bd9Sstevel@tonic-gate #define ACL_KEYWORD "acl" 66*7c478bd9Sstevel@tonic-gate #define UID_KEYWORD "uid" 67*7c478bd9Sstevel@tonic-gate #define GID_KEYWORD "gid" 68*7c478bd9Sstevel@tonic-gate #define MTIME_KEYWORD "mtime" 69*7c478bd9Sstevel@tonic-gate #define LNMTIME_KEYWORD "lnmtime" 70*7c478bd9Sstevel@tonic-gate #define DIRMTIME_KEYWORD "dirmtime" 71*7c478bd9Sstevel@tonic-gate #define DEST_KEYWORD "dest" 72*7c478bd9Sstevel@tonic-gate #define DEVNODE_KEYWORD "devnode" 73*7c478bd9Sstevel@tonic-gate #define ADD_KEYWORD "add" 74*7c478bd9Sstevel@tonic-gate #define DELETE_KEYWORD "delete" 75*7c478bd9Sstevel@tonic-gate 76*7c478bd9Sstevel@tonic-gate #define MANIFEST_VER "! Version 1.0\n" 77*7c478bd9Sstevel@tonic-gate #define FORMAT_STR "# Format:\n\ 78*7c478bd9Sstevel@tonic-gate #fname D size mode acl dirmtime uid gid\n\ 79*7c478bd9Sstevel@tonic-gate #fname P size mode acl mtime uid gid\n\ 80*7c478bd9Sstevel@tonic-gate #fname S size mode acl mtime uid gid\n\ 81*7c478bd9Sstevel@tonic-gate #fname F size mode acl mtime uid gid contents\n\ 82*7c478bd9Sstevel@tonic-gate #fname L size mode acl lnmtime uid gid dest\n\ 83*7c478bd9Sstevel@tonic-gate #fname B size mode acl mtime uid gid devnode\n\ 84*7c478bd9Sstevel@tonic-gate #fname C size mode acl mtime uid gid devnode\n" 85*7c478bd9Sstevel@tonic-gate 86*7c478bd9Sstevel@tonic-gate /* 87*7c478bd9Sstevel@tonic-gate * size of buffer - used in several places 88*7c478bd9Sstevel@tonic-gate */ 89*7c478bd9Sstevel@tonic-gate #define BUF_SIZE 65536 90*7c478bd9Sstevel@tonic-gate 91*7c478bd9Sstevel@tonic-gate /* 92*7c478bd9Sstevel@tonic-gate * size of ACL buffer - used in several places 93*7c478bd9Sstevel@tonic-gate */ 94*7c478bd9Sstevel@tonic-gate #define ACL_SIZE 1024 95*7c478bd9Sstevel@tonic-gate 96*7c478bd9Sstevel@tonic-gate /* 97*7c478bd9Sstevel@tonic-gate * size of MISC buffer - used in several places 98*7c478bd9Sstevel@tonic-gate */ 99*7c478bd9Sstevel@tonic-gate #define MISC_SIZE 20 100*7c478bd9Sstevel@tonic-gate 101*7c478bd9Sstevel@tonic-gate /* 102*7c478bd9Sstevel@tonic-gate * size of TYPE buffer - used in several places 103*7c478bd9Sstevel@tonic-gate */ 104*7c478bd9Sstevel@tonic-gate #define TYPE_SIZE 2 105*7c478bd9Sstevel@tonic-gate 106*7c478bd9Sstevel@tonic-gate struct tree_modifier { 107*7c478bd9Sstevel@tonic-gate char *mod_str; 108*7c478bd9Sstevel@tonic-gate int include; 109*7c478bd9Sstevel@tonic-gate struct tree_modifier *next; 110*7c478bd9Sstevel@tonic-gate }; 111*7c478bd9Sstevel@tonic-gate 112*7c478bd9Sstevel@tonic-gate struct attr_keyword { 113*7c478bd9Sstevel@tonic-gate char *ak_name; 114*7c478bd9Sstevel@tonic-gate int ak_flags; 115*7c478bd9Sstevel@tonic-gate }; 116*7c478bd9Sstevel@tonic-gate 117*7c478bd9Sstevel@tonic-gate 118*7c478bd9Sstevel@tonic-gate #define ATTR_ALL ((uint_t)~0) 119*7c478bd9Sstevel@tonic-gate #define ATTR_CONTENTS 0x0001 120*7c478bd9Sstevel@tonic-gate #define ATTR_TYPE 0x0002 121*7c478bd9Sstevel@tonic-gate #define ATTR_SIZE 0x0004 122*7c478bd9Sstevel@tonic-gate #define ATTR_MODE 0x0008 123*7c478bd9Sstevel@tonic-gate #define ATTR_UID 0x0010 124*7c478bd9Sstevel@tonic-gate #define ATTR_GID 0x0020 125*7c478bd9Sstevel@tonic-gate #define ATTR_ACL 0x0040 126*7c478bd9Sstevel@tonic-gate #define ATTR_DEST 0x0080 127*7c478bd9Sstevel@tonic-gate #define ATTR_DEVNODE 0x0100 128*7c478bd9Sstevel@tonic-gate #define ATTR_MTIME 0x0200 129*7c478bd9Sstevel@tonic-gate #define ATTR_LNMTIME 0x0400 130*7c478bd9Sstevel@tonic-gate #define ATTR_DIRMTIME 0x0800 131*7c478bd9Sstevel@tonic-gate #define ATTR_ADD 0x1000 132*7c478bd9Sstevel@tonic-gate #define ATTR_DELETE 0x2000 133*7c478bd9Sstevel@tonic-gate 134*7c478bd9Sstevel@tonic-gate struct rule { 135*7c478bd9Sstevel@tonic-gate char subtree[PATH_MAX]; 136*7c478bd9Sstevel@tonic-gate uint_t attr_list; 137*7c478bd9Sstevel@tonic-gate struct tree_modifier *modifiers; 138*7c478bd9Sstevel@tonic-gate struct rule *next; 139*7c478bd9Sstevel@tonic-gate struct rule *prev; 140*7c478bd9Sstevel@tonic-gate boolean_t traversed; 141*7c478bd9Sstevel@tonic-gate }; 142*7c478bd9Sstevel@tonic-gate 143*7c478bd9Sstevel@tonic-gate struct dir_component { 144*7c478bd9Sstevel@tonic-gate char dirname[PATH_MAX]; 145*7c478bd9Sstevel@tonic-gate struct dir_component *next; 146*7c478bd9Sstevel@tonic-gate }; 147*7c478bd9Sstevel@tonic-gate 148*7c478bd9Sstevel@tonic-gate 149*7c478bd9Sstevel@tonic-gate struct attr_keyword *attr_keylookup(char *); 150*7c478bd9Sstevel@tonic-gate void usage(void); 151*7c478bd9Sstevel@tonic-gate int bart_create(int, char **); 152*7c478bd9Sstevel@tonic-gate int bart_compare(int, char **); 153*7c478bd9Sstevel@tonic-gate struct rule *check_rules(const char *, char); 154*7c478bd9Sstevel@tonic-gate int exclude_fname(const char *, char, struct rule *); 155*7c478bd9Sstevel@tonic-gate struct rule *get_first_subtree(void); 156*7c478bd9Sstevel@tonic-gate struct rule *get_next_subtree(struct rule *); 157*7c478bd9Sstevel@tonic-gate void process_glob_ignores(char *, uint_t *); 158*7c478bd9Sstevel@tonic-gate void *safe_calloc(size_t); 159*7c478bd9Sstevel@tonic-gate char *safe_strdup(char *); 160*7c478bd9Sstevel@tonic-gate int read_rules(FILE *, char *, uint_t, int); 161*7c478bd9Sstevel@tonic-gate int read_line(FILE *, char *, int, int, char **, char *); 162*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 163*7c478bd9Sstevel@tonic-gate } 164*7c478bd9Sstevel@tonic-gate #endif 165*7c478bd9Sstevel@tonic-gate 166*7c478bd9Sstevel@tonic-gate #endif /* _BART_H */ 167