cpio.h revision b0ee9efa1f4ab0654aa51c968022f84aa53d894e
/*
* 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
* 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) 2012 Gary Mills
*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#ifndef _CPIO_H
#define _CPIO_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <archives.h>
/* Option Character keys (OC#), where '#' is the option character specified. */
#define OCa 0x1
#define OCb 0x2
#define OCc 0x4
#define OCd 0x8
#define OCf 0x10
#define OCi 0x20
#define OCk 0x40
#define OCl 0x80
#define OCm 0x100
#define OCo 0x200
#define OCp 0x400
#define OCr 0x800
#define OCs 0x1000
#define OCt 0x2000
#define OCu 0x4000
#define OCv 0x8000
#define OCA 0x10000
#define OCB 0x20000
#define OCC 0x40000
#define OCE 0x80000
#define OCH 0x100000
#define OCI 0x200000
#define OCL 0x400000
#define OCM 0x800000
#define OCO 0x1000000
#define OCR 0x2000000
#define OCS 0x4000000
#define OCV 0x8000000
#define OC6 0x10000000
#define BSM 0x20000000
#define OCP 0x40000000
#define OCq 0x80000000
/* Sparse file support */
#define C_ISSPARSE 0200000
#define S_IFSPARSE 0x10000
#define HIGH_ORD_MASK 0x30000
#define S_ISSPARSE(mode) \
/* Invalid option masks for each action option (-i, -o or -p). */
/* Header types */
#define NONE 0 /* No header value verified */
/* Differentiate between TAR and USTAR */
#define ULL_MAX_SIZE 20
#define UL_MAX_SIZE 10
/* constants for bar, used for extracting bar archives */
#define BAR 9
#define BAR_VOLUME_MAGIC 'V'
#define BARTYP 7
#define BARSZ 512
/* the pathname lengths for the USTAR header */
/* HDRSZ: header size minus filename field length */
/*
* IDENT: Determine if two stat() structures represent identical files.
* Assumes that if the device and inode are the same the files are
* identical (prevents the archive file from appearing in the archive).
*/
/*
* FLUSH: Determine if enough space remains in the buffer to hold
* cnt bytes, if not, call bflush() to flush the buffer to the archive.
*/
/*
* FILL: Determine if enough bytes remain in the buffer to meet current needs,
* if not, call rstbuf() to reset and refill the buffer from the archive.
*/
/*
* VERBOSE: If x is non-zero, call verbose().
*/
/*
* FORMAT: Date time formats
* b - abbreviated month name
* e - day of month (1 - 31)
* H - hour (00 - 23)
* M - minute (00 - 59)
* Y - year as ccyy
*/
#define FORMAT "%b %e %H:%M %Y"
/* Extended system attributes */
#ifndef VIEW_READONLY
#define VIEW_READONLY "SUNWattr_ro"
#endif
#ifndef VIEW_READWRITE
#define VIEW_READWRITE "SUNWattr_rw"
#endif
#define min(a, b) ((a) < (b) ? (a) : (b))
/* Values used in typeflag field */
#define INPUT 0 /* -i mode (used for chgreel() */
#define F_SKIP 0 /* an object did not match the patterns */
#define SEEK_ABS 0 /* lseek absolute */
/*
* xxx_CNT represents the number of sscanf items that will be matched
* if the sscanf to read a header is successful. If sscanf returns a number
* that is not equal to this, an error occured (which indicates that this
* is not a valid header of the type assumed.
*/
/* These defines determine the severity of the message sent to the user. */
#define P_SKIP 0 /* File should be skipped */
#define U_KEEP 0 /* Keep the existing version of a file (-u) */
/*
* _20K: Allocate the maximum of (20K or (MX_BUFS * Bufsize)) bytes
* for the main I/O buffer. Therefore if a user specifies a small buffer
* size, they still get decent performance due to the buffering strategy.
*/
#define _20K 20480
/* bar structure */
union b_block {
struct bar_header {
char mode[8];
char uid[8];
char gid[8];
char size[12];
char mtime[12];
char chksum[8];
char rdev[8];
char linkflag;
/*
* The following fields are specific to the volume
* header. They are set to zero in all file headers
* in the archive.
*/
char compressed; /* files compressed = 1 */
char start_of_name; /* start of the filename */
} dbuf;
};
/* svr32 stat structure -- for -Hodc headers */
typedef struct cpioinfo {
} cpioinfo_t;
/*
* Allocation wrappers and their flags
*/
/*
* If compiling on a system that doesn't
* support extended attributes, then
* define a couple of things so we can compile.
*/
#if !defined(O_XATTR)
#define AT_SYMLINK_NOFOLLOW 0x1000
#define AT_REMOVEDIR 0x0001
#define _XATTR_CPIO_MODE 0xB000
#define _XATTR_HDRTYPE 'E'
#endif /* O_XATTR */
/*
* Sparse file support
*/
typedef struct holes_list {
struct holes_list *hl_next;
} holes_list_t;
typedef struct holes_info {
char *holesdata; /* holesdata string */
} holes_info_t;
extern int parse_holesdata(holes_info_t *, const char *);
extern void free_holes_info(holes_info_t *);
extern void str_fprintf(FILE *, const char *, ...);
#ifdef __cplusplus
}
#endif
#endif /* _CPIO_H */