iosm.h
Go to the documentation of this file.
#ifndef H_IOSM
#define H_IOSM
#include <rpmiotypes.h>
#include <rpmsw.h>
typedef /*@abstract@*/ struct iosm_s * IOSM_t;
/*@-exportlocal@*/
/*@unchecked@*/
extern int _iosm_debug;
/*@=exportlocal@*/
typedef enum iosmFileAction_e {
FA_UNKNOWN = 0,
FA_CREATE,
FA_COPYIN,
FA_COPYOUT,
FA_BACKUP,
FA_SAVE,
FA_SKIP,
FA_ALTNAME,
FA_ERASE,
FA_SKIPNSTATE,
FA_SKIPNETSHARED,
FA_SKIPCOLOR
} iosmFileAction;
typedef enum iosmMapFlags_e {
IOSM_MAP_PATH = (1 << 0),
IOSM_MAP_MODE = (1 << 1),
IOSM_MAP_UID = (1 << 2),
IOSM_MAP_GID = (1 << 3),
IOSM_FOLLOW_SYMLINKS= (1 << 4),
IOSM_MAP_ABSOLUTE = (1 << 5),
IOSM_MAP_ADDDOT = (1 << 6),
IOSM_ALL_HARDLINKS = (1 << 7),
IOSM_MAP_TYPE = (1 << 8),
IOSM_SBIT_CHECK = (1 << 9),
IOSM_PAYLOAD_LIST = (1 << 10),
IOSM_PAYLOAD_EXTRACT= (1 << 11),
IOSM_PAYLOAD_CREATE = (1 << 12)
} iosmMapFlags;
#if defined(_IOSM_INTERNAL)
#define IOSMERR_CHECK_ERRNO 0x00008000
enum iosmErrorReturns_e {
IOSMERR_BAD_MAGIC = (2 ),
IOSMERR_BAD_HEADER = (3 ),
IOSMERR_OPEN_FAILED = (4 | IOSMERR_CHECK_ERRNO),
IOSMERR_CHMOD_FAILED = (5 | IOSMERR_CHECK_ERRNO),
IOSMERR_CHOWN_FAILED = (6 | IOSMERR_CHECK_ERRNO),
IOSMERR_WRITE_FAILED = (7 | IOSMERR_CHECK_ERRNO),
IOSMERR_UTIME_FAILED = (8 | IOSMERR_CHECK_ERRNO),
IOSMERR_UNLINK_FAILED = (9 | IOSMERR_CHECK_ERRNO),
IOSMERR_RENAME_FAILED = (10 | IOSMERR_CHECK_ERRNO),
IOSMERR_SYMLINK_FAILED = (11 | IOSMERR_CHECK_ERRNO),
IOSMERR_STAT_FAILED = (12 | IOSMERR_CHECK_ERRNO),
IOSMERR_LSTAT_FAILED = (13 | IOSMERR_CHECK_ERRNO),
IOSMERR_MKDIR_FAILED = (14 | IOSMERR_CHECK_ERRNO),
IOSMERR_RMDIR_FAILED = (15 | IOSMERR_CHECK_ERRNO),
IOSMERR_MKNOD_FAILED = (16 | IOSMERR_CHECK_ERRNO),
IOSMERR_MKFIFO_FAILED = (17 | IOSMERR_CHECK_ERRNO),
IOSMERR_LINK_FAILED = (18 | IOSMERR_CHECK_ERRNO),
IOSMERR_READLINK_FAILED = (19 | IOSMERR_CHECK_ERRNO),
IOSMERR_READ_FAILED = (20 | IOSMERR_CHECK_ERRNO),
IOSMERR_COPY_FAILED = (21 | IOSMERR_CHECK_ERRNO),
IOSMERR_LSETFCON_FAILED = (22 | IOSMERR_CHECK_ERRNO),
IOSMERR_HDR_SIZE = (23 ),
IOSMERR_HDR_TRAILER = (24 ),
IOSMERR_UNKNOWN_FILETYPE= (25 ),
IOSMERR_MISSING_HARDLINK= (26 ),
IOSMERR_DIGEST_MISMATCH = (27 ),
IOSMERR_INTERNAL = (28 ),
IOSMERR_UNMAPPED_FILE = (29 ),
IOSMERR_ENOENT = (30 ),
IOSMERR_ENOTEMPTY = (31 )
};
#endif
#define IOSM_VERBOSE 0x8000
#define IOSM_INTERNAL 0x4000
#define IOSM_SYSCALL 0x2000
#define IOSM_DEAD 0x1000
#define _fv(_a) ((_a) | IOSM_VERBOSE)
#define _fi(_a) ((_a) | IOSM_INTERNAL)
#define _fs(_a) ((_a) | (IOSM_INTERNAL | IOSM_SYSCALL))
#define _fd(_a) ((_a) | (IOSM_INTERNAL | IOSM_DEAD))
typedef enum iosmFileStage_e {
IOSM_UNKNOWN = 0,
IOSM_INIT = _fd(1),
IOSM_PRE = _fd(2),
IOSM_PROCESS= _fv(3),
IOSM_POST = _fd(4),
IOSM_UNDO = 5,
IOSM_FINI = 6,
IOSM_PKGINSTALL = _fd(7),
IOSM_PKGERASE = _fd(8),
IOSM_PKGBUILD = _fd(9),
IOSM_PKGCOMMIT = _fd(10),
IOSM_PKGUNDO = _fd(11),
IOSM_CREATE = _fd(17),
IOSM_MAP = _fd(18),
IOSM_MKDIRS = _fi(19),
IOSM_RMDIRS = _fi(20),
IOSM_MKLINKS= _fi(21),
IOSM_NOTIFY = _fd(22),
IOSM_DESTROY= _fd(23),
IOSM_VERIFY = _fd(24),
IOSM_COMMIT = _fd(25),
IOSM_UNLINK = _fs(33),
IOSM_RENAME = _fs(34),
IOSM_MKDIR = _fs(35),
IOSM_RMDIR = _fs(36),
IOSM_LSETFCON= _fs(39),
IOSM_CHOWN = _fs(40),
IOSM_LCHOWN = _fs(41),
IOSM_CHMOD = _fs(42),
IOSM_UTIME = _fs(43),
IOSM_SYMLINK= _fs(44),
IOSM_LINK = _fs(45),
IOSM_MKFIFO = _fs(46),
IOSM_MKNOD = _fs(47),
IOSM_LSTAT = _fs(48),
IOSM_STAT = _fs(49),
IOSM_READLINK= _fs(50),
IOSM_CHROOT = _fs(51),
IOSM_NEXT = _fd(65),
IOSM_EAT = _fd(66),
IOSM_POS = _fd(67),
IOSM_PAD = _fd(68),
IOSM_TRAILER= _fd(69),
IOSM_HREAD = _fd(70),
IOSM_HWRITE = _fd(71),
IOSM_DREAD = _fs(72),
IOSM_DWRITE = _fs(73),
IOSM_ROPEN = _fs(129),
IOSM_READ = _fs(130),
IOSM_RCLOSE = _fs(131),
IOSM_WOPEN = _fs(132),
IOSM_WRITE = _fs(133),
IOSM_WCLOSE = _fs(134)
} iosmFileStage;
#undef _fv
#undef _fi
#undef _fs
#undef _fd
#if defined(_IOSM_INTERNAL)
typedef /*@abstract@*/ struct iosmIterator_s * IOSMI_t;
struct hardLink_s {
/*@owned@*/ /*@relnull@*/
struct hardLink_s * next;
/*@owned@*/
const char ** nsuffix;
/*@owned@*/
int * filex;
struct stat sb;
int nlink;
int linksLeft;
int linkIndex;
int createdPath;
};
struct iosmIterator_s {
void * ts;
void * fi;
int reverse;
int isave;
int i;
};
struct iosm_s {
/*@owned@*/ /*@relnull@*/
const char * path;
/*@owned@*/ /*@relnull@*/
const char * lpath;
/*@owned@*/ /*@relnull@*/
const char * opath;
/*@relnull@*/
FD_t cfd;
/*@relnull@*/
FD_t rfd;
/*@dependent@*/ /*@relnull@*/
char * rdbuf;
/*@owned@*/ /*@relnull@*/
char * rdb;
size_t rdsize;
size_t rdlen;
size_t rdnb;
FD_t wfd;
/*@dependent@*/ /*@relnull@*/
char * wrbuf;
/*@owned@*/ /*@relnull@*/
char * wrb;
size_t wrsize;
size_t wrlen;
size_t wrnb;
/*@only@*/ /*@relnull@*/
IOSMI_t iter;
int ix;
/*@only@*/ /*@relnull@*/
struct hardLink_s * links;
/*@only@*/ /*@relnull@*/
struct hardLink_s * li;
/*@kept@*/ /*@null@*/
unsigned int * archiveSize;
/*@kept@*/ /*@null@*/
const char ** failedFile;
/*@shared@*/ /*@relnull@*/
const char * subdir;
/*@unused@*/
char subbuf[64]; /* XXX eliminate */
/*@observer@*/ /*@relnull@*/
const char * osuffix;
/*@observer@*/ /*@relnull@*/
const char * nsuffix;
/*@shared@*/ /*@relnull@*/
const char * suffix;
char sufbuf[64]; /* XXX eliminate */
/*@only@*/ /*@null@*/
unsigned short * dnlx;
/*@only@*/ /*@null@*/
char * ldn;
size_t ldnlen;
size_t ldnalloc;
int postpone;
int diskchecked;
int exists;
int mkdirsdone;
size_t astriplen;
int rc;
int commit;
int repackaged;
int strict_erasures;
int multithreaded;
int adding;
int debug;
int nofdigests;
int nofcontexts;
iosmMapFlags mapFlags;
rpmuint32_t fdigestalgo;
rpmuint32_t digestlen;
/*@shared@*/ /*@relnull@*/
const char * dirName;
/*@shared@*/ /*@relnull@*/
const char * baseName;
/*@shared@*/ /*@relnull@*/
const char * fdigest;
/*@shared@*/ /*@relnull@*/
const unsigned char * digest;
/*@dependent@*/ /*@observer@*/ /*@null@*/
const char * fcontext;
rpmuint32_t fflags;
iosmFileAction action;
iosmFileStage goal;
iosmFileStage stage;
iosmFileStage nstage;
struct stat sb;
struct stat osb;
unsigned blksize;
int (*headerRead) (void * _iosm, struct stat *st)
/*@modifies _iosm, st @*/;
int (*headerWrite) (void * _iosm, struct stat *st)
/*@modifies _iosm, st @*/;
int (*trailerWrite) (void * _iosm)
/*@modifies _iosm @*/;
/*@null@*/
char * lmtab;
size_t lmtablen;
size_t lmtaboff;
struct rpmop_s op_digest;
};
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*@-exportlocal@*/
/*@observer@*/ const char * iosmFileStageString(iosmFileStage a) /*@*/;
/*@observer@*/ const char * iosmFileActionString(iosmFileAction a) /*@*/;
/*@=exportlocal@*/
/*@only@*/
char * iosmStrerror(int rc)
/*@*/;
#if defined(_IOSM_INTERNAL)
/*@only@*/ IOSM_t newIOSM(void)
/*@*/;
/*@null@*/ IOSM_t freeIOSM(/*@only@*/ /*@null@*/ IOSM_t iosm)
/*@modifies iosm @*/;
#endif
int iosmSetup(IOSM_t iosm, iosmFileStage goal, /*@null@*/ const char * afmt,
const void * _ts,
const void * _fi,
FD_t cfd,
/*@out@*/ /*@null@*/ unsigned int * archiveSize,
/*@out@*/ /*@null@*/ const char ** failedFile)
/*@globals h_errno, fileSystem, internalState @*/
/*@modifies iosm, _ts, _fi, cfd, *archiveSize, *failedFile,
fileSystem, internalState @*/;
int iosmTeardown(IOSM_t iosm)
/*@globals h_errno, fileSystem, internalState @*/
/*@modifies iosm, fileSystem, internalState @*/;
#if defined(_IOSM_INTERNAL)
/*@-exportlocal@*/
void * iosmGetTs(const IOSM_t iosm)
/*@*/;
void * iosmGetFi(/*@partial@*/ const IOSM_t iosm)
/*@*/;
int iosmMapPath(IOSM_t iosm)
/*@modifies iosm @*/;
int iosmMapAttrs(IOSM_t iosm)
/*@modifies iosm @*/;
/*@=exportlocal@*/
extern int (*_iosmNext) (IOSM_t iosm, iosmFileStage nstage)
/*@modifies iosm @*/;
#endif
int iosmFileActionSkipped(iosmFileAction action)
/*@*/;
int iosmNext(IOSM_t iosm, iosmFileStage nstage)
/*@globals errno, h_errno, fileSystem, internalState @*/
/*@modifies iosm, errno, fileSystem, internalState @*/;
/*@-exportlocal@*/
int iosmStage(/*@partial@*/ IOSM_t iosm, iosmFileStage stage)
/*@globals errno, h_errno, fileSystem, internalState @*/
/*@modifies iosm, errno, fileSystem, internalState @*/;
/*@=exportlocal@*/
#ifdef __cplusplus
}
#endif
#endif /* H_IOSM */