|
rpm 5.3.12
|
File state machine to handle archive I/O and system call's. More...


Go to the source code of this file.
Data Structures | |
| struct | hardLink_s |
| Keeps track of the set of all hard links to a file in an archive. More... | |
| struct | iosmIterator_s |
| Iterator across package file info, forward on install, backward on erase. More... | |
| struct | iosm_s |
| File name and stat information. More... | |
Defines | |
| #define | _IOSM_INTERNAL |
| #define | IOSMERR_CHECK_ERRNO 0x00008000 |
| #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)) |
Typedefs | |
| typedef struct iosm_s * | IOSM_t |
| File state machine data. | |
| typedef enum iosmFileAction_e | iosmFileAction |
| File disposition(s) during package install/erase processing. | |
| typedef enum iosmMapFlags_e | iosmMapFlags |
| typedef enum iosmFileStage_e | iosmFileStage |
| typedef struct iosmIterator_s * | IOSMI_t |
| Iterator across package file info, forward on install, backward on erase. | |
Enumerations | |
| 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 } |
| File disposition(s) during package install/erase processing. More... | |
| 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) } |
| enum | iosmErrorReturns_e { IOSMERR_BAD_MAGIC = (2 ), IOSMERR_BAD_HEADER = (3 ), IOSMERR_OPEN_FAILED = (4 | 0x00008000 ), IOSMERR_CHMOD_FAILED = (5 | 0x00008000 ), IOSMERR_CHOWN_FAILED = (6 | 0x00008000 ), IOSMERR_WRITE_FAILED = (7 | 0x00008000 ), IOSMERR_UTIME_FAILED = (8 | 0x00008000 ), IOSMERR_UNLINK_FAILED = (9 | 0x00008000 ), IOSMERR_RENAME_FAILED = (10 | 0x00008000 ), IOSMERR_SYMLINK_FAILED = (11 | 0x00008000 ), IOSMERR_STAT_FAILED = (12 | 0x00008000 ), IOSMERR_LSTAT_FAILED = (13 | 0x00008000 ), IOSMERR_MKDIR_FAILED = (14 | 0x00008000 ), IOSMERR_RMDIR_FAILED = (15 | 0x00008000 ), IOSMERR_MKNOD_FAILED = (16 | 0x00008000 ), IOSMERR_MKFIFO_FAILED = (17 | 0x00008000 ), IOSMERR_LINK_FAILED = (18 | 0x00008000 ), IOSMERR_READLINK_FAILED = (19 | 0x00008000 ), IOSMERR_READ_FAILED = (20 | 0x00008000 ), IOSMERR_COPY_FAILED = (21 | 0x00008000 ), IOSMERR_LSETFCON_FAILED = (22 | 0x00008000 ), 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 ) } |
| 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) } |
Functions | |
| const char * | iosmFileStageString (iosmFileStage a) |
| Return formatted string representation of file stages. | |
| const char * | iosmFileActionString (iosmFileAction a) |
| Return formatted string representation of file disposition. | |
| char * | iosmStrerror (int rc) |
| Return formatted error message on payload handling failure. | |
| IOSM_t | newIOSM (void) |
| Create I/O state machine instance. | |
| IOSM_t | freeIOSM (IOSM_t iosm) |
| Destroy I/O state machine instance. | |
| int | iosmSetup (IOSM_t iosm, iosmFileStage goal, const char *afmt, const void *_ts, const void *_fi, FD_t cfd, unsigned int *archiveSize, const char **failedFile) |
| Load external data into I/O state machine. | |
| int | iosmTeardown (IOSM_t iosm) |
| Clean I/O state machine. | |
| void * | iosmGetTs (const IOSM_t iosm) |
| Retrieve transaction set from I/O state machine iterator. | |
| void * | iosmGetFi (const IOSM_t iosm) |
| Retrieve transaction element file info from I/O state machine iterator. | |
| int | iosmMapPath (IOSM_t iosm) |
| Map next file path and action. | |
| int | iosmMapAttrs (IOSM_t iosm) |
| Map file stat(2) info. | |
| int | iosmFileActionSkipped (iosmFileAction action) |
| Is the file going to be skipped? | |
| int | iosmNext (IOSM_t iosm, iosmFileStage nstage) |
| File state machine driver. | |
| int | iosmStage (IOSM_t iosm, iosmFileStage stage) |
| File state machine driver. | |
Variables | |
| int | _iosm_debug |
| int(* | _iosmNext )(IOSM_t iosm, iosmFileStage nstage) |
| Vector to iosmNext. | |
File state machine to handle archive I/O and system call's.
Definition in file iosm.h.
| #define IOSM_DEAD 0x1000 |
Definition at line 108 of file iosm.h.
Referenced by fsmStage(), and iosmStage().
| #define IOSM_INTERNAL 0x4000 |
Definition at line 106 of file iosm.h.
Referenced by fsmStage(), and iosmStage().
| #define IOSM_SYSCALL 0x2000 |
Definition at line 107 of file iosm.h.
Referenced by fsmStage(), and iosmStage().
| #define IOSM_VERBOSE 0x8000 |
Definition at line 105 of file iosm.h.
Referenced by fsmStage(), and iosmStage().
| typedef enum iosmFileAction_e iosmFileAction |
File disposition(s) during package install/erase processing.
| typedef enum iosmFileStage_e iosmFileStage |
| enum iosmFileAction_e |
File disposition(s) during package install/erase processing.
| enum iosmFileStage_e |
Destroy I/O state machine instance.
| iosm | I/O state machine |
Definition at line 572 of file iosm.c.
References _free(), iosm_s::dnlx, freeHardLink(), iosm_s::iter, iosm_s::ldn, iosm_s::li, iosm_s::links, mapFreeIterator(), hardLink_s::next, and iosm_s::path.
| int iosmFileActionSkipped | ( | iosmFileAction | action | ) |
Is the file going to be skipped?
| iosm | I/O state machine |
Definition at line 2674 of file iosm.c.
References IOSM_SKIPPING.
Referenced by dnlInitIterator(), fsmCommitLinks(), fsmMakeLinks(), fsmStage(), handleInstInstalledFile(), handleOverlappedFiles(), iosmCommitLinks(), iosmMakeLinks(), iosmStage(), rpmtsAddFingerprints(), rpmtsSkipFiles(), and saveHardLink().
| const char* iosmFileActionString | ( | iosmFileAction | a | ) |
Return formatted string representation of file disposition.
| a | file dispostion |
Definition at line 2679 of file iosm.c.
References FA_ALTNAME, FA_BACKUP, FA_COPYIN, FA_COPYOUT, FA_CREATE, FA_ERASE, FA_SAVE, FA_SKIP, FA_SKIPCOLOR, FA_SKIPNETSHARED, FA_SKIPNSTATE, and FA_UNKNOWN.
| const char* iosmFileStageString | ( | iosmFileStage | a | ) |
Return formatted string representation of file stages.
| a | file stage |
Definition at line 2699 of file iosm.c.
References IOSM_CHMOD, IOSM_CHOWN, IOSM_CHROOT, IOSM_COMMIT, IOSM_CREATE, IOSM_DESTROY, IOSM_DREAD, IOSM_DWRITE, IOSM_EAT, IOSM_FINI, IOSM_HREAD, IOSM_HWRITE, IOSM_INIT, IOSM_LCHOWN, IOSM_LINK, IOSM_LSETFCON, IOSM_LSTAT, IOSM_MAP, IOSM_MKDIR, IOSM_MKDIRS, IOSM_MKFIFO, IOSM_MKLINKS, IOSM_MKNOD, IOSM_NEXT, IOSM_NOTIFY, IOSM_PAD, IOSM_PKGBUILD, IOSM_PKGCOMMIT, IOSM_PKGERASE, IOSM_PKGINSTALL, IOSM_PKGUNDO, IOSM_POS, IOSM_POST, IOSM_PRE, IOSM_PROCESS, IOSM_RCLOSE, IOSM_READ, IOSM_READLINK, IOSM_RENAME, IOSM_RMDIR, IOSM_RMDIRS, IOSM_ROPEN, IOSM_STAT, IOSM_SYMLINK, IOSM_TRAILER, IOSM_UNDO, IOSM_UNKNOWN, IOSM_UNLINK, IOSM_UTIME, IOSM_VERIFY, IOSM_WCLOSE, IOSM_WOPEN, and IOSM_WRITE.
Referenced by fsmStage(), and iosmStage().
| void* iosmGetFi | ( | const IOSM_t | iosm | ) |
Retrieve transaction element file info from I/O state machine iterator.
| iosm | I/O state machine |
Definition at line 90 of file iosm.c.
References iosmIterator_s::fi, and iosm_s::iter.
Referenced by iosmMapAttrs(), iosmMapFContext(), iosmMapPath(), iosmMkdirs(), and iosmStage().
| void* iosmGetTs | ( | const IOSM_t | iosm | ) |
Retrieve transaction set from I/O state machine iterator.
| iosm | I/O state machine |
Referenced by iosmStage(), and iosmTeardown().
| int iosmMapAttrs | ( | IOSM_t | iosm | ) |
Map file stat(2) info.
| iosm | I/O state machine |
Definition at line 941 of file iosm.c.
References _, iosm_s::digest, iosm_s::digestlen, iosm_s::fdigest, iosm_s::fdigestalgo, gnameToGid(), iosm_s::goal, IOSM_MAP_GID, IOSM_MAP_MODE, IOSM_MAP_TYPE, IOSM_MAP_UID, IOSM_PKGINSTALL, iosmGetFi(), iosm_s::ix, iosm_s::mapFlags, iosm_s::nofdigests, rpmlog(), RPMLOG_WARNING, iosm_s::sb, and unameToUid().
Referenced by iosmStage().
| int iosmMapPath | ( | IOSM_t | iosm | ) |
Map next file path and action.
| iosm | I/O state machine |
Definition at line 850 of file iosm.c.
References _free(), iosm_s::action, iosm_s::adding, iosm_s::astriplen, iosm_s::baseName, iosm_s::dirName, FA_ALTNAME, FA_BACKUP, FA_COPYIN, FA_COPYOUT, FA_CREATE, FA_ERASE, FA_SAVE, FA_SKIP, FA_SKIPCOLOR, FA_SKIPNETSHARED, FA_SKIPNSTATE, FA_UNKNOWN, iosm_s::fflags, IOSM_MAP_PATH, iosmFsPath(), iosmGetFi(), iosm_s::ix, iosm_s::mapFlags, iosm_s::nsuffix, iosm_s::osuffix, iosm_s::path, RPMFILE_GHOST, RPMFILE_STATE_NETSHARED, RPMFILE_STATE_NOTINSTALLED, RPMFILE_STATE_WRONGCOLOR, rpmteType(), iosm_s::sb, iosm_s::subdir, iosm_s::suffix, SUFFIX_RPMNEW, SUFFIX_RPMORIG, SUFFIX_RPMSAVE, and TR_REMOVED.
Referenced by iosmStage().
| int iosmNext | ( | IOSM_t | iosm, |
| iosmFileStage | nstage | ||
| ) |
File state machine driver.
| iosm | I/O state machine |
| nstage | next stage |
Definition at line 453 of file iosm.c.
References iosmStage(), iosm_s::multithreaded, iosm_s::nstage, rpmsqJoin(), and rpmsqThread().
Referenced by iosmCommitLinks(), iosmMakeLinks(), iosmMkdirs(), iosmRmdirs(), iosmSetup(), and iosmStage().
| int iosmSetup | ( | IOSM_t | iosm, |
| iosmFileStage | goal, | ||
| const char * | afmt, | ||
| const void * | _ts, | ||
| const void * | _fi, | ||
| FD_t | cfd, | ||
| unsigned int * | archiveSize, | ||
| const char ** | failedFile | ||
| ) |
Load external data into I/O state machine.
| iosm | I/O state machine |
| goal | |
| afmt | archive format (NULL uses cpio) |
| _ts | transaction set |
| _fi | transaction element file info |
| cfd | payload descriptor |
| archiveSize | pointer to archive size |
| failedFile | pointer to first file name that failed. |
Definition at line 661 of file iosm.c.
References _iosm_debug, _iosm_threads, _iosmNext, _tsmask, iosm_s::adding, iosm_s::archiveSize, arHeaderRead(), arHeaderWrite(), arSetup(), arTrailerWrite(), iosm_s::blksize, iosm_s::cfd, iosm_s::commit, cpioHeaderRead(), cpioHeaderWrite(), cpioTrailerWrite(), iosm_s::debug, FA_COPYOUT, iosm_s::failedFile, fdGetCpioPos(), fdLink(), fdSetCpioPos(), iosm_s::goal, iosm_s::headerRead, iosm_s::headerWrite, IOSM_CREATE, IOSM_PKGBUILD, IOSM_PKGCOMMIT, IOSM_PKGERASE, IOSM_PKGINSTALL, iosmNext(), iosmUNSAFE, iosm_s::iter, mapInitIterator(), iosm_s::multithreaded, iosm_s::nofcontexts, iosm_s::nofdigests, iosm_s::rc, RPMCALLBACK_INST_START, rpmteType(), RPMTRANS_FLAG_NOCONTEXTS, RPMTRANS_FLAG_NOFDIGESTS, rpmtsFlags(), rpmtsGetTid(), rpmtsLink(), rpmtsNotify(), iosm_s::sufbuf, TAR_BLOCK_SIZE, tarHeaderRead(), tarHeaderWrite(), tarTrailerWrite(), TR_ADDED, TR_REMOVED, iosm_s::trailerWrite, and iosmIterator_s::ts.
| int iosmStage | ( | IOSM_t | iosm, |
| iosmFileStage | stage | ||
| ) |
File state machine driver.
| iosm | I/O state machine |
| stage | next stage |
Definition at line 1634 of file iosm.c.
References _, _fafilter, _free(), iosm_s::action, alloca(), iosm_s::astriplen, iosm_s::blksize, iosm_s::cfd, Chmod(), Chown(), iosm_s::commit, CPIO_TRAILER, hardLink_s::createdPath, iosm_s::debug, iosm_s::diskchecked, iosm_s::dnlx, errno, iosm_s::exists, extractRegular(), FA_ERASE, FA_UNKNOWN, Fadvise(), iosm_s::failedFile, Fclose(), iosm_s::fcontext, fdGetCpioPos(), fdSetCpioPos(), FDSTAT_DIGEST, fdstat_op(), Ferror(), iosm_s::fflags, hardLink_s::filex, Fopen(), Fread(), freeHardLink(), Fwrite(), iosm_s::goal, iosm_s::headerRead, iosm_s::headerWrite, IOSM_ALL_HARDLINKS, IOSM_CHMOD, IOSM_CHOWN, IOSM_CHROOT, IOSM_COMMIT, IOSM_CREATE, IOSM_DEAD, IOSM_DESTROY, IOSM_DREAD, IOSM_DWRITE, IOSM_EAT, IOSM_FINI, IOSM_FOLLOW_SYMLINKS, IOSM_HREAD, IOSM_HWRITE, IOSM_INIT, IOSM_INTERNAL, IOSM_LCHOWN, IOSM_LINK, IOSM_LSETFCON, IOSM_LSTAT, IOSM_MAP, IOSM_MKDIR, IOSM_MKDIRS, IOSM_MKFIFO, IOSM_MKLINKS, IOSM_MKNOD, IOSM_NEXT, IOSM_NOTIFY, IOSM_PAD, IOSM_PAYLOAD_EXTRACT, IOSM_PAYLOAD_LIST, IOSM_PKGBUILD, IOSM_PKGCOMMIT, IOSM_PKGERASE, IOSM_PKGINSTALL, IOSM_POS, IOSM_POST, IOSM_PRE, IOSM_PROCESS, IOSM_RCLOSE, IOSM_READ, IOSM_READLINK, IOSM_RENAME, IOSM_RMDIR, IOSM_RMDIRS, IOSM_ROPEN, IOSM_SBIT_CHECK, IOSM_STAT, IOSM_SYMLINK, IOSM_SYSCALL, IOSM_TRAILER, IOSM_UNDO, IOSM_UNKNOWN, IOSM_UNLINK, IOSM_UTIME, IOSM_VERBOSE, IOSM_VERIFY, IOSM_WCLOSE, IOSM_WOPEN, IOSM_WRITE, iosmCommitLinks(), IOSMERR_CHMOD_FAILED, IOSMERR_CHOWN_FAILED, IOSMERR_ENOENT, IOSMERR_ENOTEMPTY, IOSMERR_HDR_TRAILER, IOSMERR_LINK_FAILED, IOSMERR_LSETFCON_FAILED, IOSMERR_LSTAT_FAILED, IOSMERR_MISSING_HARDLINK, IOSMERR_MKDIR_FAILED, IOSMERR_MKFIFO_FAILED, IOSMERR_MKNOD_FAILED, IOSMERR_OPEN_FAILED, IOSMERR_READ_FAILED, IOSMERR_READLINK_FAILED, IOSMERR_RENAME_FAILED, IOSMERR_RMDIR_FAILED, IOSMERR_STAT_FAILED, IOSMERR_SYMLINK_FAILED, IOSMERR_UNKNOWN_FILETYPE, IOSMERR_UNLINK_FAILED, IOSMERR_UNMAPPED_FILE, IOSMERR_UTIME_FAILED, IOSMERR_WRITE_FAILED, iosmFileActionSkipped(), iosmFileStageString(), iosmFsPath(), iosmGetFi(), iosmGetTs(), iosmMakeLinks(), iosmMapAttrs(), iosmMapFContext(), iosmMapPath(), iosmMkdirs(), iosmNext(), iosmRmdirs(), iosmUNSAFE, IS_DEV_LOG, iosm_s::iter, iosm_s::ix, Lchown(), iosm_s::ldn, iosm_s::ldnalloc, iosm_s::ldnlen, iosm_s::li, Link(), hardLink_s::linkIndex, iosm_s::links, hardLink_s::linksLeft, iosm_s::lpath, Lstat(), mapFind(), iosm_s::mapFlags, mapNextIterator(), Mkdir(), iosm_s::mkdirsdone, Mkfifo(), Mknod(), hardLink_s::next, hardLink_s::nlink, iosm_s::nsuffix, iosm_s::op_digest, iosm_s::opath, iosm_s::osb, iosm_s::osuffix, iosm_s::path, iosm_s::postpone, iosm_s::rc, iosm_s::rdb, iosm_s::rdbuf, iosm_s::rdlen, iosm_s::rdnb, iosm_s::rdsize, Readlink(), Rename(), iosm_s::repackaged, iosm_s::rfd, Rmdir(), RPMCALLBACK_INST_PROGRESS, RPMFILE_GHOST, RPMFILE_MISSINGOK, rpmlog(), RPMLOG_DEBUG, RPMLOG_ERR, RPMLOG_WARNING, rpmswAdd(), rpmsxLsetfilecon(), rpmtsNotify(), S_ISLNK, S_ISSOCK, saveHardLink(), hardLink_s::sb, iosm_s::sb, iosm_s::stage, Stat(), stpcpy(), iosm_s::strict_erasures, iosm_s::subdir, iosm_s::sufbuf, iosm_s::suffix, Symlink(), iosm_s::trailerWrite, Unlink(), urlPath(), Utime(), iosm_s::wfd, iosm_s::wrb, iosm_s::wrbuf, writeFile(), writeLinkedFile(), iosm_s::wrlen, iosm_s::wrnb, iosm_s::wrsize, xmalloc(), and xstrdup().
Referenced by fsmStage(), and iosmNext().
| int iosmTeardown | ( | IOSM_t | iosm | ) |
Clean I/O state machine.
| iosm | I/O state machine |
Definition at line 794 of file iosm.c.
References _free(), iosm_s::cfd, iosm_s::debug, iosm_s::failedFile, fdFree(), IOSM_DESTROY, iosmGetTs(), iosmUNSAFE, iosm_s::iter, iosm_s::lmtab, mapFreeIterator(), iosm_s::op_digest, iosm_s::rc, rpmswAdd(), RPMTS_OP_DIGEST, rpmtsFree(), rpmtsOp(), and iosmIterator_s::ts.
| IOSM_t newIOSM | ( | void | ) |
| int _iosm_debug |
| int(* _iosmNext)(IOSM_t iosm, iosmFileStage nstage) |
Vector to iosmNext.
Definition at line 76 of file iosm.c.
Referenced by arHeaderRead(), arHeaderWrite(), arRead(), arTrailerWrite(), arWrite(), cpioHeaderRead(), cpioHeaderWrite(), cpioRead(), cpioTrailerWrite(), cpioWrite(), fsmSetup(), iosmSetup(), tarHeaderWrite(), tarHeaderWriteName(), tarRead(), tarTrailerWrite(), and tarWrite().
1.7.4