11553Srgrimes/*- 21553Srgrimes * Copyright (c) 1990, 1993 31553Srgrimes * The Regents of the University of California. All rights reserved. 41553Srgrimes * 51553Srgrimes * Redistribution and use in source and binary forms, with or without 61553Srgrimes * modification, are permitted provided that the following conditions 71553Srgrimes * are met: 81553Srgrimes * 1. Redistributions of source code must retain the above copyright 91553Srgrimes * notice, this list of conditions and the following disclaimer. 101553Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 111553Srgrimes * notice, this list of conditions and the following disclaimer in the 121553Srgrimes * documentation and/or other materials provided with the distribution. 13121300Sphk * 3. Neither the name of the University nor the names of its contributors 141553Srgrimes * may be used to endorse or promote products derived from this software 151553Srgrimes * without specific prior written permission. 161553Srgrimes * 171553Srgrimes * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 181553Srgrimes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 191553Srgrimes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 201553Srgrimes * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 211553Srgrimes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 221553Srgrimes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 231553Srgrimes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 241553Srgrimes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 251553Srgrimes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 261553Srgrimes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 271553Srgrimes * SUCH DAMAGE. 281553Srgrimes * 291553Srgrimes * @(#)mtree.h 8.1 (Berkeley) 6/6/93 3054375Sjoe * $FreeBSD: releng/10.3/usr.sbin/mtree/mtree.h 160083 2006-07-03 10:55:22Z maxim $ 311553Srgrimes */ 321553Srgrimes 331553Srgrimes#include <string.h> 341553Srgrimes#include <stdlib.h> 351553Srgrimes 361553Srgrimes#define KEYDEFAULT \ 3754375Sjoe (F_GID | F_MODE | F_NLINK | F_SIZE | F_SLINK | F_TIME | F_UID | F_FLAGS) 381553Srgrimes 391553Srgrimes#define MISMATCHEXIT 2 401553Srgrimes 411553Srgrimestypedef struct _node { 421553Srgrimes struct _node *parent, *child; /* up, down */ 431553Srgrimes struct _node *prev, *next; /* left, right */ 441553Srgrimes off_t st_size; /* size */ 451553Srgrimes struct timespec st_mtimespec; /* last modification time */ 461553Srgrimes u_long cksum; /* check sum */ 476286Swollman char *md5digest; /* MD5 digest */ 4844303Swollman char *sha1digest; /* SHA-1 digest */ 49144295Stobez char *sha256digest; /* SHA-256 digest */ 5044303Swollman char *rmd160digest; /* RIPEMD160 digest */ 511553Srgrimes char *slink; /* symbolic link reference */ 521553Srgrimes uid_t st_uid; /* uid */ 531553Srgrimes gid_t st_gid; /* gid */ 541553Srgrimes#define MBITS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO) 551553Srgrimes mode_t st_mode; /* mode */ 5654375Sjoe u_long st_flags; /* flags */ 571553Srgrimes nlink_t st_nlink; /* link count */ 581553Srgrimes 591553Srgrimes#define F_CKSUM 0x0001 /* check sum */ 601553Srgrimes#define F_DONE 0x0002 /* directory done */ 611553Srgrimes#define F_GID 0x0004 /* gid */ 621553Srgrimes#define F_GNAME 0x0008 /* group name */ 631553Srgrimes#define F_IGN 0x0010 /* ignore */ 641553Srgrimes#define F_MAGIC 0x0020 /* name has magic chars */ 651553Srgrimes#define F_MODE 0x0040 /* mode */ 661553Srgrimes#define F_NLINK 0x0080 /* number of links */ 671553Srgrimes#define F_SIZE 0x0100 /* size */ 681553Srgrimes#define F_SLINK 0x0200 /* link count */ 691553Srgrimes#define F_TIME 0x0400 /* modification time */ 701553Srgrimes#define F_TYPE 0x0800 /* file type */ 711553Srgrimes#define F_UID 0x1000 /* uid */ 721553Srgrimes#define F_UNAME 0x2000 /* user name */ 731553Srgrimes#define F_VISIT 0x4000 /* file visited */ 746286Swollman#define F_MD5 0x8000 /* MD5 digest */ 7536670Speter#define F_NOCHANGE 0x10000 /* If owner/mode "wrong", do */ 7636670Speter /* not change */ 7744303Swollman#define F_SHA1 0x20000 /* SHA-1 digest */ 7844303Swollman#define F_RMD160 0x40000 /* RIPEMD160 digest */ 7954375Sjoe#define F_FLAGS 0x80000 /* file flags */ 80144295Stobez#define F_SHA256 0x100000 /* SHA-256 digest */ 81160083Smaxim#define F_OPT 0x200000 /* existence optional */ 8236670Speter u_int flags; /* items set */ 831553Srgrimes 841553Srgrimes#define F_BLOCK 0x001 /* block special */ 851553Srgrimes#define F_CHAR 0x002 /* char special */ 861553Srgrimes#define F_DIR 0x004 /* directory */ 871553Srgrimes#define F_FIFO 0x008 /* fifo */ 881553Srgrimes#define F_FILE 0x010 /* regular file */ 891553Srgrimes#define F_LINK 0x020 /* symbolic link */ 901553Srgrimes#define F_SOCK 0x040 /* socket */ 911553Srgrimes u_char type; /* file type */ 921553Srgrimes 931553Srgrimes char name[1]; /* file name (must be last) */ 941553Srgrimes} NODE; 951553Srgrimes 961553Srgrimes#define RP(p) \ 971553Srgrimes ((p)->fts_path[0] == '.' && (p)->fts_path[1] == '/' ? \ 981553Srgrimes (p)->fts_path + 2 : (p)->fts_path) 99