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

## Function Documentation

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

Definition at line 200 of file transaction.c.

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.

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

Definition at line 1231 of file transaction.c.

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.

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

Definition at line 70 of file transaction.c.

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

Definition at line 270 of file transaction.c.

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.

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.

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

Definition at line 991 of file transaction.c.

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

Definition at line 231 of file transaction.c.

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.

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

Definition at line 124 of file transaction.c.

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

Definition at line 734 of file transaction.c.

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.

void rpmProblemSetFree | ( | rpmProblemSet | probs | ) |

Destroy problem set.

Parameters:

  | probs | problem set

Definition at line 256 of file transaction.c.

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

Definition at line 771 of file transaction.c.

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

Definition at line 1250 of file transaction.c.

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.

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

Return transaction element available package pointer.

Parameters:

  | a | transaction element iterator

Returns:
  available package pointer

Definition at line 1444 of file transaction.c.

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.

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.

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.

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

Definition at line 286 of file transaction.c.