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