rpm  5.4.10
Macros | Functions | Variables
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.

Macros

#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). More...
 
static ssize_t cpioRead (void *_iosm, void *buf, size_t count)
 
int cpioHeaderRead (void *_iosm, struct stat *st)
 Read cpio header. More...
 
static ssize_t cpioWrite (void *_iosm, const void *buf, size_t count)
 
int cpioHeaderWrite (void *_iosm, struct stat *st)
 Write cpio header. More...
 
int cpioTrailerWrite (void *_iosm)
 Write cpio trailer. More...
 

Variables

int _cpio_debug = 0
 

Detailed Description

Handle cpio(1) archives.

Definition in file cpio.c.

Macro Definition Documentation

§ _IOSM_INTERNAL

#define _IOSM_INTERNAL

Definition at line 12 of file cpio.c.

§ _IOSMRC

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

Definition at line 55 of file cpio.c.

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

§ GET_NUM_FIELD

#define GET_NUM_FIELD (   phys,
  log 
)
Value:
log = strntoul(phys, &end, 16, sizeof(phys)); \
if ( (end - phys) != sizeof(phys) ) return IOSMERR_BAD_HEADER;
static int strntoul(const char *str, char **endptr, int base, size_t num)
Convert string to unsigned integer (with buffer size check).
Definition: cpio.c:30

Definition at line 89 of file cpio.c.

Referenced by cpioHeaderRead().

§ SET_NUM_FIELD

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

Definition at line 92 of file cpio.c.

Referenced by cpioHeaderWrite().

Function Documentation

§ cpioHeaderRead()

int cpioHeaderRead ( void *  _iosm,
struct stat *  st 
)

§ cpioHeaderWrite()

int cpioHeaderWrite ( void *  _iosm,
struct stat *  st 
)

§ cpioRead()

static ssize_t cpioRead ( void *  _iosm,
void *  buf,
size_t  count 
)
static

Definition at line 58 of file cpio.c.

References _cpio_debug, _iosmNext, IOSM_DREAD, IOSMERR_READ_FAILED, iosm_s::rdnb, iosm_s::wrbuf, and iosm_s::wrlen.

Referenced by cpioHeaderRead().

§ cpioTrailerWrite()

int cpioTrailerWrite ( void *  _iosm)

Write cpio trailer.

Return values
_iosmfile path and stat info
Returns
0 on success

Definition at line 280 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, PHYS_HDR_SIZE, and iosm_s::rdbuf.

Referenced by fsmSetup(), and iosmSetup().

§ cpioWrite()

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

§ strntoul()

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

§ _cpio_debug

int _cpio_debug = 0

Definition at line 20 of file cpio.c.

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