rpm  4.5
Functions | Variables
tar.c File Reference

Handle tar payloads within rpm packages. More...

#include "system.h"
#include <rpmio_internal.h>
#include <rpmlib.h>
#include "tar.h"
#include "fsm.h"
#include "ugid.h"
#include "rpmerr.h"
#include "debug.h"
Include dependency graph for tar.c:

Go to the source code of this file.

Functions

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

Variables

int _tar_debug = 0
 
static int nochksum = 0
 

Detailed Description

Handle tar payloads within rpm packages.

Definition in file tar.c.

Function Documentation

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

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

Parameters
strinput string
Return values
endptraddress of 1st character not processed
Parameters
basenumerical conversion base
nummax no. of bytes to read
Returns
converted integer

Definition at line 34 of file tar.c.

References alloca(), and StringBufRec::buf.

Referenced by tarHeaderRead().

int tarHeaderRead ( FSM_t  fsm,
struct stat *  st 
)
static int tarHeaderReadName ( FSM_t  fsm,
int  len,
const char **  fnp 
)
static

Read long file/link name from tar archive.

Parameters
fsmfile state machine
lenno. bytes of name
Return values
*fnplong file/link name
Returns
0 on success

Definition at line 65 of file tar.c.

References _free(), CPIOERR_READ_FAILED, FSM_DREAD, fsmNext(), fsm_s::rdnb, TAR_BLOCK_SIZE, fsm_s::wrbuf, fsm_s::wrlen, and xmalloc().

Referenced by tarHeaderRead().

int tarHeaderWrite ( FSM_t  fsm,
struct stat *  st 
)
static int tarHeaderWriteBlock ( FSM_t  fsm,
struct stat *  st,
tarHeader  hdr 
)
static

Write tar header block with checksum into tar archive.

Parameters
fsmfile state machine
stfile info
hdrtar header block
Returns
0 on success

Definition at line 310 of file tar.c.

References _tar_debug, tarHeader_s::checksum, CPIOERR_WRITE_FAILED, FSM_DWRITE, fsmNext(), tarHeader_s::magic, fsm_s::path, fsm_s::rdnb, stpcpy(), TAR_BLOCK_SIZE, TAR_MAGIC, TAR_VERSION, tarHeader_s::typeflag, and fsm_s::wrnb.

Referenced by tarHeaderWrite().

static int tarHeaderWriteName ( FSM_t  fsm,
const char *  path 
)
static

Write long file/link name into tar archive.

Parameters
fsmfile state machine
pathlong file/link name
Returns
0 on success

Definition at line 271 of file tar.c.

References _tar_debug, CPIOERR_WRITE_FAILED, FSM_DWRITE, FSM_PAD, fsmNext(), fsm_s::rdbuf, fsm_s::rdnb, TAR_BLOCK_SIZE, and fsm_s::wrnb.

Referenced by tarHeaderWrite().

int tarTrailerWrite ( FSM_t  fsm)

Write cpio trailer to payload.

Return values
fsmfile path and stat info
Returns
0 on success

Definition at line 455 of file tar.c.

References _tar_debug, fsm_s::blksize, FSM_PAD, and fsmNext().

Referenced by fsmSetup().

Variable Documentation

int _tar_debug = 0
int nochksum = 0
static

Definition at line 24 of file tar.c.

Referenced by tarHeaderRead().