17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*9c84d166Srm88369 * Common Development and Distribution License (the "License"). 6*9c84d166Srm88369 * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*9c84d166Srm88369 * Copyright 2006 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #ifndef _BART_H 277c478bd9Sstevel@tonic-gate #define _BART_H 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate #ifdef __cplusplus 327c478bd9Sstevel@tonic-gate extern "C" { 337c478bd9Sstevel@tonic-gate #endif 347c478bd9Sstevel@tonic-gate 357c478bd9Sstevel@tonic-gate #include <stdio.h> 367c478bd9Sstevel@tonic-gate #include <stdlib.h> 377c478bd9Sstevel@tonic-gate #include <ctype.h> 387c478bd9Sstevel@tonic-gate #include <limits.h> 397c478bd9Sstevel@tonic-gate #include <sys/stat.h> 407c478bd9Sstevel@tonic-gate #include <strings.h> 417c478bd9Sstevel@tonic-gate #include <errno.h> 427c478bd9Sstevel@tonic-gate #include <fcntl.h> 437c478bd9Sstevel@tonic-gate #include <sys/types.h> 447c478bd9Sstevel@tonic-gate #include <md5.h> 457c478bd9Sstevel@tonic-gate #include <ftw.h> 467c478bd9Sstevel@tonic-gate #include <libintl.h> 477c478bd9Sstevel@tonic-gate #include "msgs.h" 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate #define EXIT 0 507c478bd9Sstevel@tonic-gate #define WARNING_EXIT 1 517c478bd9Sstevel@tonic-gate #define FATAL_EXIT 2 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate #define CHECK 0 547c478bd9Sstevel@tonic-gate #define NOCHECK 1 557c478bd9Sstevel@tonic-gate 567c478bd9Sstevel@tonic-gate #define CHECK_KEYWORD(s) (strcmp(s, "CHECK") == 0) 577c478bd9Sstevel@tonic-gate #define IGNORE_KEYWORD(s) (strcmp(s, "IGNORE") == 0) 587c478bd9Sstevel@tonic-gate 597c478bd9Sstevel@tonic-gate #define ALL_KEYWORD "all" 607c478bd9Sstevel@tonic-gate #define CONTENTS_KEYWORD "contents" 617c478bd9Sstevel@tonic-gate #define TYPE_KEYWORD "type" 627c478bd9Sstevel@tonic-gate #define SIZE_KEYWORD "size" 637c478bd9Sstevel@tonic-gate #define MODE_KEYWORD "mode" 647c478bd9Sstevel@tonic-gate #define ACL_KEYWORD "acl" 657c478bd9Sstevel@tonic-gate #define UID_KEYWORD "uid" 667c478bd9Sstevel@tonic-gate #define GID_KEYWORD "gid" 677c478bd9Sstevel@tonic-gate #define MTIME_KEYWORD "mtime" 687c478bd9Sstevel@tonic-gate #define LNMTIME_KEYWORD "lnmtime" 697c478bd9Sstevel@tonic-gate #define DIRMTIME_KEYWORD "dirmtime" 707c478bd9Sstevel@tonic-gate #define DEST_KEYWORD "dest" 717c478bd9Sstevel@tonic-gate #define DEVNODE_KEYWORD "devnode" 727c478bd9Sstevel@tonic-gate #define ADD_KEYWORD "add" 737c478bd9Sstevel@tonic-gate #define DELETE_KEYWORD "delete" 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate #define MANIFEST_VER "! Version 1.0\n" 767c478bd9Sstevel@tonic-gate #define FORMAT_STR "# Format:\n\ 777c478bd9Sstevel@tonic-gate #fname D size mode acl dirmtime uid gid\n\ 787c478bd9Sstevel@tonic-gate #fname P size mode acl mtime uid gid\n\ 797c478bd9Sstevel@tonic-gate #fname S size mode acl mtime uid gid\n\ 807c478bd9Sstevel@tonic-gate #fname F size mode acl mtime uid gid contents\n\ 817c478bd9Sstevel@tonic-gate #fname L size mode acl lnmtime uid gid dest\n\ 827c478bd9Sstevel@tonic-gate #fname B size mode acl mtime uid gid devnode\n\ 837c478bd9Sstevel@tonic-gate #fname C size mode acl mtime uid gid devnode\n" 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate /* 867c478bd9Sstevel@tonic-gate * size of buffer - used in several places 877c478bd9Sstevel@tonic-gate */ 887c478bd9Sstevel@tonic-gate #define BUF_SIZE 65536 897c478bd9Sstevel@tonic-gate 907c478bd9Sstevel@tonic-gate /* 917c478bd9Sstevel@tonic-gate * size of ACL buffer - used in several places 927c478bd9Sstevel@tonic-gate */ 937c478bd9Sstevel@tonic-gate #define ACL_SIZE 1024 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate /* 967c478bd9Sstevel@tonic-gate * size of MISC buffer - used in several places 977c478bd9Sstevel@tonic-gate */ 987c478bd9Sstevel@tonic-gate #define MISC_SIZE 20 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate /* 1017c478bd9Sstevel@tonic-gate * size of TYPE buffer - used in several places 1027c478bd9Sstevel@tonic-gate */ 1037c478bd9Sstevel@tonic-gate #define TYPE_SIZE 2 1047c478bd9Sstevel@tonic-gate 1057c478bd9Sstevel@tonic-gate struct tree_modifier { 1067c478bd9Sstevel@tonic-gate char *mod_str; 1077c478bd9Sstevel@tonic-gate int include; 1087c478bd9Sstevel@tonic-gate struct tree_modifier *next; 1097c478bd9Sstevel@tonic-gate }; 1107c478bd9Sstevel@tonic-gate 1117c478bd9Sstevel@tonic-gate struct attr_keyword { 1127c478bd9Sstevel@tonic-gate char *ak_name; 1137c478bd9Sstevel@tonic-gate int ak_flags; 1147c478bd9Sstevel@tonic-gate }; 1157c478bd9Sstevel@tonic-gate 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate #define ATTR_ALL ((uint_t)~0) 1187c478bd9Sstevel@tonic-gate #define ATTR_CONTENTS 0x0001 1197c478bd9Sstevel@tonic-gate #define ATTR_TYPE 0x0002 1207c478bd9Sstevel@tonic-gate #define ATTR_SIZE 0x0004 1217c478bd9Sstevel@tonic-gate #define ATTR_MODE 0x0008 1227c478bd9Sstevel@tonic-gate #define ATTR_UID 0x0010 1237c478bd9Sstevel@tonic-gate #define ATTR_GID 0x0020 1247c478bd9Sstevel@tonic-gate #define ATTR_ACL 0x0040 1257c478bd9Sstevel@tonic-gate #define ATTR_DEST 0x0080 1267c478bd9Sstevel@tonic-gate #define ATTR_DEVNODE 0x0100 1277c478bd9Sstevel@tonic-gate #define ATTR_MTIME 0x0200 1287c478bd9Sstevel@tonic-gate #define ATTR_LNMTIME 0x0400 1297c478bd9Sstevel@tonic-gate #define ATTR_DIRMTIME 0x0800 1307c478bd9Sstevel@tonic-gate #define ATTR_ADD 0x1000 1317c478bd9Sstevel@tonic-gate #define ATTR_DELETE 0x2000 1327c478bd9Sstevel@tonic-gate 1337c478bd9Sstevel@tonic-gate struct rule { 1347c478bd9Sstevel@tonic-gate char subtree[PATH_MAX]; 1357c478bd9Sstevel@tonic-gate uint_t attr_list; 1367c478bd9Sstevel@tonic-gate struct tree_modifier *modifiers; 1377c478bd9Sstevel@tonic-gate struct rule *next; 1387c478bd9Sstevel@tonic-gate struct rule *prev; 1397c478bd9Sstevel@tonic-gate }; 1407c478bd9Sstevel@tonic-gate 1417c478bd9Sstevel@tonic-gate struct dir_component { 1427c478bd9Sstevel@tonic-gate char dirname[PATH_MAX]; 1437c478bd9Sstevel@tonic-gate struct dir_component *next; 1447c478bd9Sstevel@tonic-gate }; 1457c478bd9Sstevel@tonic-gate 1467c478bd9Sstevel@tonic-gate 1477c478bd9Sstevel@tonic-gate struct attr_keyword *attr_keylookup(char *); 1487c478bd9Sstevel@tonic-gate void usage(void); 1497c478bd9Sstevel@tonic-gate int bart_create(int, char **); 1507c478bd9Sstevel@tonic-gate int bart_compare(int, char **); 1517c478bd9Sstevel@tonic-gate struct rule *check_rules(const char *, char); 1527c478bd9Sstevel@tonic-gate int exclude_fname(const char *, char, struct rule *); 1537c478bd9Sstevel@tonic-gate struct rule *get_first_subtree(void); 1547c478bd9Sstevel@tonic-gate struct rule *get_next_subtree(struct rule *); 1557c478bd9Sstevel@tonic-gate void process_glob_ignores(char *, uint_t *); 1567c478bd9Sstevel@tonic-gate void *safe_calloc(size_t); 1577c478bd9Sstevel@tonic-gate char *safe_strdup(char *); 1587c478bd9Sstevel@tonic-gate int read_rules(FILE *, char *, uint_t, int); 1597c478bd9Sstevel@tonic-gate int read_line(FILE *, char *, int, int, char **, char *); 1607c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1617c478bd9Sstevel@tonic-gate } 1627c478bd9Sstevel@tonic-gate #endif 1637c478bd9Sstevel@tonic-gate 1647c478bd9Sstevel@tonic-gate #endif /* _BART_H */ 165