# lib/transaction.c File Reference

`#include "system.h"`
`#include <rpmmacro.h>`
`#include "psm.h"`
`#include "rpmdb.h"`
`#include "fprint.h"`
`#include "rpmhash.h"`
`#include "misc.h"`
`#include "debug.h"`

Go to the source code of this file.

## Data Structures

struct | diskspaceInfo
struct | tsIterator_s
| Iterator across transaction elements, forward on install, backward on erase. More...

## Defines

#define | adj_fs_blocks(_nb) (((_nb) * 21) / 20)
#define | BLOCK_ROUND(size, block) (((size) + (block) - 1) / (block))
#define | XSTRCMP(a, b) ((!(a) && !(b)) || ((a) && (b) && !strcmp((a), (b))))
#define | alloca_strdup(_s) strcpy(alloca(strlen(_s)+1), (_s))
#define | NOTIFY(_ts, _al) if ((_ts)->notify) (void) (_ts)->notify _al

## Functions

static void * | freeFl (rpmTransactionSet ts, TFI_t flList)
void | rpmtransSetScriptFd (rpmTransactionSet ts, FD_t fd)
| Save file handle to be used as stderr when running package scripts.
int | rpmtransGetKeys (const rpmTransactionSet ts, const void ***ep, int *nep)
| Retrieve keys from ordered transaction set.
static rpmProblemSet | psCreate (void)
static void | psAppend (rpmProblemSet probs, rpmProblemType type, const struct availablePackage *alp, const char *dn, const char *bn, Header altH, unsigned long ulong1)
static int | archOkay (Header h)
static int | osOkay (Header h)
void | rpmProblemSetFree (rpmProblemSet probs)
| Destroy problem set.
static const char *const | ftstring (fileTypes ft)
static fileTypes | whatis (uint_16 mode)
static Header | relocateFileList (const rpmTransactionSet ts, TFI_t fi, struct availablePackage *alp, Header origH, fileAction *actions)
| Relocate files in header.
static int | psTrim (rpmProblemSet filter, rpmProblemSet target)
static int | sharedCmp (const void *one, const void *two)
static fileAction | decideFileFate (const char *dirName, const char *baseName, short dbMode, const char *dbMd5, const char *dbLink, short newMode, const char *newMd5, const char *newLink, int newFlags, rpmtransFlags transFlags)
static int | filecmp (short mode1, const char *md51, const char *link1, short mode2, const char *md52, const char *link2)
static int | handleInstInstalledFiles (TFI_t fi, rpmdb db, struct sharedFileInfo *shared, int sharedCount, int reportConflicts, rpmProblemSet probs, rpmtransFlags transFlags)
static int | handleRmvdInstalledFiles (TFI_t fi, rpmdb db, struct sharedFileInfo *shared, int sharedCount)
static void | handleOverlappedFiles (TFI_t fi, hashTable ht, rpmProblemSet probs, struct diskspaceInfo *dsl)
| Update disk space needs on each partition for this package.
static int | ensureOlder (struct availablePackage *alp, Header old, rpmProblemSet probs)
static void | skipFiles (const rpmTransactionSet ts, TFI_t fi)
static int | tsGetOc (void *a)
| Return transaction element order count.
static struct availablePackage * | tsGetAlp (void *a)
| Return transaction element available package pointer.
static void * | tsFreeIterator (const void *a)
| Destroy transaction element iterator.
static void * | tsInitIterator (const void *a)
| Create transaction element iterator.
static TFI_t | tsNextIterator (void *a)
| Return next transaction element's file info.
int | rpmRunTransactions (rpmTransactionSet ts, rpmCallbackFunction notify, rpmCallbackData notifyData, rpmProblemSet okProbs, rpmProblemSet *newProbs, rpmtransFlags transFlags, rpmprobFilterFlags ignoreSet)
| Process all packages in transaction set.

## Detailed Description

Definition in file transaction.c.

## Define Documentation

#define adj_fs_blocks | ( | _nb |  | ) | (((_nb) * 21) / 20)

| Definition at line 62 of file transaction.c.

#define alloca_strdup | ( | _s |  | ) | strcpy(alloca(strlen(_s)+1), (_s))

| Definition at line 298 of file transaction.c.

#define BLOCK_ROUND | ( | size,
|  | block |  | ) | (((size) + (block) - 1) / (block))

| Definition at line 66 of file transaction.c.

#define NOTIFY | ( | _ts,
|  | _al |  | ) | if ((_ts)->notify) (void) (_ts)->notify _al

| Definition at line 1514 of file transaction.c.

#define XSTRCMP | ( | a,
|  | b |  | ) | ((!(a) && !(b)) || ((a) && (b) && !strcmp((a), (b))))

| Definition at line 68 of file transaction.c. Referenced by psTrim().

## Function Documentation

static int archOkay | ( | Header | h | ) | `[static]`

| Definition at line 200 of file transaction.c. References headerGetEntry(), RPM_INT8_TYPE, RPM_MACHTABLE_INSTARCH, rpmGetArchInfo(), rpmMachineScore(), and RPMTAG_ARCH.

static fileAction decideFileFate | ( | const char * | dirName,
|  | const char * | baseName,
|  | short | dbMode,
|  | const char * | dbMd5,
|  | const char * | dbLink,
|  | short | newMode,
|  | const char * | newMd5,
|  | const char * | newLink,
|  | int | newFlags,
|  | rpmtransFlags | transFlags
| ) | `[static]`

| Definition at line 785 of file transaction.c. References _, alloca(), domd5(), FA_ALTNAME, FA_CREATE, FA_SAVE, FA_SKIP, LINK, REG, RPMFILE_MISSINGOK, RPMFILE_NOREPLACE, rpmMessage, RPMTRANS_FLAG_ALLFILES, stpcpy(), whatis(), and XDIR.

static int ensureOlder | ( | struct availablePackage * | alp,
|  | Header | old,
|  | rpmProblemSet | probs
| ) | `[static]`

| Definition at line 1231 of file transaction.c. References availablePackage::h, psAppend(), RPMPROB_OLDPACKAGE, and rpmVersionCompare().

static int filecmp | ( | short | mode1,
|  | const char * | md51,
|  | const char * | link1,
|  | short | mode2,
|  | const char * | md52,
|  | const char * | link2
| ) | `[static]`

| Definition at line 878 of file transaction.c. References LINK, REG, and whatis(). Referenced by handleInstInstalledFiles().

static void* freeFl | ( | rpmTransactionSet | ts,
|  | TFI_t | flList
| ) | `[static]`

| Definition at line 70 of file transaction.c. References _free(), freeFi(), and rpmTransactionSet_s::orderCount.

static const char* const ftstring | ( | fileTypes | ft | ) | `[static]`

| Definition at line 270 of file transaction.c. References BDEV, CDEV, LINK, PIPE, REG, SOCK, and XDIR.

static int handleInstInstalledFiles | ( | TFI_t | fi,
|  | rpmdb | db,
|  | struct sharedFileInfo * | shared,
|  | int | sharedCount,
|  | int | reportConflicts,
|  | rpmProblemSet | probs,
|  | rpmtransFlags | transFlags
| ) | `[static]`

Definition at line 895 of file transaction.c.

References transactionFileInfo_s::actions, transactionFileInfo_s::ap, transactionFileInfo_s::bnl, transactionFileInfo_s::dil, transactionFileInfo_s::dnl, transactionFileInfo_s::fflags, filecmp(), transactionFileInfo_s::flinks, transactionFileInfo_s::fmd5s, transactionFileInfo_s::fmodes, headerFreeData(), transactionFileInfo_s::hfd, transactionFileInfo_s::hge, sharedFileInfo::isRemoved, sharedFileInfo::otherFileNum, sharedFileInfo::otherPkg, sharedFileInfo::pkgFileNum, psAppend(), transactionFileInfo_s::replaced, rpmdbFreeIterator(), RPMDBI_PACKAGES, rpmdbInitIterator(), rpmdbNextIterator(), RPMFILE_CONFIG, RPMFILE_STATE_NORMAL, RPMPROB_FILE_CONFLICT, RPMTAG_FILEFLAGS, RPMTAG_FILELINKTOS, RPMTAG_FILEMD5S, RPMTAG_FILEMODES, RPMTAG_FILESIZES, RPMTAG_FILESTATES, XFA_SKIPPING, and xmalloc().

static void handleOverlappedFiles | ( | TFI_t | fi,
|  | hashTable | ht,
|  | rpmProblemSet | probs,
|  | struct diskspaceInfo * | dsl
| ) | `[static]`

| Update disk space needs on each partition for this package. Definition at line 1032 of file transaction.c. References transactionFileInfo_s::actions, transactionFileInfo_s::bnl, transactionFileInfo_s::dil, transactionFileInfo_s::dnl, transactionFileInfo_s::fc, recs, XFA_SKIPPING, and xrealloc().

static int handleRmvdInstalledFiles | ( | TFI_t | fi,
|  | rpmdb | db,
|  | struct sharedFileInfo * | shared,
|  | int | sharedCount
| ) | `[static]`

| Definition at line 991 of file transaction.c. References transactionFileInfo_s::actions, FA_SKIP, transactionFileInfo_s::hge, sharedFileInfo::otherFileNum, sharedFileInfo::otherPkg, sharedFileInfo::pkgFileNum, rpmdbFreeIterator(), RPMDBI_PACKAGES, rpmdbInitIterator(), rpmdbNextIterator(), RPMFILE_STATE_NORMAL, and RPMTAG_FILESTATES.

static int osOkay | ( | Header | h | ) | `[static]`

| Definition at line 231 of file transaction.c. References headerGetEntry(), RPM_INT8_TYPE, RPM_MACHTABLE_INSTOS, rpmMachineScore(), and RPMTAG_OS.

static void psAppend | ( | rpmProblemSet | probs,
|  | rpmProblemType | type,
|  | const struct availablePackage * | alp,
|  | const char * | dn,
|  | const char * | bn,
|  | Header | altH,
|  | unsigned long | ulong1
| ) | `[static]`

Definition at line 136 of file transaction.c.

References rpmProblem_s::altNEVR, availablePackage::h, rpmProblem_s::h, headerLink(), headerNVR(), rpmProblem_s::ignoreProblem, availablePackage::key, rpmProblem_s::key, availablePackage::name, rpmProblemSet_s::numProblems, rpmProblemSet_s::numProblemsAlloced, rpmProblem_s::pkgNEVR, rpmProblemSet_s::probs, availablePackage::release, stpcpy(), rpmProblem_s::str1, rpmProblem_s::type, rpmProblem_s::ulong1, availablePackage::version, xmalloc(), and xrealloc().

Referenced by ensureOlder(), handleInstInstalledFiles(), and relocateFileList().

static rpmProblemSet psCreate | ( | void |  | ) | `[static]`

| Definition at line 124 of file transaction.c. References xmalloc(). Referenced by rpmRunTransactions().

static int psTrim | ( | rpmProblemSet | filter,
|  | rpmProblemSet | target
| ) | `[static]`

| Definition at line 734 of file transaction.c. References rpmProblem_s::h, rpmProblem_s::ignoreProblem, rpmProblem_s::key, rpmProblemSet_s::numProblems, rpmProblemSet_s::probs, rpmProblem_s::str1, rpmProblem_s::type, and XSTRCMP.

static Header relocateFileList | ( | const rpmTransactionSet | ts,
|  | TFI_t | fi,
|  | struct availablePackage * | alp,
|  | Header | origH,
|  | fileAction * | actions
| ) | `[static]`

Relocate files in header.

Todo:
  multilib file dispositions need to be checked.

Parameters:

  | ts | transaction set
  | fi | transaction element file info
  | alp | available package
  | origH | package header
  | actions | file dispositions

Returns:
  header with relocated files

Definition at line 310 of file transaction.c.

References alloca(), alloca_strdup, transactionFileInfo_s::hae, headerCopy(), headerFreeData(), headerIsEntry(), headerLink(), transactionFileInfo_s::hfd, transactionFileInfo_s::hge, transactionFileInfo_s::hme, rpmTransactionSet_s::ignoreSet, rpmTransactionSet_s::probs, psAppend(), availablePackage::relocs, RPMPROB_BADRELOCATE, RPMPROB_FILTER_FORCERELOCATE, RPMTAG_INSTPREFIXES, RPMTAG_PREFIXES, and stripTrailingChar().

void rpmProblemSetFree | ( | rpmProblemSet | probs | ) |

Destroy problem set.

Parameters:

  | probs | problem set

Definition at line 256 of file transaction.c.

References _free(), rpmProblem_s::h, headerFree(), rpmProblemSet_s::numProblems, and rpmProblemSet_s::probs.

Referenced by rpmRollback(), and rpmtransRun().

static int sharedCmp | ( | const void * | one,
|  | const void * | two
| ) | `[static]`

| Definition at line 771 of file transaction.c. References sharedFileInfo::otherPkg.

static void skipFiles | ( | const rpmTransactionSet | ts,
|  | TFI_t | fi
| ) | `[static]`

| Definition at line 1250 of file transaction.c. References _free(), transactionFileInfo_s::actions, alloca(), transactionFileInfo_s::bnl, transactionFileInfo_s::dc, transactionFileInfo_s::dil, transactionFileInfo_s::dnl, transactionFileInfo_s::fc, rpmExpand(), rpmExpandNumeric(), RPMTRANS_FLAG_NODOCS, splitString(), rpmTransactionSet_s::transFlags, and XFA_SKIPPING.

static void* tsFreeIterator | ( | const void * | a | ) | `[static]`

Destroy transaction element iterator.

Parameters:

  | a | transaction element iterator

Returns:
  NULL always

Definition at line 1465 of file transaction.c.

References _free().

static struct availablePackage* tsGetAlp | ( | void * | a | ) | `[static]`

Return transaction element available package pointer.

Parameters:

  | a | transaction element iterator

Returns:
  available package pointer

Definition at line 1444 of file transaction.c.

References transactionElement_s::addedIndex, rpmTransactionSet_s::addedPackages, rpmTransactionSet_s::flList, availableList_s::list, tsIterator_s::ocsave, rpmTransactionSet_s::order, tsIterator_s::ts, transactionFileInfo_s::type, and transactionElement_s::u.

static int tsGetOc | ( | void * | a | ) | `[static]`

Return transaction element order count.

Parameters:

  | a | transaction element iterator

Returns:
  element order count

Definition at line 1431 of file transaction.c.

References tsIterator_s::oc, and tsIterator_s::ocsave.

static void* tsInitIterator | ( | const void * | a | ) | `[static]`

Create transaction element iterator.

Parameters:

  | a | transaction set

Returns:
  transaction element iterator

Definition at line 1476 of file transaction.c.

References rpmTransactionSet_s::orderCount, RPMTRANS_FLAG_REVERSE, rpmTransactionSet_s::transFlags, tsIterator_s::ts, and xcalloc().

static TFI_t tsNextIterator | ( | void * | a | ) | `[static]`

Return next transaction element's file info.

Parameters:

  | a | file info iterator

Returns:
  next index, -1 on termination

Definition at line 1495 of file transaction.c.

References rpmTransactionSet_s::flList, tsIterator_s::oc, tsIterator_s::ocsave, rpmTransactionSet_s::orderCount, tsIterator_s::reverse, and tsIterator_s::ts.

static fileTypes whatis | ( | uint_16 | mode | ) | `[static]`

| Definition at line 286 of file transaction.c. References BDEV, CDEV, LINK, PIPE, REG, S_ISLNK, S_ISSOCK, SOCK, and XDIR. Referenced by decideFileFate(), and filecmp().