src/robustcopier.c File Reference

#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "rdd.h"
#include "rdd_internals.h"
#include "commandline.h"
#include "reader.h"
#include "writer.h"
#include "filter.h"
#include "filterset.h"
#include "copier.h"
#include "error.h"
#include "netio.h"
#include "alignedbuf.h"
#include "progress.h"

Include dependency graph for robustcopier.c:

Go to the source code of this file.

Data Structures

struct  _RDD_ROBUST_COPIER

Defines

#define KNOWN_INPUT_SIZE(s)   ((s)->count != RDD_WHOLE_FILE)

Typedefs

typedef struct _RDD_ROBUST_COPIER RDD_ROBUST_COPIER
typedef enum _read_mode_t read_mode_t

Enumerations

enum  _read_mode_t { READ_OK, READ_ERROR, READ_RECOVERY }

Functions

static void handle_eof (RDD_ROBUST_COPIER *state)
static int handle_read_error (RDD_ROBUST_COPIER *state, RDD_READER *reader, unsigned char *buf, unsigned rsize)
static void handle_read_ok (RDD_ROBUST_COPIER *state, unsigned rsize, unsigned nread)
int rdd_new_robust_copier (RDD_COPIER **self, rdd_count_t offset, rdd_count_t count, RDD_ROBUST_PARAMS *p)
 Creates a new robust copier.
static int robust_exec (RDD_COPIER *c, RDD_READER *r, RDD_FILTERSET *fset, RDD_COPIER_RETURN *ret)
static int robust_free (RDD_COPIER *c)

Variables

static char copyright []
static RDD_COPY_OPS robust_ops


Define Documentation

#define KNOWN_INPUT_SIZE (  )     ((s)->count != RDD_WHOLE_FILE)

Definition at line 73 of file robustcopier.c.


Typedef Documentation

typedef enum _read_mode_t read_mode_t


Enumeration Type Documentation

Enumerator:
READ_OK 
READ_ERROR 
READ_RECOVERY 

Definition at line 75 of file robustcopier.c.


Function Documentation

static void handle_eof ( RDD_ROBUST_COPIER state  )  [static]

Definition at line 192 of file robustcopier.c.

References _RDD_ROBUST_COPIER::count, error(), KNOWN_INPUT_SIZE, _RDD_ROBUST_COPIER::nbyte, and rdd_strsize().

Here is the call graph for this function:

static int handle_read_error ( RDD_ROBUST_COPIER state,
RDD_READER reader,
unsigned char *  buf,
unsigned  rsize 
) [static]

static void handle_read_ok ( RDD_ROBUST_COPIER state,
unsigned  rsize,
unsigned  nread 
) [static]

int rdd_new_robust_copier ( RDD_COPIER **  c,
rdd_count_t  offset,
rdd_count_t  count,
RDD_ROBUST_PARAMS params 
)

Creates a new robust copier.

Parameters:
c output value: will be set to a pointer to the new robust copier object.
offset byte offset; where to start copying
count the maximum number of bytes to copy
params the copier's error-handling parameters
Returns:
Returns RDD_OK on success. Returns RDD_NOMEM if there is insufficient memory to create the object.
A robust copier behaves like a simple copier as long as no errors occur and if the offset and count arguments are both set to zero.

The offset and count arguments are used to read a contiguous segment from the input stream supplied to rdd_copy_exec(): offset bytes from the input stream are skipped before the copier starts copying data and copying stops when count bytes have been copied or when end-of-file is encountered.

The parameters params specify the copier's behavior when read errors occur. A robust copier will enter a retry phase when a read fails. In that phase it reduces the amount of data it reads at a time and it will retry reads that fail.

Definition at line 120 of file robustcopier.c.

References _RDD_ROBUST_COPIER::count, _RDD_ROBUST_COPIER::curblocklen, error(), _RDD_ROBUST_COPIER::maxblocklen, _RDD_ROBUST_PARAMS::maxblocklen, _RDD_ROBUST_PARAMS::maxsubst, _RDD_ROBUST_COPIER::maxsubst, _RDD_ROBUST_COPIER::minblocklen, _RDD_ROBUST_PARAMS::minblocklen, _RDD_ROBUST_COPIER::mode, _RDD_ROBUST_COPIER::nbyte, _RDD_ROBUST_COPIER::nlost, _RDD_ROBUST_COPIER::nok, _RDD_ROBUST_COPIER::nread_err, _RDD_ROBUST_PARAMS::nretry, _RDD_ROBUST_COPIER::nretry, _RDD_ROBUST_COPIER::nsubst, _RDD_ROBUST_COPIER::ntry, _RDD_ROBUST_COPIER::offset, _RDD_ROBUST_PARAMS::progressenv, _RDD_ROBUST_COPIER::progressenv, _RDD_ROBUST_PARAMS::progressfun, _RDD_ROBUST_COPIER::progressfun, RDD_BADARG, rdd_new_alignedbuf(), rdd_new_copier(), RDD_OK, RDD_SECTOR_SIZE, READ_OK, _RDD_ROBUST_COPIER::readbuf, _RDD_ROBUST_PARAMS::readerrenv, _RDD_ROBUST_COPIER::readerrenv, _RDD_ROBUST_PARAMS::readerrfun, _RDD_ROBUST_COPIER::readerrfun, _RDD_ROBUST_COPIER::recovery_threshold, _RDD_COPIER::state, _RDD_ROBUST_PARAMS::substenv, _RDD_ROBUST_COPIER::substenv, _RDD_ROBUST_PARAMS::substfun, _RDD_ROBUST_COPIER::substfun, and _RDD_ROBUST_COPIER::verbose.

Here is the call graph for this function:

static int robust_exec ( RDD_COPIER c,
RDD_READER r,
RDD_FILTERSET fset,
RDD_COPIER_RETURN ret 
) [static]

static int robust_free ( RDD_COPIER c  )  [static]

Definition at line 474 of file robustcopier.c.

References rdd_free_alignedbuf(), _RDD_ROBUST_COPIER::readbuf, and _RDD_COPIER::state.

Here is the call graph for this function:


Variable Documentation

char copyright[] [static]

Initial value:

"@(#) Copyright (c) 2002\n\
    Netherlands Forensic Institute.  All rights reserved.\n"

Definition at line 39 of file robustcopier.c.

Initial value:

Definition at line 114 of file robustcopier.c.


Generated on Sun Feb 6 12:36:35 2011 for rdd by  doxygen 1.5.6