rpm  5.4.10
Macros | Functions | Variables
tar.c File Reference

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).
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.
int tarHeaderRead (void *_iosm, struct stat *st)
 Read tar header from payload.
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.
static ssize_t tarHeaderWriteBlock (void *_iosm, struct stat *st, tarHeader hdr)
 Write tar header block with checksum into tar archive.
int tarHeaderWrite (void *_iosm, struct stat *st)
 Write tar header to payload.
int tarTrailerWrite (void *_iosm)
 Write cpio trailer to payload.

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
strinput string
Return values
*endptr1st 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().

Referenced by tarHeaderRead().

int tarHeaderRead ( void *  _iosm,
struct stat *  st 
)
static ssize_t tarHeaderReadName ( void *  _iosm,
size_t  len,
const char **  fnp 
)
static

Read long file/link name from tar archive.

Parameters
_iosmfile state machine
lenno. bytes of name
Return values
*fnplong 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 
)
static ssize_t tarHeaderWriteBlock ( void *  _iosm,
struct stat *  st,
tarHeader  hdr 
)
static

Write tar header block with checksum into tar archive.

Parameters
_iosmfile state machine
stfile info
hdrtar header block
Returns
no. bytes written (rc < 0 on error)

Definition at line 350 of file tar.c.

References _tar_debug, tarHeader_s::checksum, tarHeader_s::magic, iosm_s::path, 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
_iosmfile state machine
pathlong 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
int tarTrailerWrite ( void *  _iosm)

Write cpio trailer to payload.

Return values
_fsmfile path and stat info
Returns
0 on success

Definition at line 499 of file tar.c.

References _iosmNext, _IOSMRC, _tar_debug, iosm_s::blksize, IOSM_PAD, and tarWrite().

Referenced by fsmSetup(), and iosmSetup().

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

Variable Documentation

int _tar_debug = 0
int nochksum = 0
static

Definition at line 24 of file tar.c.

Referenced by tarHeaderRead().