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 57c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 67c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 77c478bd9Sstevel@tonic-gate * with the License. 87c478bd9Sstevel@tonic-gate * 97c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 107c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 117c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 127c478bd9Sstevel@tonic-gate * and limitations under the License. 137c478bd9Sstevel@tonic-gate * 147c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 157c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 167c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 177c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 187c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 197c478bd9Sstevel@tonic-gate * 207c478bd9Sstevel@tonic-gate * CDDL HEADER END 217c478bd9Sstevel@tonic-gate */ 227c478bd9Sstevel@tonic-gate /* 237c478bd9Sstevel@tonic-gate * Copyright (c) 1996 Sun Microsystems, Inc. All Rights Reserved 24*48bbca81SDaniel Hoffman * Copyright (c) 2016 by Delphix. All rights reserved. 257c478bd9Sstevel@tonic-gate * 267c478bd9Sstevel@tonic-gate * module: 277c478bd9Sstevel@tonic-gate * filesync.h 287c478bd9Sstevel@tonic-gate * 297c478bd9Sstevel@tonic-gate * purpose: 307c478bd9Sstevel@tonic-gate * general defines for use throughout the program 317c478bd9Sstevel@tonic-gate */ 327c478bd9Sstevel@tonic-gate 337c478bd9Sstevel@tonic-gate #ifndef _FILESYNC_H 347c478bd9Sstevel@tonic-gate #define _FILESYNC_H 357c478bd9Sstevel@tonic-gate 367c478bd9Sstevel@tonic-gate #ifdef __cplusplus 377c478bd9Sstevel@tonic-gate extern "C" { 387c478bd9Sstevel@tonic-gate #endif 397c478bd9Sstevel@tonic-gate 407c478bd9Sstevel@tonic-gate #include <sys/types.h> 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate /* 437c478bd9Sstevel@tonic-gate * arbitrary limits 447c478bd9Sstevel@tonic-gate */ 457c478bd9Sstevel@tonic-gate #define MAX_NAME 256 /* longest path component */ 467c478bd9Sstevel@tonic-gate #define MAX_PATH 1024 /* longest total path length */ 477c478bd9Sstevel@tonic-gate #define MAX_RLIST 32 /* max number of -r arguments */ 487c478bd9Sstevel@tonic-gate #define MAX_LINE 1024 /* longest input line */ 497c478bd9Sstevel@tonic-gate #define MAX_DEPTH 20 /* how deep to recurse */ 507c478bd9Sstevel@tonic-gate #define COPY_BSIZE 8192 /* block size for file copies */ 517c478bd9Sstevel@tonic-gate #define MIN_HOLE 1024 /* minimum hole in sparse file */ 527c478bd9Sstevel@tonic-gate #define HASH_SIZE 99 /* ignore list hash table */ 537c478bd9Sstevel@tonic-gate 547c478bd9Sstevel@tonic-gate /* 557c478bd9Sstevel@tonic-gate * sanity check limits 567c478bd9Sstevel@tonic-gate */ 577c478bd9Sstevel@tonic-gate #define CONFIRM_MIN 4 /* min # deletetes to confirm */ 587c478bd9Sstevel@tonic-gate #define CONFIRM_PCT 25 /* min pctg of files to confirm */ 597c478bd9Sstevel@tonic-gate 607c478bd9Sstevel@tonic-gate /* 617c478bd9Sstevel@tonic-gate * special types used in the program 627c478bd9Sstevel@tonic-gate */ 637c478bd9Sstevel@tonic-gate typedef enum { 647c478bd9Sstevel@tonic-gate FALSE = 0, 657c478bd9Sstevel@tonic-gate TRUE = 1, 667c478bd9Sstevel@tonic-gate MAYBE = 2 /* only partially true */ 677c478bd9Sstevel@tonic-gate } bool_t; 687c478bd9Sstevel@tonic-gate 697c478bd9Sstevel@tonic-gate typedef enum { 707c478bd9Sstevel@tonic-gate OPT_BASE = 0, /* use the baseline data */ 717c478bd9Sstevel@tonic-gate OPT_SRC = 1, /* use the source side */ 727c478bd9Sstevel@tonic-gate OPT_DST = 2, /* use the destination side */ 737c478bd9Sstevel@tonic-gate OPT_OLD = 3, /* use the old one */ 747c478bd9Sstevel@tonic-gate OPT_NEW = 4 /* use the new one */ 757c478bd9Sstevel@tonic-gate } side_t; 767c478bd9Sstevel@tonic-gate 777c478bd9Sstevel@tonic-gate /* 787c478bd9Sstevel@tonic-gate * values for debug mask 797c478bd9Sstevel@tonic-gate */ 807c478bd9Sstevel@tonic-gate typedef long dbgmask_t; /* type for debug masks */ 817c478bd9Sstevel@tonic-gate #define DBG_BASE 0x0001 /* baseline changes */ 827c478bd9Sstevel@tonic-gate #define DBG_RULE 0x0002 /* rule base changes */ 837c478bd9Sstevel@tonic-gate #define DBG_STAT 0x0004 /* file stats */ 847c478bd9Sstevel@tonic-gate #define DBG_ANAL 0x0008 /* analysis tracing */ 857c478bd9Sstevel@tonic-gate #define DBG_RECON 0x0010 /* reconciliation tracing */ 867c478bd9Sstevel@tonic-gate #define DBG_VARS 0x0020 /* variable tracing */ 877c478bd9Sstevel@tonic-gate #define DBG_FILES 0x0040 /* file reading/writing */ 887c478bd9Sstevel@tonic-gate #define DBG_LIST 0x0080 /* include list building */ 897c478bd9Sstevel@tonic-gate #define DBG_EVAL 0x0100 /* evaluation tracing */ 907c478bd9Sstevel@tonic-gate #define DBG_IGNORE 0x0200 /* ignore tracing */ 917c478bd9Sstevel@tonic-gate #define DBG_MISC 0x0400 /* catch-all everything else */ 927c478bd9Sstevel@tonic-gate 937c478bd9Sstevel@tonic-gate /* 947c478bd9Sstevel@tonic-gate * values for error codes 957c478bd9Sstevel@tonic-gate */ 967c478bd9Sstevel@tonic-gate typedef int errmask_t; /* type for error masks */ 977c478bd9Sstevel@tonic-gate #define ERR_OK 0 /* everything is fine */ 987c478bd9Sstevel@tonic-gate #define ERR_RESOLVABLE 1 /* resolvable conflicts */ 997c478bd9Sstevel@tonic-gate #define ERR_UNRESOLVED 2 /* unresolvable conflicts */ 1007c478bd9Sstevel@tonic-gate #define ERR_MISSING 4 /* some files missing */ 1017c478bd9Sstevel@tonic-gate #define ERR_PERM 8 /* insufficient access */ 1027c478bd9Sstevel@tonic-gate #define ERR_FILES 16 /* file format or I/O errors */ 1037c478bd9Sstevel@tonic-gate #define ERR_INVAL 32 /* invalid arguments */ 1047c478bd9Sstevel@tonic-gate #define ERR_NOBASE 64 /* inaccessable base directory */ 1057c478bd9Sstevel@tonic-gate #define ERR_OTHER 128 /* anything else */ 1067c478bd9Sstevel@tonic-gate 1077c478bd9Sstevel@tonic-gate /* errors that will prevent reconciliation from taking place */ 1087c478bd9Sstevel@tonic-gate #define ERR_FATAL (ERR_FILES|ERR_INVAL|ERR_NOBASE|ERR_OTHER) 1097c478bd9Sstevel@tonic-gate 1107c478bd9Sstevel@tonic-gate /* errors that will cause reconciliation to stop with -h specified */ 1117c478bd9Sstevel@tonic-gate #define ERR_ABORT (ERR_FILES|ERR_PERM) 1127c478bd9Sstevel@tonic-gate 1137c478bd9Sstevel@tonic-gate /* 1147c478bd9Sstevel@tonic-gate * program defaults 1157c478bd9Sstevel@tonic-gate */ 1167c478bd9Sstevel@tonic-gate #define DFLT_PRFX "$HOME/" /* default location/pfx */ 1177c478bd9Sstevel@tonic-gate #define SUFX_RULES ".packingrules" /* rules v1.1 location */ 1187c478bd9Sstevel@tonic-gate #define SUFX_BASE ".filesync-base" /* baseline location */ 1197c478bd9Sstevel@tonic-gate #define SUFX_OLD ".filesync-rules" /* rules v1.0 location */ 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate /* 1227c478bd9Sstevel@tonic-gate * global variables for command line options 1237c478bd9Sstevel@tonic-gate */ 1247c478bd9Sstevel@tonic-gate extern bool_t opt_acls; /* enable acl checking/preservation */ 1257c478bd9Sstevel@tonic-gate extern bool_t opt_mtime; /* preserve modification times */ 1267c478bd9Sstevel@tonic-gate extern bool_t opt_notouch; /* don't actually make any changes */ 1277c478bd9Sstevel@tonic-gate extern side_t opt_force; /* designated winner for conflicts */ 1287c478bd9Sstevel@tonic-gate extern side_t opt_oneway; /* one way only propagation */ 1297c478bd9Sstevel@tonic-gate extern side_t opt_onesided; /* permit one sided analysis */ 1307c478bd9Sstevel@tonic-gate extern bool_t opt_everything; /* everything must agree (modes/uid/gid) */ 1317c478bd9Sstevel@tonic-gate extern bool_t opt_quiet; /* stiffle reconciliaton descriptions */ 1327c478bd9Sstevel@tonic-gate extern bool_t opt_verbose; /* generate analysis commentary */ 1337c478bd9Sstevel@tonic-gate extern bool_t opt_errors; /* simulate errors on specified files */ 1347c478bd9Sstevel@tonic-gate extern bool_t opt_halt; /* halt on any propagation error */ 1357c478bd9Sstevel@tonic-gate extern dbgmask_t opt_debug; /* debugging options */ 1367c478bd9Sstevel@tonic-gate 1377c478bd9Sstevel@tonic-gate /* 1387c478bd9Sstevel@tonic-gate * information gained during startup that other people may need 1397c478bd9Sstevel@tonic-gate */ 1407c478bd9Sstevel@tonic-gate extern uid_t my_uid; /* User ID for files I create */ 1417c478bd9Sstevel@tonic-gate extern gid_t my_gid; /* Group ID for files I create */ 1427c478bd9Sstevel@tonic-gate 1437c478bd9Sstevel@tonic-gate /* error and warning routines */ 144*48bbca81SDaniel Hoffman void confirm(char *); /* ask user if they're sure */ 1457c478bd9Sstevel@tonic-gate void nomem(char *); /* die from malloc failure */ 1467c478bd9Sstevel@tonic-gate 1477c478bd9Sstevel@tonic-gate /* routines for dealing with strings and file names */ 1487c478bd9Sstevel@tonic-gate const char *prefix(const char *, const char *); /* does s1 begin with s2 */ 1497c478bd9Sstevel@tonic-gate char *qualify(char *); /* validate and fully qualify */ 1507c478bd9Sstevel@tonic-gate char *expand(char *); /* expand variables in name */ 1517c478bd9Sstevel@tonic-gate char *lex(FILE *); /* lex off one token */ 1527c478bd9Sstevel@tonic-gate extern int lex_linenum; /* current input file line number */ 1537c478bd9Sstevel@tonic-gate const char *noblanks(const char *); /* escape strings for embedded blanks */ 1547c478bd9Sstevel@tonic-gate bool_t wildcards(const char *); /* does name contain wildcards */ 1557c478bd9Sstevel@tonic-gate bool_t suffix(const char *, const char *); /* does s1 end with s2 */ 1567c478bd9Sstevel@tonic-gate bool_t contains(const char *, const char *); /* does s1 contain s2 */ 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate #ifdef __cplusplus 1597c478bd9Sstevel@tonic-gate } 1607c478bd9Sstevel@tonic-gate #endif 1617c478bd9Sstevel@tonic-gate 1627c478bd9Sstevel@tonic-gate #endif /* _FILESYNC_H */ 163