rpm 5.2.1

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

- File List
- Globals

Macros | Functions | Variables
tar.c File Reference
PAYLOAD.

Handle ustar archives. More...

`#include "system.h"`
`#include <rpmio.h>`
`#include <ugid.h>`
`#include <tar.h>`
`#include <iosm.h>`
`#include "debug.h"`
Include dependency graph for tar.c:

Go to the source code of this file.

## Macros
#define | _IOSM_INTERNAL
#define | _IOSMRC(_rc) if ((_rc) <= 0) return ((_rc) ? (int) -rc : IOSMERR_HDR_TRAILER)

## Functions
static int | strntoul (const char *str, char **endptr, int base, size_t num)
| Convert string to unsigned integer (with buffer size check). More...
static ssize_t | tarRead (void *_iosm, void *buf, size_t count)
static ssize_t | tarHeaderReadName (void *_iosm, size_t len, const char **fnp)
| Read long file/link name from tar archive. More...
int | tarHeaderRead (void *_iosm, struct stat *st)
| Read tar header from payload. More...
static ssize_t | tarWrite (void *_iosm, const void *buf, size_t count)
static ssize_t | tarHeaderWriteName (void *_iosm, const char *path)
| Write long file/link name into tar archive. More...
static ssize_t | tarHeaderWriteBlock (void *_iosm, struct stat *st, tarHeader hdr)
| Write tar header block with checksum into tar archive. More...
int | tarHeaderWrite (void *_iosm, struct stat *st)
| Write tar header to payload. More...
int | tarTrailerWrite (void *_iosm)
| Write cpio trailer to payload. More...

## Variables
int | _tar_debug = 0
static int | nochksum = 0

## Detailed Description

Handle ustar archives.

Definition in file tar.c.

## Macro Definition Documentation

#define _IOSM_INTERNAL

Definition at line 13 of file tar.c.

#define _IOSMRC | ( |  | _rc | ) | if ((_rc) <= 0) return ((_rc) ? (int) -rc : IOSMERR_HDR_TRAILER)

Definition at line 58 of file tar.c.

Referenced by tarHeaderRead(), tarHeaderWrite(), and tarTrailerWrite().

## Function Documentation

static int strntoul | ( | const char * | str,
|  | char ** | endptr,
|  | int | base,
|  | size_t | num
| ) |  |
| static

Convert string to unsigned integer (with buffer size check).

Parameters

  str | input string

Return values

  *endptr | 1st character not processed

Parameters

  base | numerical conversion base
  num | max no. of bytes to read

Returns
  converted integer

Definition at line 34 of file tar.c.

References alloca().

Referenced by tarHeaderRead().

int tarHeaderRead | ( | void * | _iosm,
|  | struct stat * | st
| ) |  |

Read tar header from payload.

Return values

  _iosm | file path and stat info
  st |

Returns
  0 on success

Definition at line 122 of file tar.c.

References _IOSMRC, _tar_debug, tarHeader_s::checksum, tarHeader_s::devMajor, tarHeader_s::devMinor, tarHeader_s::filesize, tarHeader_s::gid, tarHeader_s::linkname, tarHeader_s::magic, major, Makedev, minor, tarHeader_s::mode, tarHeader_s::mtime, tarHeader_s::name, nochksum, strntoul(), TAR_BLOCK_SIZE, TAR_MAGIC, tarHeaderReadName(), tarRead(), tarHeader_s::typeflag, tarHeader_s::uid, and xmalloc().

Referenced by fsmSetup(), and iosmSetup().

static ssize_t tarHeaderReadName | ( | void * | _iosm,
|  | size_t | len,
|  | const char ** | fnp
| ) |  |
| static

Read long file/link name from tar archive.

Parameters

  _iosm | file state machine
  len | no. bytes of name

Return values

  *fnp | long file/link name

Returns
  no. bytes read (rc < 0 on error)

Definition at line 99 of file tar.c.

References _free(), _tar_debug, tarRead(), and xmalloc().

Referenced by tarHeaderRead().

int tarHeaderWrite | ( | void * | _iosm,
|  | struct stat * | st
| ) |  |

Write tar header to payload.

Return values

  _iosm | file path and stat info

Parameters

  st |

Returns
  0 on success

Definition at line 385 of file tar.c.

References _iosmNext, _IOSMRC, _tar_debug, tarHeader_s::devMajor, tarHeader_s::devMinor, tarHeader_s::filesize, tarHeader_s::gid, gidToGname(), tarHeader_s::gname, IOSM_PAD, tarHeader_s::linkname, major, minor, tarHeader_s::mode, tarHeader_s::mtime, tarHeader_s::name, S_ISLNK, S_ISSOCK, tarHeaderWriteBlock(), tarHeaderWriteName(), tarHeader_s::typeflag, tarHeader_s::uid, uidToUname(), and tarHeader_s::uname.

Referenced by fsmSetup(), iosmSetup(), and writeLinkedFile().

static ssize_t tarHeaderWriteBlock | ( | void * | _iosm,
|  | struct stat * | st,
|  | tarHeader | hdr
| ) |  |
| static

Write tar header block with checksum into tar archive.

Parameters

  _iosm | file state machine
  st | file info
  hdr | tar header block

Returns
  no. bytes written (rc < 0 on error)

Definition at line 349 of file tar.c.

References _tar_debug, tarHeader_s::checksum, tarHeader_s::magic, stpcpy(), TAR_BLOCK_SIZE, TAR_MAGIC, TAR_VERSION, tarWrite(), and tarHeader_s::typeflag.

Referenced by tarHeaderWrite().

static ssize_t tarHeaderWriteName | ( | void * | _iosm,
|  | const char * | path
| ) |  |
| static

Write long file/link name into tar archive.

Parameters

  _iosm | file state machine
  path | long file/link name

Returns
  no. bytes written (rc < 0 on error)

Definition at line 323 of file tar.c.

References _iosmNext, _tar_debug, IOSM_PAD, and tarWrite().

Referenced by tarHeaderWrite().

static ssize_t tarRead | ( | void * | _iosm,
|  | void * | buf,
|  | size_t | count
| ) |  |
| static

Definition at line 61 of file tar.c.

References _iosmNext, _tar_debug, and IOSM_DREAD.

Referenced by tarHeaderRead(), and tarHeaderReadName().

int tarTrailerWrite | ( | void * | _iosm | ) |

Write cpio trailer to payload.

Return values

  _fsm | file path and stat info

Returns
  0 on success

Definition at line 495 of file tar.c.

References _iosmNext, _IOSMRC, _tar_debug, IOSM_PAD, and tarWrite().

Referenced by fsmSetup(), and iosmSetup().

static ssize_t tarWrite | ( | void * | _iosm,
|  | const void * | buf,
|  | size_t | count
| ) |  |
| static

Definition at line 281 of file tar.c.

References _iosmNext, _tar_debug, IOSM_DWRITE, and IOSM_PAD.

Referenced by tarHeaderWriteBlock(), tarHeaderWriteName(), and tarTrailerWrite().

## Variable Documentation

int _tar_debug = 0

Definition at line 21 of file tar.c.

Referenced by tarHeaderRead(), tarHeaderReadName(), tarHeaderWrite(), tarHeaderWriteBlock(), tarHeaderWriteName(), tarRead(), tarTrailerWrite(), and tarWrite().

int nochksum = 0
| static

Definition at line 24 of file tar.c.

Referenced by tarHeaderRead().