rpm 5.3.12
|
File state machine to handle a payload from a package. More...
#include "system.h"
#include <rpmio_internal.h>
#include <rpmcb.h>
#include <ugid.h>
#include <rpmsq.h>
#include <rpmsw.h>
#include <rpmsx.h>
#include "../rpmdb/rpmtag.h"
#include <iosm.h>
#include "cpio.h"
#include "tar.h"
#include "ar.h"
#include "../lib/rpmfi.h"
#include "debug.h"
Go to the source code of this file.
Data Structures | |
struct | dnli_s |
Directory name iterator. More... | |
Defines | |
#define | _IOSM_INTERNAL |
#define | iosmUNSAFE iosmStage |
#define | _RPMFI_INTERNAL |
#define | _RPMFI_NOMETHODS |
#define | alloca_strdup(_s) strcpy(alloca(strlen(_s)+1), (_s)) |
#define | _IOSM_DEBUG 0 |
#define | SUFFIX_RPMORIG ".rpmorig" |
#define | SUFFIX_RPMSAVE ".rpmsave" |
#define | SUFFIX_RPMNEW ".rpmnew" |
#define | IS_DEV_LOG(_x) |
#define | _fafilter(_a) |
#define | IOSM_SKIPPING(_a) ((_a) == FA_SKIP || (_a) == FA_SKIPNSTATE || (_a) == FA_SKIPNETSHARED || (_a) == FA_SKIPCOLOR) |
Typedefs | |
typedef struct rpmts_s * | rpmts |
typedef struct rpmte_s * | rpmte |
typedef iosmMapFlags | cpioMapFlags |
typedef struct rpmds_s * | rpmds |
typedef struct rpmRelocation_s * | rpmRelocation |
typedef struct rpmdb_s * | rpmdb |
typedef struct rpmmi_s * | rpmmi |
typedef struct rpmPRCO_s * | rpmPRCO |
typedef struct Spec_s * | Spec |
typedef struct dnli_s * | DNLI_t |
Directory name iterator. | |
Functions | |
void * | iosmGetFi (const IOSM_t iosm) |
Retrieve transaction element file info from I/O state machine iterator. | |
static const char * | iosmFsPath (const IOSM_t iosm, const struct stat *st, const char *subdir, const char *suffix) |
Build path to file from file info, ornamented with subdir and suffix. | |
static void * | mapFreeIterator (void *p) |
Destroy file info iterator. | |
static void * | mapInitIterator (rpmfi fi, int reverse) |
Create file info iterator. | |
static int | mapNextIterator (void *a) |
Return next index into file info. | |
static int | iosmStrCmp (const void *a, const void *b) |
static int | mapFind (FSMI_t iter, const char *fsmPath) |
Locate archive path in file info. | |
static void * | dnlFreeIterator (const void *a) |
Destroy directory name iterator. | |
static int | dnlCount (const DNLI_t dnli) |
static int | dnlIndex (const DNLI_t dnli) |
static void * | dnlInitIterator (const IOSM_t fsm, int reverse) |
Create directory name iterator. | |
static const char * | dnlNextIterator (DNLI_t dnli) |
Return next directory name (from file info). | |
int | iosmNext (IOSM_t iosm, iosmFileStage nstage) |
File state machine driver. | |
static int | saveHardLink (IOSM_t fsm) |
Save hard link in chain. | |
static void * | freeHardLink (struct hardLink_s *li) |
Destroy set of hard links. | |
IOSM_t | newIOSM (void) |
Create I/O state machine instance. | |
IOSM_t | freeIOSM (IOSM_t iosm) |
Destroy I/O state machine instance. | |
static int | arSetup (IOSM_t iosm, rpmfi fi) |
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. | |
static int | iosmMapFContext (IOSM_t iosm) |
int | iosmMapPath (IOSM_t iosm) |
Map next file path and action. | |
int | iosmMapAttrs (IOSM_t iosm) |
Map file stat(2) info. | |
static int | extractRegular (IOSM_t fsm) |
Create file from payload stream. | |
static int | writeFile (IOSM_t fsm, int writeData) |
Write next item to payload stream. | |
static int | writeLinkedFile (IOSM_t fsm) |
Write set of linked files to payload stream. | |
static int | iosmMakeLinks (IOSM_t iosm) |
Create pending hard links to existing file. | |
static int | iosmCommitLinks (IOSM_t iosm) |
Commit hard linked file set atomically. | |
static int | iosmRmdirs (IOSM_t iosm) |
Remove (if created) directories not explicitly included in package. | |
static int | iosmMkdirs (IOSM_t iosm) |
Create (if necessary) directories not explicitly included in package. | |
int | iosmStage (IOSM_t iosm, iosmFileStage stage) |
File state machine driver. | |
int | iosmFileActionSkipped (iosmFileAction action) |
Is the file going to be skipped? | |
const char * | iosmFileActionString (iosmFileAction a) |
Return formatted string representation of file disposition. | |
const char * | iosmFileStageString (iosmFileStage a) |
Return formatted string representation of file stages. | |
char * | iosmStrerror (int rc) |
Return formatted error message on payload handling failure. | |
Variables | |
int | _iosm_debug = 0 |
int | _iosm_threads = 0 |
int(* | _iosmNext )(IOSM_t iosm, iosmFileStage nstage) = &iosmNext |
Vector to iosmNext. |
File state machine to handle a payload from a package.
Definition in file iosm.c.
#define _fafilter | ( | _a | ) |
(!((_a) == FA_CREATE || (_a) == FA_ERASE || (_a) == FA_COPYIN || (_a) == FA_COPYOUT) \ ? iosmFileActionString(_a) : "")
#define alloca_strdup | ( | _s | ) | strcpy(alloca(strlen(_s)+1), (_s)) |
#define IOSM_SKIPPING | ( | _a | ) | ((_a) == FA_SKIP || (_a) == FA_SKIPNSTATE || (_a) == FA_SKIPNETSHARED || (_a) == FA_SKIPCOLOR) |
Definition at line 2671 of file iosm.c.
Referenced by iosmFileActionSkipped().
#define iosmUNSAFE iosmStage |
Definition at line 23 of file iosm.c.
Referenced by iosmMakeLinks(), iosmMkdirs(), iosmSetup(), iosmStage(), and iosmTeardown().
#define IS_DEV_LOG | ( | _x | ) |
((_x) != NULL && strlen(_x) >= (sizeof("/dev/log")-1) && \ !strncmp((_x), "/dev/log", sizeof("/dev/log")-1) && \ ((_x)[sizeof("/dev/log")-1] == '\0' || \ (_x)[sizeof("/dev/log")-1] == ';'))
Definition at line 1627 of file iosm.c.
Referenced by iosmStage().
#define SUFFIX_RPMNEW ".rpmnew" |
Definition at line 100 of file iosm.c.
Referenced by iosmMapPath().
#define SUFFIX_RPMORIG ".rpmorig" |
Definition at line 98 of file iosm.c.
Referenced by iosmMapPath().
#define SUFFIX_RPMSAVE ".rpmsave" |
Definition at line 99 of file iosm.c.
Referenced by iosmMapPath().
typedef iosmMapFlags cpioMapFlags |
typedef struct rpmRelocation_s* rpmRelocation |
Definition at line 588 of file iosm.c.
References iosm_s::lmtab, iosm_s::lmtablen, iosm_s::lmtaboff, rpmfiBN(), rpmfiInit(), rpmfiNext(), stpcpy(), urlPath(), and xmalloc().
Referenced by fsmSetup(), and iosmSetup().
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().
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().
static int iosmMapFContext | ( | IOSM_t | iosm | ) | [static] |
Definition at line 827 of file iosm.c.
References iosm_s::fcontext, iosmGetFi(), iosm_s::ix, iosm_s::nofcontexts, iosm_s::path, rpmsxMatch(), and iosm_s::sb.
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().
static int iosmMkdirs | ( | IOSM_t | iosm | ) | [static] |
Create (if necessary) directories not explicitly included in package.
iosm | file state machine data |
Definition at line 1471 of file iosm.c.
References _free(), D_, dc, dnlCount(), dnlFreeIterator(), dnlIndex(), dnlInitIterator(), dnlNextIterator(), iosm_s::dnlx, iosm_s::fcontext, IOSM_LSETFCON, IOSM_LSTAT, IOSM_MKDIR, IOSMERR_ENOENT, iosmGetFi(), iosmNext(), iosmUNSAFE, iosm_s::ldn, iosm_s::ldnalloc, iosm_s::ldnlen, iosm_s::osb, iosm_s::path, iosm_s::rdbuf, rpmlog(), RPMLOG_DEBUG, rpmsxMatch(), iosm_s::sb, stpcpy(), urlPath(), xcalloc(), and xrealloc().
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().
static int iosmRmdirs | ( | IOSM_t | iosm | ) | [static] |
Remove (if created) directories not explicitly included in package.
iosm | file state machine data |
Definition at line 1416 of file iosm.c.
References dc, dnlCount(), dnlFreeIterator(), dnlIndex(), dnlInitIterator(), dnlNextIterator(), iosm_s::dnlx, IOSM_RMDIR, iosmNext(), iosm_s::ldn, iosm_s::path, iosm_s::rdbuf, and stpcpy().
Referenced by 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 = 0 |
Definition at line 68 of file iosm.c.
Referenced by iosmSetup().
int _iosm_threads = 0 |
Definition at line 72 of file iosm.c.
Referenced by iosmSetup().
int(* _iosmNext)(IOSM_t iosm, iosmFileStage nstage) = &iosmNext |
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().