# lib/transaction.c File Reference

More...

`#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

void * | freeFl (rpmTransactionSet ts, TFI_t flList)
void | rpmtransSetScriptFd (rpmTransactionSet ts, FD_t fd)
int | rpmtransGetKeys (const rpmTransactionSet ts, const void ***ep, int *nep)
rpmProblemSet | psCreate (void)
void | psAppend (rpmProblemSet probs, rpmProblemType type, const struct availablePackage *alp, const char *dn, const char *bn, Header altH, unsigned long ulong1)
int | archOkay (Header h)
int | osOkay (Header h)
void | rpmProblemSetFree (rpmProblemSet probs)
| Destroy problem set.
const char *const | ftstring (fileTypes ft)
fileTypes | whatis (uint_16 mode)
Header | relocateFileList (const rpmTransactionSet ts, TFI_t fi, struct availablePackage *alp, Header origH, fileAction *actions)
| Relocate files in header.
int | psTrim (rpmProblemSet filter, rpmProblemSet target)
int | sharedCmp (const void *one, const void *two)
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)
int | filecmp (short mode1, const char *md51, const char *link1, short mode2, const char *md52, const char *link2)
int | handleInstInstalledFiles (TFI_t fi, rpmdb db, struct sharedFileInfo *shared, int sharedCount, int reportConflicts, rpmProblemSet probs, rpmtransFlags transFlags)
int | handleRmvdInstalledFiles (TFI_t fi, rpmdb db, struct sharedFileInfo *shared, int sharedCount)
void | handleOverlappedFiles (TFI_t fi, hashTable ht, rpmProblemSet probs, struct diskspaceInfo *dsl)
| Update disk space needs on each partition for this package.
int | ensureOlder (struct availablePackage *alp, Header old, rpmProblemSet probs)
void | skipFiles (const rpmTransactionSet ts, TFI_t fi)
int | tsGetOc (void *a)
| Return transaction element order count.
availablePackage * | tsGetAlp (void *a)
| Return transaction element available package pointer.
void * | tsFreeIterator (const void *a)
| Destroy transaction element iterator.
void * | tsInitIterator (const void *a)
| Create transaction element iterator.
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)

## 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. Referenced by rpmRunTransactions().

#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. Referenced by handleOverlappedFiles().

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

| Definition at line 1514 of file transaction.c. Referenced by rpmRunTransactions().

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

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

## Function Documentation

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

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

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, fileAction, fileTypes, LINK, REG, RPMFILE_MISSINGOK, RPMFILE_NOREPLACE, RPMMESS_DEBUG, rpmMessage, RPMTRANS_FLAG_ALLFILES, rpmtransFlags, stpcpy(), whatis(), and XDIR. Referenced by handleInstInstalledFiles().

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

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

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 fileTypes, LINK, REG, and whatis(). Referenced by handleInstInstalledFiles(), and handleOverlappedFiles().

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

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

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

| Definition at line 270 of file transaction.c. References BDEV, CDEV, fileTypes, LINK, PIPE, REG, SOCK, and XDIR. Referenced by relocateFileList().

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, decideFileFate(), transactionFileInfo_s::dil, transactionFileInfo_s::dnl, transactionFileInfo_s::fflags, filecmp(), transactionFileInfo_s::flinks, transactionFileInfo_s::fmd5s, transactionFileInfo_s::fmodes, Header, transactionFileInfo_s::hfd, HFD_t, transactionFileInfo_s::hge, HGE_t, sharedFileInfo::isRemoved, sharedFileInfo::otherFileNum, sharedFileInfo::otherPkg, sharedFileInfo::pkgFileNum, psAppend(), transactionFileInfo_s::replaced, transactionFileInfo_s::replacedSizes, rpmdbFreeIterator(), RPMDBI_PACKAGES, rpmdbInitIterator(), rpmdbNextIterator(), RPMFILE_CONFIG, RPMFILE_STATE_NORMAL, RPMPROB_FILE_CONFLICT, rpmProblemSet, RPMTAG_FILEFLAGS, RPMTAG_FILELINKTOS, RPMTAG_FILEMD5S, RPMTAG_FILEMODES, RPMTAG_FILESIZES, RPMTAG_FILESTATES, rpmTagType, rpmtransFlags, TFI_t, uint_16, uint_32, XFA_SKIPPING, xmalloc(), and xrealloc().

Referenced by rpmRunTransactions().

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::ap, BLOCK_ROUND, transactionFileInfo_s::bnl, fprintCacheEntry_s::dev, transactionFileInfo_s::dil, transactionFileInfo_s::dnl, fingerPrint_s::entry, FA_ALTNAME, FA_BACKUP, FA_CREATE, FA_ERASE, FA_SAVE, FA_SKIP, FA_UNKNOWN, transactionFileInfo_s::fc, transactionFileInfo_s::fflags, filecmp(), transactionFileInfo_s::flinks, transactionFileInfo_s::fmd5s, transactionFileInfo_s::fmodes, FP_EQUAL, transactionFileInfo_s::fps, transactionFileInfo_s::fsizes, transactionFileInfo_s::fstates, availablePackage::h, hashTable, htGetEntry(), mdfile(), psAppend(), transactionFileInfo_s::replacedSizes, RPMFILE_CONFIG, RPMFILE_NOREPLACE, RPMFILE_STATE_NORMAL, RPMPROB_NEW_FILE_CONFLICT, rpmProblemSet, stpcpy(), TFI_t, transactionFileInfo_s::type, uint_32, XFA_SKIPPING, and xrealloc().

Referenced by rpmRunTransactions().

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, Header, transactionFileInfo_s::hge, HGE_t, sharedFileInfo::otherFileNum, sharedFileInfo::otherPkg, sharedFileInfo::pkgFileNum, rpmdbFreeIterator(), RPMDBI_PACKAGES, rpmdbInitIterator(), rpmdbNextIterator(), RPMFILE_STATE_NORMAL, RPMTAG_FILESTATES, and TFI_t. Referenced by rpmRunTransactions().

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

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

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, Header, 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, rpmProblem, rpmProblemSet, rpmProblemType, stpcpy(), rpmProblem_s::str1, rpmProblem_s::type, rpmProblem_s::ulong1, availablePackage::version, xmalloc(), and xrealloc().

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

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

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

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, rpmProblemSet, rpmProblem_s::str1, rpmProblem_s::type, and XSTRCMP. Referenced by rpmRunTransactions().

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 _, _free(), alloca(), alloca_strdup, transactionFileInfo_s::bnl, transactionFileInfo_s::dc, transactionFileInfo_s::dil, transactionFileInfo_s::dnl, FA_SKIPMULTILIB, FA_SKIPNSTATE, transactionFileInfo_s::fc, fileAction, fileTypes, ftstring(), transactionFileInfo_s::hae, HAE_t, Header, headerCopy(), headerIsEntry(), headerLink(), transactionFileInfo_s::hfd, HFD_t, transactionFileInfo_s::hge, HGE_t, transactionFileInfo_s::hme, HME_t, rpmTransactionSet_s::ignoreSet, int_32, isFileMULTILIB, availablePackage::multiLib, rpmRelocation_s::newPath, rpmRelocation_s::oldPath, rpmTransactionSet_s::probs, psAppend(), availablePackage::relocs, RPM_INT32_TYPE, RPM_STRING_ARRAY_TYPE, RPMMESS_DEBUG, rpmMessage, RPMPROB_BADRELOCATE, RPMPROB_FILTER_FORCERELOCATE, rpmProblemSet, rpmRelocation, RPMTAG_BASENAMES, RPMTAG_DIRINDEXES, RPMTAG_DIRNAMES, RPMTAG_FILEFLAGS, RPMTAG_FILEMODES, RPMTAG_INSTPREFIXES, RPMTAG_ORIGBASENAMES, RPMTAG_ORIGDIRINDEXES, RPMTAG_ORIGDIRNAMES, RPMTAG_PREFIXES, rpmTagType, rpmTransactionSet, stpcpy(), stripTrailingChar(), TFI_t, uint_16, uint_32, whatis(), XDIR, xmalloc(), and xrealloc().

Referenced by rpmRunTransactions().

void rpmProblemSetFree | ( | rpmProblemSet | probs | ) |

Destroy problem set.

Parameters:

  probs | problem set

Definition at line 256 of file transaction.c.

References _free(), rpmProblem_s::altNEVR, rpmProblem_s::h, headerFree(), rpmProblemSet_s::numProblems, rpmProblem_s::pkgNEVR, rpmProblemSet_s::probs, rpmProblem, rpmProblemSet, and rpmProblem_s::str1.

Referenced by rpmInstall(), rpmRollback(), and rpmtransRun().

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

| Definition at line 771 of file transaction.c. Referenced by rpmRunTransactions().

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, FA_SKIPNETSHARED, FA_SKIPNSTATE, transactionFileInfo_s::fc, transactionFileInfo_s::fflags, transactionFileInfo_s::flangs, transactionFileInfo_s::fmodes, freeSplitString(), rpmExpand(), rpmExpandNumeric(), RPMFILE_DOC, RPMMESS_DEBUG, rpmMessage, RPMTRANS_FLAG_NODOCS, rpmTransactionSet, splitString(), TFI_t, rpmTransactionSet_s::transFlags, whatis(), XDIR, and XFA_SKIPPING.

Referenced by rpmRunTransactions().

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().

Referenced by rpmRunTransactions().

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 rpmTransactionSet_s::addedPackages, rpmTransactionSet_s::flList, availableList_s::list, rpmTransactionSet_s::order, rpmTransactionSet, TFI_t, transactionFileInfo_s::type, and transactionElement_s::u.

Referenced by rpmRunTransactions().

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.

Referenced by rpmRunTransactions().

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, rpmTransactionSet_s::transFlags, and xcalloc().

Referenced by rpmRunTransactions().

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, rpmTransactionSet_s::orderCount, rpmTransactionSet, and TFI_t.

Referenced by rpmRunTransactions().

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

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