From a594e2218a320b9f90b7fa24ce95a806e50fff38 Mon Sep 17 00:00:00 2001 From: Thomas Tsai Date: Mon, 25 Sep 2023 11:47:25 +0800 Subject: [PATCH] add direct-io option and set version 0.3.26 --- config.h.in | 15 ++++++--------- configure.ac | 2 +- src/partclone.c | 20 +++++++++++++++++--- src/partclone.h | 1 + src/version.h | 2 +- 5 files changed, 26 insertions(+), 14 deletions(-) diff --git a/config.h.in b/config.h.in index 92b07885..9a24a612 100644 --- a/config.h.in +++ b/config.h.in @@ -74,9 +74,6 @@ /* Define to 1 if you have the header file. */ #undef HAVE_LOCALE_H -/* Define to 1 if you have the header file. */ -#undef HAVE_MEMORY_H - /* Define to 1 if you have the header file. */ #undef HAVE_MNTENT_H @@ -116,6 +113,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H +/* Define to 1 if you have the header file. */ +#undef HAVE_STDIO_H + /* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H @@ -170,17 +170,14 @@ /* Define to the version of this package. */ #undef PACKAGE_VERSION -/* Define to 1 if you have the ANSI C header files. */ +/* Define to 1 if all of the C90 standard headers exist (not just the ones + required in a freestanding environment). This macro is provided for + backward compatibility; new code need not use it. */ #undef STDC_HEADERS /* Version number of package */ #undef VERSION -/* Enable large inode numbers on Mac OS X 10.5. */ -#ifndef _DARWIN_USE_64_BIT_INODE -# define _DARWIN_USE_64_BIT_INODE 1 -#endif - /* Number of bits in a file offset, on hosts where this is settable. */ #undef _FILE_OFFSET_BITS diff --git a/configure.ac b/configure.ac index 9caa7f48..5ee7fb12 100644 --- a/configure.ac +++ b/configure.ac @@ -1,4 +1,4 @@ -AC_INIT([Partclone],[0.3.25],[thomas@nchc.org.tw]) +AC_INIT([Partclone],[0.3.26],[thomas@nchc.org.tw]) AM_INIT_AUTOMAKE([-Wall foreign]) AM_GNU_GETTEXT_VERSION([0.16.1]) AM_GNU_GETTEXT([external]) diff --git a/src/partclone.c b/src/partclone.c index 40272335..44dff904 100644 --- a/src/partclone.c +++ b/src/partclone.c @@ -73,6 +73,13 @@ SCREEN *ptclscr; int log_y_line = 0; #endif +#define OPT_OFFSET_DOMAIN 1000 +#define OPT_DIRECT_IO 1001 +// +//enum { +// OPT_OFFSET_DOMAIN = 1000 +//}; + /** * return the cpu architecture for which partclone is compiled * @@ -253,6 +260,7 @@ void usage(void) { #endif #ifndef CHKIMG " -I, --ignore_fschk Ignore filesystem check\n" + " --direct-io Writing data to TARGET disk or image without cache.\n" #endif " -i, --ignore_crc Ignore checksum error\n" " -F, --force Force progress\n" @@ -300,9 +308,6 @@ int convert_to_checksum_mode(unsigned long mode) { } } -enum { - OPT_OFFSET_DOMAIN = 1000 -}; const char *exec_name = "unset_name"; @@ -347,6 +352,7 @@ void parse_options(int argc, char **argv, cmd_opt* opt) { { "force", no_argument, NULL, 'F' }, { "no_block_detail", no_argument, NULL, 'B' }, { "buffer_size", required_argument, NULL, 'z' }, + { "direct-io", no_argument, NULL, OPT_DIRECT_IO }, // not RESTORE and not CHKIMG #ifndef CHKIMG #ifndef RESTORE @@ -403,6 +409,7 @@ void parse_options(int argc, char **argv, cmd_opt* opt) { opt->reseed_checksum = 1; opt->blocks_per_checksum = 0; opt->blockfile = 0; + opt->direct_io = 0; #ifdef DD @@ -433,6 +440,9 @@ void parse_options(int argc, char **argv, cmd_opt* opt) { case 'v': print_version(); break; + case OPT_DIRECT_IO: + opt->direct_io = 1; + break; case 'n': memcpy(opt->note, optarg, NOTE_SIZE); break; @@ -1568,6 +1578,10 @@ int open_target(char* target, cmd_opt* opt) { struct stat st_dev; int ddd_block_device = -1; + if (opt->direct_io == 1){ + flags = flags | O_DIRECT; + } + log_mesg(1, 0, 0, debug, "open target file/device %s\n", target); if (opt->ddd) { if (stat(target, &st_dev) != -1) { diff --git a/src/partclone.h b/src/partclone.h index c97e86c2..1a5e7a93 100644 --- a/src/partclone.h +++ b/src/partclone.h @@ -120,6 +120,7 @@ struct cmd_opt int no_block_detail; int restore_raw_file; int skip_write_error; + int direct_io; unsigned int buffer_size; off_t offset; unsigned long fresh; diff --git a/src/version.h b/src/version.h index 18cbe939..608ee90c 100644 --- a/src/version.h +++ b/src/version.h @@ -3,5 +3,5 @@ * WHETHER THEY ARE BUILT BY OTHERS OR DURING DEVELOPMENT OR FOR THE * OFFICIAL PARTCLONE RELEASES. */ -#define git_version "c905de58e162d559138eeabc5c9152a41bfa2f9e" +#define git_version "8f931256b03cf919a0220ca35a91c3cd40b50bd9"