rpm 5.3.7
Defines | Functions | Variables

rpmio/cpio.c File Reference

Handle cpio(1) archives. More...

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

Go to the source code of this file.

Defines

#define _IOSM_INTERNAL
#define _IOSMRC(_rc)   if ((_rc) <= 0) return ((_rc) ? (int) -rc : IOSMERR_HDR_TRAILER)
#define GET_NUM_FIELD(phys, log)
#define SET_NUM_FIELD(phys, val, space)

Functions

static int strntoul (const char *str, char **endptr, int base, size_t num)
 Convert string to unsigned integer (with buffer size check).
static ssize_t cpioRead (void *_iosm, void *buf, size_t count)
int cpioHeaderRead (void *_iosm, struct stat *st)
 Read cpio header.
static ssize_t cpioWrite (void *_iosm, const void *buf, size_t count)
int cpioHeaderWrite (void *_iosm, struct stat *st)
 Write cpio header.
int cpioTrailerWrite (void *_iosm)
 Write cpio trailer.

Variables

int _cpio_debug = 0

Detailed Description

Handle cpio(1) archives.

Definition in file cpio.c.


Define Documentation

#define _IOSM_INTERNAL

Definition at line 12 of file cpio.c.

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

Definition at line 54 of file cpio.c.

Referenced by cpioHeaderRead(), cpioHeaderWrite(), and cpioTrailerWrite().

#define GET_NUM_FIELD (   phys,
  log 
)
Value:
log = strntoul(phys, &end, 16, sizeof(phys)); \
        if ( (end - phys) != sizeof(phys) ) return IOSMERR_BAD_HEADER;

Definition at line 88 of file cpio.c.

Referenced by cpioHeaderRead().

#define SET_NUM_FIELD (   phys,
  val,
  space 
)
Value:
sprintf(space, "%8.8lx", (unsigned long) (val)); \
        memcpy(phys, space, 8)

Definition at line 91 of file cpio.c.

Referenced by cpioHeaderWrite().


Function Documentation

int cpioHeaderRead ( void *  _iosm,
struct stat *  st 
)
int cpioHeaderWrite ( void *  _iosm,
struct stat *  st 
)
static ssize_t cpioRead ( void *  _iosm,
void *  buf,
size_t  count 
) [static]

Definition at line 57 of file cpio.c.

References _cpio_debug, _iosmNext, and IOSM_DREAD.

Referenced by cpioHeaderRead().

int cpioTrailerWrite ( void *  _iosm)

Write cpio trailer.

Return values:
_iosmfile path and stat info
Returns:
0 on success

Definition at line 279 of file cpio.c.

References _cpio_debug, _iosmNext, _IOSMRC, CPIO_NEWC_MAGIC, CPIO_TRAILER, cpioWrite(), IOSM_PAD, cpioCrcPhysicalHeader_s::magic, cpioCrcPhysicalHeader_s::namesize, cpioCrcPhysicalHeader_s::nlink, and PHYS_HDR_SIZE.

Referenced by fsmSetup(), and iosmSetup().

static ssize_t cpioWrite ( void *  _iosm,
const void *  buf,
size_t  count 
) [static]

Definition at line 188 of file cpio.c.

References _cpio_debug, _iosmNext, IOSM_DWRITE, and IOSM_PAD.

Referenced by cpioHeaderWrite(), and cpioTrailerWrite().

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

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

Parameters:
strinput string
Return values:
*endptr1st character not processed
Parameters:
basenumerical conversion base
nummax no. of bytes to read
Returns:
converted integer

Definition at line 30 of file cpio.c.

References alloca().


Variable Documentation

int _cpio_debug = 0

Definition at line 20 of file cpio.c.

Referenced by cpioHeaderRead(), cpioHeaderWrite(), cpioRead(), cpioTrailerWrite(), and cpioWrite().