#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"
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 KNOWN_INPUT_SIZE | ( | s | ) | ((s)->count != RDD_WHOLE_FILE) |
Definition at line 73 of file robustcopier.c.
typedef struct _RDD_ROBUST_COPIER RDD_ROBUST_COPIER |
typedef enum _read_mode_t read_mode_t |
enum _read_mode_t |
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().
static int handle_read_error | ( | RDD_ROBUST_COPIER * | state, | |
RDD_READER * | reader, | |||
unsigned char * | buf, | |||
unsigned | rsize | |||
) | [static] |
Definition at line 264 of file robustcopier.c.
References _RDD_ROBUST_COPIER::curblocklen, errlognl(), _RDD_ROBUST_COPIER::minblocklen, _RDD_ROBUST_COPIER::mode, _RDD_ROBUST_COPIER::nbyte, _RDD_ROBUST_COPIER::nok, _RDD_ROBUST_COPIER::nread_err, _RDD_ROBUST_COPIER::nretry, _RDD_ROBUST_COPIER::ntry, _RDD_ROBUST_COPIER::offset, RDD_ABORTED, RDD_EAGAIN, RDD_EREAD, RDD_OK, rdd_reader_skip(), READ_ERROR, READ_OK, READ_RECOVERY, and _RDD_ROBUST_COPIER::verbose.
static void handle_read_ok | ( | RDD_ROBUST_COPIER * | state, | |
unsigned | rsize, | |||
unsigned | nread | |||
) | [static] |
Definition at line 204 of file robustcopier.c.
References bug(), _RDD_ROBUST_COPIER::curblocklen, errlognl(), KNOWN_INPUT_SIZE, _RDD_ROBUST_COPIER::maxblocklen, _RDD_ROBUST_COPIER::mode, _RDD_ROBUST_COPIER::nbyte, _RDD_ROBUST_COPIER::nok, _RDD_ROBUST_COPIER::offset, READ_ERROR, READ_OK, READ_RECOVERY, _RDD_ROBUST_COPIER::recovery_threshold, and _RDD_ROBUST_COPIER::verbose.
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.
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 |
RDD_OK
on success. Returns RDD_NOMEM
if there is insufficient memory to create the object.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.
static int robust_exec | ( | RDD_COPIER * | c, | |
RDD_READER * | r, | |||
RDD_FILTERSET * | fset, | |||
RDD_COPIER_RETURN * | ret | |||
) | [static] |
Definition at line 336 of file robustcopier.c.
References RDD_ALIGNEDBUF::aligned, _RDD_ROBUST_COPIER::count, _RDD_ROBUST_COPIER::curblocklen, handle_eof(), handle_read_error(), handle_read_ok(), _RDD_ROBUST_COPIER::maxsubst, _RDD_ROBUST_COPIER::nbyte, _RDD_COPIER_RETURN::nbyte, _RDD_ROBUST_COPIER::nlost, _RDD_COPIER_RETURN::nlost, _RDD_ROBUST_COPIER::nread_err, _RDD_COPIER_RETURN::nread_err, _RDD_ROBUST_COPIER::nsubst, _RDD_COPIER_RETURN::nsubst, _RDD_ROBUST_COPIER::offset, _RDD_ROBUST_COPIER::progressenv, _RDD_ROBUST_COPIER::progressfun, RDD_ABORTED, RDD_EAGAIN, RDD_EREAD, rdd_fset_close(), rdd_fset_push(), RDD_OK, rdd_open_atomic_reader(), rdd_reader_close(), rdd_reader_read(), rdd_reader_skip(), _RDD_ROBUST_COPIER::readbuf, _RDD_ROBUST_COPIER::readerrenv, _RDD_ROBUST_COPIER::readerrfun, _RDD_COPIER::state, _RDD_ROBUST_COPIER::substenv, and _RDD_ROBUST_COPIER::substfun.
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.
char copyright[] [static] |
Initial value:
"@(#) Copyright (c) 2002\n\ Netherlands Forensic Institute. All rights reserved.\n"
Definition at line 39 of file robustcopier.c.
RDD_COPY_OPS robust_ops [static] |