PAYLOAD.
Collaboration diagram for PAYLOAD.:

## Files

file | fsm.c
| File state machine to handle a payload from a package.
file | fsm.h
| File state machine to handle a payload within an rpm package.
file | psm.c
| Package state machine to handle a package from a transaction set.
file | psm.h
| Package state machine to handle a package from a transaction set.
file | rpmlib.h
| In Memoriam: Steve Taylor stayl.nosp@m.or@r.nosp@m.edhat.nosp@m..com was here, now he's not.
file | ar.c
| Handle ar(1) archives.
file | ar.h
| Structures used for ar(1) archives.
file | cpio.c
| Handle cpio(1) archives.
file | cpio.h
| Structures used for cpio(1) archives.
file | iosm.c
| File state machine to handle a payload from a package.
file | iosm.h
| File state machine to handle archive I/O and system call's.
file | tar.c
| Handle ustar archives.
file | tar.h
| Structures used for tar(1) archives.

## Data Structures

struct | dnli_s
| Directory name iterator. More...
struct | arHeader_s
| ar(1) archive header. More...
struct | cpioCrcPhysicalHeader_s
| Cpio archive header information. More...
struct | tarHeader_s
| Tar archive header information. More...

## Typedefs

typedef struct dnli_s * | DNLI_t
| Directory name iterator. More...
typedef struct iosm_s * | FSM_t
| File state machine data. More...
typedef struct iosmIterator_s * | FSMI_t
| Iterator across package file info, forward on install, backward on erase. More...
typedef struct dnli_s * | DNLI_t
| Directory name iterator. More...
typedef struct iosm_s * | IOSM_t
| File state machine data. More...
typedef enum iosmMapFlags_e | iosmMapFlags

## Enumerations

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) }

## Functions

static const char * | fsmFsPath (const IOSM_t fsm, const struct stat *st, const char *subdir, const char *suffix)
| Build path to file from file info, ornamented with subdir and suffix. More...
static void * | mapFreeIterator (void *p)
| Destroy file info iterator. More...
static void * | mapInitIterator (rpmfi fi, int reverse)
| Create file info iterator. More...
static int | mapNextIterator (void *a)
| Return next index into file info. More...
static int | cpioStrCmp (const void *a, const void *b)
static int | mapFind (FSMI_t iter, const char *fsmPath)
| Locate archive path in file info. More...
static void * | dnlFreeIterator (const void *a)
| Destroy directory name iterator. More...
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. More...
static const char * | dnlNextIterator (DNLI_t dnli)
| Return next directory name (from file info). More...
static int | saveHardLink (IOSM_t fsm)
| Save hard link in chain. More...
static void * | freeHardLink (struct hardLink_s *li)
| Destroy set of hard links. More...
static int | extractRegular (IOSM_t fsm)
| Create file from payload stream. More...
static int | writeFile (IOSM_t fsm, int writeData)
| Write next item to payload stream. More...
static int | writeLinkedFile (IOSM_t fsm)
| Write set of linked files to payload stream. More...
static int | fsmMakeLinks (IOSM_t fsm)
| Create pending hard links to existing file. More...
static int | fsmCommitLinks (IOSM_t fsm)
| Commit hard linked file set atomically. More...
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. More...
static int | iosmStrCmp (const void *a, const void *b)
static int | mapFind (IOSMI_t iter, const char *iosmPath)
| Locate archive path in file info. More...
static int | iosmMakeLinks (IOSM_t iosm)
| Create pending hard links to existing file. More...
static int | iosmCommitLinks (IOSM_t iosm)
| Commit hard linked file set atomically. More...
char * | iosmStrerror (int rc)
| Return formatted error message on payload handling failure. More...

## Detailed Description

## Typedef Documentation

typedef struct dnli_s * DNLI_t

Directory name iterator.

typedef struct dnli_s * DNLI_t

Directory name iterator.

typedef struct iosm_s* FSM_t

File state machine data.

Definition at line 14 of file fsm.h.

typedef struct iosmIterator_s* FSMI_t

Iterator across package file info, forward on install, backward on erase.

Definition at line 24 of file fsm.h.

typedef struct iosm_s* IOSM_t

File state machine data.

Definition at line 15 of file iosm.h.

typedef enum iosmMapFlags_e iosmMapFlags

## Enumeration Type Documentation

enum iosmMapFlags_e

Enumerator
IOSM_MAP_PATH |
IOSM_MAP_MODE |
IOSM_MAP_UID |
IOSM_MAP_GID |
IOSM_FOLLOW_SYMLINKS | only for building.
IOSM_MAP_ABSOLUTE |
IOSM_MAP_ADDDOT |
IOSM_ALL_HARDLINKS | fail if hardlinks are missing.
IOSM_MAP_TYPE | only for building.
IOSM_SBIT_CHECK |
IOSM_PAYLOAD_LIST |
IOSM_PAYLOAD_EXTRACT |
IOSM_PAYLOAD_CREATE |

Definition at line 42 of file iosm.h.

## Function Documentation

static int cpioStrCmp | ( | const void * | a,
|  | const void * | b
| ) |  |

static

Definition at line 196 of file fsm.c.

References urlPath().

Referenced by mapFind().

static int dnlCount | ( | const DNLI_t | dnli | ) |

inlinestatic

Definition at line 284 of file fsm.c.

References dnli_s::fi.

Referenced by fsmMkdirs(), and fsmRmdirs().

static void* dnlFreeIterator | ( | const void * | a | ) |

static

Destroy directory name iterator.

Parameters

  a | directory name iterator

Return values

  NULL | always

Definition at line 272 of file fsm.c.

References _free(), and dnli_s::active.

Referenced by fsmMkdirs(), and fsmRmdirs().

static int dnlIndex | ( | const DNLI_t | dnli | ) |

inlinestatic

Definition at line 292 of file fsm.c.

References dnli_s::isave.

Referenced by fsmMkdirs(), and fsmRmdirs().

static void* dnlInitIterator | ( | const IOSM_t | fsm,
|  | int | reverse
| ) |  |

static

Create directory name iterator.

Parameters

  fsm | file state machine data
  reverse | traverse directory names in reverse order?

Returns
  directory name iterator

Definition at line 306 of file fsm.c.

References dnli_s::active, D_, dnli_s::fi, fsmGetFi(), dnli_s::i, iosmFileActionSkipped(), reverse, dnli_s::reverse, rpmfiInit(), rpmfiNext(), rpmlog(), RPMLOG_DEBUG, urlPath(), and xcalloc().

Referenced by fsmMkdirs(), and fsmRmdirs().

static const char* dnlNextIterator | ( | DNLI_t | dnli | ) |

static

Return next directory name (from file info).

Parameters

  dnli | directory name iterator

Returns
  next directory name

Definition at line 393 of file fsm.c.

References dnli_s::active, dnli_s::fi, dnli_s::i, dnli_s::isave, and dnli_s::reverse.

Referenced by fsmMkdirs(), and fsmRmdirs().

static int extractRegular | ( | IOSM_t | fsm | ) |

static

Create file from payload stream.

Parameters

  fsm | file state machine data

Returns
  0 on success

Definition at line 979 of file fsm.c.

References _free(), fdFiniDigest(), fdInitDigest(), Fflush(), Fileno(), fsmNext(), IOSM_DREAD, IOSM_NOTIFY, IOSM_WCLOSE, IOSM_WOPEN, and IOSM_WRITE.

Referenced by fsmStage().

static void* freeHardLink | ( | struct hardLink_s * | li | ) |

static

Destroy set of hard links.

Parameters

  li | set of hard links

Returns
  NULL always

Definition at line 531 of file fsm.c.

References _free().

Referenced by freeFSM(), and fsmStage().

static int fsmCommitLinks | ( | IOSM_t | fsm | ) |

static

Commit hard linked file set atomically.

Parameters

  fsm | file state machine data

Returns
  0 on success

Definition at line 1321 of file fsm.c.

References _free(), fsmNext(), IOSM_COMMIT, IOSM_MAP, and iosmFileActionSkipped().

Referenced by fsmStage().

static const char* fsmFsPath | ( | const IOSM_t | fsm,
|  | const struct stat * | st,
|  | const char * | subdir,
|  | const char * | suffix
| ) |  |

static

Build path to file from file info, ornamented with subdir and suffix.

Parameters

  fsm | file state machine data
  st | file stat info
  subdir | subdir to use (NULL disables)
  suffix | suffix to use (NULL disables)

Return values

  path | to file

Definition at line 100 of file fsm.c.

References stpcpy(), and xmalloc().

Referenced by fsmMapPath(), and fsmStage().

static int fsmMakeLinks | ( | IOSM_t | fsm | ) |

static

Create pending hard links to existing file.

Parameters

  fsm | file state machine data

Returns
  0 on success

Definition at line 1260 of file fsm.c.

References _free(), fsmNext(), fsmUNSAFE, IOSM_LINK, IOSM_MAP, IOSM_VERIFY, iosmFileActionSkipped(), and xstrdup().

Referenced by fsmStage().

static int iosmCommitLinks | ( | IOSM_t | iosm | ) |

static

Commit hard linked file set atomically.

Parameters

  iosm | file state machine data

Returns
  0 on success

Definition at line 1377 of file iosm.c.

References _free(), IOSM_COMMIT, IOSM_MAP, iosmFileActionSkipped(), and iosmNext().

Referenced by iosmStage().

static const char* iosmFsPath | ( | const IOSM_t | iosm,
|  | const struct stat * | st,
|  | const char * | subdir,
|  | const char * | suffix
| ) |  |

static

Build path to file from file info, ornamented with subdir and suffix.

Parameters

  iosm | file state machine data
  st | file stat info
  subdir | subdir to use (NULL disables)
  suffix | suffix to use (NULL disables)

Return values

  path | to file

Definition at line 110 of file iosm.c.

References stpcpy(), and xmalloc().

Referenced by iosmMapPath(), and iosmStage().

static int iosmMakeLinks | ( | IOSM_t | iosm | ) |

static

Create pending hard links to existing file.

Parameters

  iosm | file state machine data

Returns
  0 on success

Definition at line 1316 of file iosm.c.

References _free(), IOSM_LINK, IOSM_MAP, IOSM_VERIFY, iosmFileActionSkipped(), iosmNext(), iosmUNSAFE, and xstrdup().

Referenced by iosmStage().

static int iosmStrCmp | ( | const void * | a,
|  | const void * | b
| ) |  |

static

Definition at line 205 of file iosm.c.

References urlPath().

Referenced by mapFind().

char* iosmStrerror | ( | int | rc | ) |

Return formatted error message on payload handling failure.

Parameters

  rc | error code

Returns
  (malloc'd) formatted error string

Definition at line 2769 of file iosm.c.

References _, errno, and xstrdup().

Referenced by cpio_doio(), and rpmpsmStage().

static int mapFind | ( | FSMI_t | iter,
|  | const char * | fsmPath
| ) |  |

static

Locate archive path in file info.

Parameters

  iter | file info iterator
  fsmPath | archive path

Returns
  index into file info, -1 if archive path was not found

Definition at line 230 of file fsm.c.

References cpioStrCmp(), mapNextIterator(), and rpmfiFC().

Referenced by fsmStage().

static int mapFind | ( | IOSMI_t | iter,
|  | const char * | iosmPath
| ) |  |

static

Locate archive path in file info.

Parameters

  iter | file info iterator
  iosmPath | archive path

Returns
  index into file info, -1 if archive path was not found

Definition at line 239 of file iosm.c.

References iosmStrCmp(), mapNextIterator(), and rpmfiFC().

Referenced by iosmStage().

static void* mapFreeIterator | ( | void * | p | ) |

static

Destroy file info iterator.

Parameters

  p | file info iterator

Return values

  NULL | always

Definition at line 132 of file fsm.c.

References _free(), rpmfiUnlink(), and rpmtsFree().

Referenced by freeFSM(), and fsmTeardown().

static void* mapInitIterator | ( | rpmfi | fi,
|  | int | reverse
| ) |  |

static

Create file info iterator.

Parameters

  fi | transaction element file info
  reverse | iterate in reverse order?

Returns
  file info iterator

Definition at line 154 of file fsm.c.

References reverse, rpmfiLink(), and xcalloc().

Referenced by fsmSetup().

static int mapNextIterator | ( | void * | a | ) |

static

Return next index into file info.

Parameters

  a | file info iterator

Returns
  next index, -1 on termination

Definition at line 174 of file fsm.c.

Referenced by fsmStage(), and mapFind().

static int saveHardLink | ( | IOSM_t | fsm | ) |

static

Save hard link in chain.

Parameters

  fsm | file state machine data

Returns
  Is chain only partially filled?

Definition at line 445 of file fsm.c.

References _free(), fsmGetFi(), fsmNext(), IOSM_MAP, IOSM_PKGBUILD, IOSM_PKGINSTALL, iosmFileActionSkipped(), and xcalloc().

Referenced by fsmStage().

static int writeFile | ( | IOSM_t | fsm,
|  | int | writeData
| ) |  |

static

Write next item to payload stream.

Parameters

  fsm | file state machine data
  writeData | should data be written?

Returns
  0 on success

Definition at line 1051 of file fsm.c.

References alloca(), Fileno(), fsmGetFi(), fsmNext(), fsmUNSAFE, IOSM_DWRITE, IOSM_HWRITE, IOSM_MAP_ABSOLUTE, IOSM_MAP_ADDDOT, IOSM_MAP_PATH, IOSM_PAD, IOSM_RCLOSE, IOSM_READ, IOSM_READLINK, IOSM_ROPEN, S_ISLNK, stpcpy(), urlPath(), and xstrdup().

Referenced by fsmStage(), and writeLinkedFile().

static int writeLinkedFile | ( | IOSM_t | fsm | ) |

static

Write set of linked files to payload stream.

Parameters

  fsm | file state machine data

Returns
  0 on success

Definition at line 1186 of file fsm.c.

References _free(), fsmNext(), IOSM_MAP, stpcpy(), tarHeaderWrite(), urlPath(), writeFile(), xmalloc(), and xstrdup().

Referenced by fsmStage().