src/rddcopy.c File Reference

#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <limits.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
#include "rdd.h"
#include "rdd_internals.h"
#include "numparser.h"
#include "reader.h"
#include "commandline.h"
#include "error.h"
#include "hashcontainer.h"
#include "writer.h"
#include "filter.h"
#include "filterset.h"
#include "copier.h"
#include "netio.h"
#include "progress.h"
#include "msgprinter.h"

Include dependency graph for rddcopy.c:

Go to the source code of this file.

Data Structures

struct  _rdd_copy_opts
struct  _rdd_output_opt_t

Defines

#define ALL_MODES   (RDD_LOCAL|RDD_CLIENT|RDD_SERVER)
#define bool2str(b)   ((b) ? "yes" : "no")
#define DEFAULT_BLOCK_LEN   262144
#define DEFAULT_BLOCKMD5_SIZE   4096
#define DEFAULT_CHKSUM_BLOCK_SIZE   32768
#define DEFAULT_HIST_BLOCK_SIZE   262144
#define DEFAULT_MAX_READ_ERR   0
#define DEFAULT_MIN_BLOCK_SIZE   32768
#define DEFAULT_NRETRY   1
#define DEFAULT_RDD_SERVER_PORT   4832
#define DEFAULT_RECOVERY_LEN   4
#define RDD_MAX_OUTPUT_OPTS   16
#define RDD_OUTPUT_OPTTAB_OPTION_COUNT   sizeof(output_opttab)/sizeof(RDD_OPTION)
#define str2str(s)   ((s) == 0? "<none>" : (s))

Typedefs

typedef enum _rdd_copy_mode_t rdd_copy_mode_t
typedef struct _rdd_copy_opts rdd_copy_opts
typedef struct _rdd_output_opt_t rdd_output_opt_t

Enumerations

enum  _rdd_copy_mode_t { RDD_LOCAL = 0x1, RDD_CLIENT = 0x2, RDD_SERVER = 0x4 }

Functions

static void add_filter (RDD_FILTERSET *fset, const char *name, RDD_FILTER *f)
static int check_compress_option (char *arg)
static void close_printer (void)
static void command_line (int argc, char **argv)
static RDD_WRITERconnection_exists (RDD_WRITER *writer_list[], int output_number, struct addrinfo *address)
static RDD_COPIERcreate_copier (rdd_count_t input_size, RDD_PROGRESS *progress)
static void fatal_rdd_error (int rdd_errno, char *fmt,...)
static int handle_progress (rdd_count_t pos, rdd_count_t nsubst, void *env)
static void handle_read_error (rdd_count_t offset, unsigned nbyte, void *env)
static void handle_substitution (rdd_count_t offset, unsigned nbyte, void *env)
static void init_options (void)
static void install_filters (RDD_FILTERSET *fset, RDD_WRITER *writers[])
static void log_header (char **argv, int argc)
static void log_params (rdd_copy_opts *opts)
static void logmsg (const char *fmt,...)
int main (int argc, char **argv)
static RDD_READERopen_disk_input (rdd_count_t *inputlen)
static RDD_WRITERopen_disk_output (rdd_count_t outputsize, RDD_HASH_CONTAINER *hashcontainer, int output_number)
static RDD_READERopen_input (rdd_count_t *inputlen)
static void open_logfile (void)
static RDD_READERopen_net_input (rdd_count_t *inputlen)
static RDD_WRITERopen_net_output (rdd_count_t outputsize, RDD_WRITER *tcp_writer_list[], int *num_tcp_writers, int output_number)
 Open network output.
static RDD_WRITERopen_output (rdd_count_t outputsize, RDD_HASH_CONTAINER *hashcontainer, RDD_WRITER *tcp_writer_list[], int *num_tcp_writers, int output_number)
static char * print_ewf_compress_option ()
static void process_hash_result (RDD_FILTERSET *fset, const char *hash_name, const char *filter_name, unsigned mdsize, RDD_HASH_CONTAINER *hashcontainer)
static void process_options ()
static rdd_count_t scan_size (char *str, unsigned flags)
static unsigned scan_tcp_port (char *str)
static unsigned scan_uint (char *str)
static int send_end_of_output_opts_marker (RDD_WRITER *tcp_writer_list[])
static void split_host_file (const char *host_file, char **host, char **file)

Variables

static RDD_OPTION all_output_opttabs [RDD_OUTPUT_OPTTAB_OPTION_COUNT *RDD_MAX_OUTPUT_OPTS]
static char * compression_types [] = { "no ewf", "none", "fast", "best", "empty-block", NULL}
static char copyright []
static rdd_copy_opts opts
static RDD_OPTION opttab []
static RDD_OPTION output_opttab []
static RDD_MSGPRINTERthe_printer
static char * usage_message


Define Documentation

#define ALL_MODES   (RDD_LOCAL|RDD_CLIENT|RDD_SERVER)

Definition at line 120 of file rddcopy.c.

#define bool2str (  )     ((b) ? "yes" : "no")

Definition at line 109 of file rddcopy.c.

#define DEFAULT_BLOCK_LEN   262144

Definition at line 98 of file rddcopy.c.

#define DEFAULT_BLOCKMD5_SIZE   4096

Definition at line 102 of file rddcopy.c.

#define DEFAULT_CHKSUM_BLOCK_SIZE   32768

Definition at line 101 of file rddcopy.c.

#define DEFAULT_HIST_BLOCK_SIZE   262144

Definition at line 100 of file rddcopy.c.

#define DEFAULT_MAX_READ_ERR   0

Definition at line 106 of file rddcopy.c.

#define DEFAULT_MIN_BLOCK_SIZE   32768

Definition at line 99 of file rddcopy.c.

#define DEFAULT_NRETRY   1

Definition at line 104 of file rddcopy.c.

#define DEFAULT_RDD_SERVER_PORT   4832

Definition at line 107 of file rddcopy.c.

#define DEFAULT_RECOVERY_LEN   4

Definition at line 105 of file rddcopy.c.

#define RDD_MAX_OUTPUT_OPTS   16

Definition at line 122 of file rddcopy.c.

#define RDD_OUTPUT_OPTTAB_OPTION_COUNT   sizeof(output_opttab)/sizeof(RDD_OPTION)

Definition at line 226 of file rddcopy.c.

#define str2str (  )     ((s) == 0? "<none>" : (s))

Definition at line 110 of file rddcopy.c.


Typedef Documentation

typedef struct _rdd_copy_opts rdd_copy_opts


Enumeration Type Documentation

Enumerator:
RDD_LOCAL 
RDD_CLIENT 
RDD_SERVER 

Definition at line 114 of file rddcopy.c.


Function Documentation

static void add_filter ( RDD_FILTERSET fset,
const char *  name,
RDD_FILTER f 
) [static]

Definition at line 1226 of file rddcopy.c.

References fatal_rdd_error(), rdd_fset_add(), and RDD_OK.

Here is the call graph for this function:

static int check_compress_option ( char *  arg  )  [static]

Definition at line 268 of file rddcopy.c.

References compression_types, fatal_rdd_error(), and RDD_BADARG.

Here is the call graph for this function:

static void close_printer ( void   )  [static]

Definition at line 1036 of file rddcopy.c.

References rdd_mp_close(), RDD_MP_READONLY, RDD_MP_RECURSE, and RDD_OK.

Here is the call graph for this function:

static void command_line ( int  argc,
char **  argv 
) [static]

static RDD_WRITER* connection_exists ( RDD_WRITER writer_list[],
int  output_number,
struct addrinfo *  address 
) [static]

Definition at line 853 of file rddcopy.c.

References fatal_rdd_error(), rdd_compare_address(), and RDD_OK.

Here is the call graph for this function:

static RDD_COPIER* create_copier ( rdd_count_t  input_size,
RDD_PROGRESS progress 
) [static]

static void fatal_rdd_error ( int  rdd_errno,
char *  fmt,
  ... 
) [static]

Definition at line 233 of file rddcopy.c.

References rdd_mp_vrddmsg(), and RDD_MSG_ERROR.

Here is the call graph for this function:

static int handle_progress ( rdd_count_t  pos,
rdd_count_t  nsubst,
void *  env 
) [static]

static void handle_read_error ( rdd_count_t  offset,
unsigned  nbyte,
void *  env 
) [static]

Definition at line 1143 of file rddcopy.c.

References logmsg().

Here is the call graph for this function:

static void handle_substitution ( rdd_count_t  offset,
unsigned  nbyte,
void *  env 
) [static]

Definition at line 1150 of file rddcopy.c.

References logmsg().

Here is the call graph for this function:

static void init_options ( void   )  [static]

static void install_filters ( RDD_FILTERSET fset,
RDD_WRITER writers[] 
) [static]

static void log_header ( char **  argv,
int  argc 
) [static]

Definition at line 1056 of file rddcopy.c.

References logmsg(), and rdd_ctime().

Here is the call graph for this function:

static void log_params ( rdd_copy_opts opts  )  [static]

static void logmsg ( const char *  fmt,
  ... 
) [static]

Definition at line 244 of file rddcopy.c.

References rdd_mp_vmessage(), and RDD_MSG_INFO.

Here is the call graph for this function:

int main ( int  argc,
char **  argv 
)

static RDD_READER* open_disk_input ( rdd_count_t inputlen  )  [static]

static RDD_WRITER* open_disk_output ( rdd_count_t  outputsize,
RDD_HASH_CONTAINER hashcontainer,
int  output_number 
) [static]

static RDD_READER* open_input ( rdd_count_t inputlen  )  [static]

Definition at line 788 of file rddcopy.c.

References _rdd_copy_opts::mode, open_disk_input(), open_net_input(), and RDD_SERVER.

Here is the call graph for this function:

static void open_logfile ( void   )  [static]

static RDD_READER* open_net_input ( rdd_count_t inputlen  )  [static]

static RDD_WRITER* open_net_output ( rdd_count_t  outputsize,
RDD_WRITER tcp_writer_list[],
int *  num_tcp_writers,
int  output_number 
) [static]

Open network output.

Parameters:
outputsize the size of the output
tcp_writer_list (in/out) the list of current tcp writers
num_tcp_writers (in/out) the size of the tcp_writer_list
output_number the index of the output parameter set on the command line for which we have to create a writer
Returns:
the new writer
Note:
The tcp writer list is needed to be able to send an end-of-output-marker to each writer. The actual writer returned by this function may be a stacked writer (e.g. zlib), to which we cannot send the marker. We also use the list to determine if a tcp writer with the same address * already exists; in that case we just send meta-information.

Find out if the connection has already been created by another writer.

Send output parameters.

Definition at line 912 of file rddcopy.c.

References _rdd_copy_opts::blocklen, _rdd_copy_opts::compress, connection_exists(), _rdd_output_opt_t::ewf, fatal_rdd_error(), _rdd_output_opt_t::outpath, _rdd_copy_opts::output, rdd_get_address(), RDD_NET_COMPRESS, RDD_OK, rdd_open_tcp_writer(), rdd_open_zlib_writer(), rdd_send_info(), _rdd_output_opt_t::server_host, _rdd_output_opt_t::server_port, and _rdd_output_opt_t::splitlen.

Here is the call graph for this function:

static RDD_WRITER* open_output ( rdd_count_t  outputsize,
RDD_HASH_CONTAINER hashcontainer,
RDD_WRITER tcp_writer_list[],
int *  num_tcp_writers,
int  output_number 
) [static]

Creates a writer stack that corresponds to the user's options. The outputsize argument contains the size of the output in bytes if that size is known or RDD_WHOLE_FILE if is not known.

Definition at line 982 of file rddcopy.c.

References _rdd_copy_opts::mode, open_disk_output(), open_net_output(), and RDD_CLIENT.

Here is the call graph for this function:

static char* print_ewf_compress_option (  )  [static]

Definition at line 284 of file rddcopy.c.

References compression_types, _rdd_output_opt_t::ewf, fatal_rdd_error(), _rdd_copy_opts::output, and RDD_BADARG.

Here is the call graph for this function:

static void process_hash_result ( RDD_FILTERSET fset,
const char *  hash_name,
const char *  filter_name,
unsigned  mdsize,
RDD_HASH_CONTAINER hashcontainer 
) [static]

Definition at line 1415 of file rddcopy.c.

References fatal_rdd_error(), logmsg(), rdd_buf2hex(), RDD_ESPACE, rdd_filter_get_result(), rdd_fset_get(), RDD_MAX_DIGEST_LENGTH, RDD_OK, and rdd_set_hash().

Here is the call graph for this function:

static void process_options ( void   )  [static]

static rdd_count_t scan_size ( char *  str,
unsigned  flags 
) [static]

Definition at line 256 of file rddcopy.c.

References fatal_rdd_error(), RDD_OK, and rdd_parse_bignum().

Here is the call graph for this function:

static unsigned scan_tcp_port ( char *  str  )  [static]

Definition at line 307 of file rddcopy.c.

References fatal_rdd_error(), RDD_OK, and rdd_parse_tcp_port().

Here is the call graph for this function:

static unsigned scan_uint ( char *  str  )  [static]

Definition at line 295 of file rddcopy.c.

References fatal_rdd_error(), RDD_OK, and rdd_parse_uint().

Here is the call graph for this function:

static int send_end_of_output_opts_marker ( RDD_WRITER tcp_writer_list[]  )  [static]

Definition at line 873 of file rddcopy.c.

References fatal_rdd_error(), _rdd_copy_opts::output_count, rdd_compare_address(), RDD_OK, and rdd_send_info().

Here is the call graph for this function:

static void split_host_file ( const char *  host_file,
char **  host,
char **  file 
) [static]

Definition at line 348 of file rddcopy.c.

References error(), and rdd_malloc().

Here is the call graph for this function:


Variable Documentation

RDD_OPTION all_output_opttabs[RDD_OUTPUT_OPTTAB_OPTION_COUNT *RDD_MAX_OUTPUT_OPTS] [static]

Definition at line 228 of file rddcopy.c.

char* compression_types[] = { "no ewf", "none", "fast", "best", "empty-block", NULL} [static]

Definition at line 172 of file rddcopy.c.

char copyright[] [static]

Initial value:

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

Definition at line 39 of file rddcopy.c.

rdd_copy_opts opts [static]

Definition at line 170 of file rddcopy.c.

RDD_OPTION opttab[] [static]

Definition at line 179 of file rddcopy.c.

Initial value:

 {
        {"-e",              "--ewf",            "<compression>",RDD_LOCAL|RDD_CLIENT,   "Output as Expert Witness Compression Format (EnCase), compression: none, fast, best, empty-block", 0,  0},
        {"-s",              "--split",          "<count>[kKmMgG]",  RDD_LOCAL|RDD_CLIENT,   "Split output,  all files < <count> [KMG]bytes",    0,  0},
    {"-N",              "--name",           "<file>",       RDD_LOCAL|RDD_CLIENT,   "The output file name",                 0,  0},
        {"-p",              "--port",           "<portnum>",        RDD_CLIENT,     "Set server port to <port>",                0,  0},
        {0,             0,              0,          0,          0,                          0,  0} 
}

Definition at line 218 of file rddcopy.c.

Definition at line 230 of file rddcopy.c.

char* usage_message [static]

Initial value:

 "\n"
    "\trdd-copy [local options] --in infile --out <output options>\n"
    "\trdd-copy -C [client options] --in infile --out <output options>\n"
    "\trdd-copy -S [server options]\n"

Definition at line 174 of file rddcopy.c.


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