From 7be7f7d23914d7a5066c451a5b9c478162eb359a Mon Sep 17 00:00:00 2001 From: hondza Date: Fri, 23 Jan 2009 23:34:10 +0100 Subject: [PATCH] Introducing relaxed mode. Handy when running as non-root. --- dm-merge.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/dm-merge.c b/dm-merge.c index dc7db4c..748ae31 100644 --- a/dm-merge.c +++ b/dm-merge.c @@ -68,7 +68,7 @@ struct disk_exception { unsigned char *header=NULL, *header_orig=NULL, *buf=NULL, *buf_orig=NULL, *chunk=NULL, *chunk_orig=NULL; char *input_filename=NULL, *output_filename=NULL; -int inputfd=-1, outputfd=-1, dry=1, print_dds=0, do_direct_io = 0, verbose = 0, err=-1, err2=-1, flags=0, go=1; +int inputfd=-1, outputfd=-1, dry=1, print_dds=0, do_direct_io = 0, verbose = 0, err=-1, err2=-1, flags=0, go=1, relaxed=0; unsigned int i=0, retries=0; struct stat st; size_t input_length=0, output_length=0; @@ -177,6 +177,7 @@ void help() fputs("Usage: dm-merge [options] -i [ -o ]\n\n", stderr); fputs("Options:\n", stderr); fputs("-f\t\tREALLY do it (no dry run)\n", stderr); + fputs("-x\t\tRelaxed mode; allow some things (namely ioctl) to fail\n", stderr); fputs("-d\t\tPrint dd lines as list_exception_chunks.pl would\n", stderr); fputs("-D\t\tTry to use O_DIRECT\n", stderr); fputs("-v\t\tBe verbose (more '-v's increase verbosity)\n", stderr); @@ -194,10 +195,11 @@ int main(int argc, char ** argv) atexit(cleanup); - while( (c = getopt(argc, argv, "fdi:o:Dvh")) != -1 ) + while( (c = getopt(argc, argv, "fdi:o:Dvhx")) != -1 ) { switch(c) { + case 'x': relaxed = 1; break; case 'f': dry = 0; break; case 'd': print_dds = 1; break; case 'D': do_direct_io = 1; break; @@ -264,7 +266,8 @@ int main(int argc, char ** argv) if(-1 == err) { perror("ioctl(snapshot, BLKFLSBUF)"); - exit(1); + if(!relaxed) exit(1); + else fputs("relaxed mode, will continue ...\n", stderr); } } else @@ -307,7 +310,8 @@ int main(int argc, char ** argv) if(-1 == err) { perror("ioctl(output, BLKFLSBUF)"); - exit(1); + if(!relaxed) exit(1); + else fputs("relaxed mode, will continue ...\n", stderr); } } else -- 2.11.4.GIT