Mykola Ivanets
2020-Feb-12 01:02 UTC
[Libguestfs] [PATCH v2 0/1] tools: add '--blocksize' option for C-based tools
From: Nikolay Ivanets <stenavin@gmail.com> This patch depends on changes in 'common' sub-module posted here: https://www.redhat.com/archives/libguestfs/2020-February/msg00099.html v2: Almost the same as v1 except '--blocksize' option description is moved into a common submodule (similar to key-option.pod). v1 was here: https://www.redhat.com/archives/libguestfs/2020-February/msg00097.html Nikolay Ivanets (1): tools: add '--blocksize' option for C-based tools align/Makefile.am | 1 + align/scan.c | 8 ++++++++ align/virt-alignment-scan.pod | 2 ++ cat/Makefile.am | 1 + cat/cat.c | 8 ++++++++ cat/filesystems.c | 8 ++++++++ cat/log.c | 8 ++++++++ cat/ls.c | 8 ++++++++ cat/tail.c | 8 ++++++++ cat/virt-cat.pod | 2 ++ cat/virt-filesystems.pod | 2 ++ cat/virt-log.pod | 2 ++ cat/virt-ls.pod | 2 ++ cat/virt-tail.pod | 2 ++ df/Makefile.am | 1 + df/main.c | 8 ++++++++ df/virt-df.pod | 2 ++ diff/diff.c | 8 ++++++++ diff/virt-diff.pod | 2 ++ edit/edit.c | 8 ++++++++ edit/virt-edit.pod | 2 ++ fish/fish.c | 8 ++++++++ fish/guestfish.pod | 2 ++ format/Makefile.am | 1 + format/format.c | 8 ++++++++ format/virt-format.pod | 2 ++ fuse/guestmount.c | 8 ++++++++ fuse/guestmount.pod | 2 ++ inspector/inspector.c | 8 ++++++++ inspector/virt-inspector.pod | 2 ++ rescue/Makefile.am | 1 + rescue/rescue.c | 8 ++++++++ rescue/virt-rescue.pod | 2 ++ 33 files changed, 145 insertions(+) -- 2.17.2
Mykola Ivanets
2020-Feb-12 01:02 UTC
[Libguestfs] [PATCH v2 1/1] tools: add '--blocksize' option for C-based tools
From: Nikolay Ivanets <stenavin@gmail.com> This patch adds '--blocksize' command line option for guestfish and other C-based tools. This option allows specifying disk sector size. --- align/Makefile.am | 1 + align/scan.c | 8 ++++++++ align/virt-alignment-scan.pod | 2 ++ cat/Makefile.am | 1 + cat/cat.c | 8 ++++++++ cat/filesystems.c | 8 ++++++++ cat/log.c | 8 ++++++++ cat/ls.c | 8 ++++++++ cat/tail.c | 8 ++++++++ cat/virt-cat.pod | 2 ++ cat/virt-filesystems.pod | 2 ++ cat/virt-log.pod | 2 ++ cat/virt-ls.pod | 2 ++ cat/virt-tail.pod | 2 ++ df/Makefile.am | 1 + df/main.c | 8 ++++++++ df/virt-df.pod | 2 ++ diff/diff.c | 8 ++++++++ diff/virt-diff.pod | 2 ++ edit/edit.c | 8 ++++++++ edit/virt-edit.pod | 2 ++ fish/fish.c | 8 ++++++++ fish/guestfish.pod | 2 ++ format/Makefile.am | 1 + format/format.c | 8 ++++++++ format/virt-format.pod | 2 ++ fuse/guestmount.c | 8 ++++++++ fuse/guestmount.pod | 2 ++ inspector/inspector.c | 8 ++++++++ inspector/virt-inspector.pod | 2 ++ rescue/Makefile.am | 1 + rescue/rescue.c | 8 ++++++++ rescue/virt-rescue.pod | 2 ++ 33 files changed, 145 insertions(+) diff --git a/align/Makefile.am b/align/Makefile.am index 1c698561b..6ff4aa3bf 100644 --- a/align/Makefile.am +++ b/align/Makefile.am @@ -66,6 +66,7 @@ stamp-virt-alignment-scan.pod: virt-alignment-scan.pod $(PODWRAPPER) \ --man virt-alignment-scan.1 \ --html $(top_builddir)/website/virt-alignment-scan.1.html \ + --path $(top_srcdir)/common/options \ --license GPLv2+ \ --warning safe \ $< diff --git a/align/scan.c b/align/scan.c index b9f29868c..5a456d3d6 100644 --- a/align/scan.c +++ b/align/scan.c @@ -90,6 +90,8 @@ usage (int status) " -c|--connect uri Specify libvirt URI for -d option\n" " -d|--domain guest Add disks from libvirt guest\n" " --format[=raw|..] Force disk format for -a option\n" + " --blocksize[=512|4096]\n" + " Set sector size of the disk for -a option\n" " --help Display brief help\n" " -P nr_threads Use at most nr_threads\n" " -q|--quiet No output, just exit code\n" @@ -119,6 +121,7 @@ main (int argc, char *argv[]) { "connect", 1, 0, 'c' }, { "domain", 1, 0, 'd' }, { "format", 2, 0, 0 }, + { "blocksize", 2, 0, 0 }, { "help", 0, 0, HELP_OPTION }, { "long-options", 0, 0, 0 }, { "quiet", 0, 0, 'q' }, @@ -131,6 +134,8 @@ main (int argc, char *argv[]) struct drv *drvs = NULL; const char *format = NULL; bool format_consumed = true; + int blocksize = 0; + bool blocksize_consumed = true; int c; int option_index; int exit_code; @@ -153,6 +158,8 @@ main (int argc, char *argv[]) display_short_options (options); else if (STREQ (long_options[option_index].name, "format")) { OPTION_format; + } else if (STREQ (long_options[option_index].name, "blocksize")) { + OPTION_blocksize; } else if (STREQ (long_options[option_index].name, "uuid")) { uuid = 1; } else @@ -215,6 +222,7 @@ main (int argc, char *argv[]) usage (EXIT_FAILURE); CHECK_OPTION_format_consumed; + CHECK_OPTION_blocksize_consumed; /* virt-alignment-scan has two modes. If the user didn't specify * any drives, then we do the scan on every libvirt guest. That's diff --git a/align/virt-alignment-scan.pod b/align/virt-alignment-scan.pod index 19953546e..83f500fde 100644 --- a/align/virt-alignment-scan.pod +++ b/align/virt-alignment-scan.pod @@ -162,6 +162,8 @@ If you have untrusted raw-format guest disk images, you should use this option to specify the disk format. This avoids a possible security problem with malicious guests (CVE-2010-3851). +__INCLUDE:blocksize-option.pod__ + =item B<-P> nr_threads Since libguestfs 1.22, virt-alignment-scan is multithreaded and diff --git a/cat/Makefile.am b/cat/Makefile.am index 1d013e8dd..01e13abda 100644 --- a/cat/Makefile.am +++ b/cat/Makefile.am @@ -200,6 +200,7 @@ stamp-virt-filesystems.pod: virt-filesystems.pod $(PODWRAPPER) \ --man virt-filesystems.1 \ --html $(top_builddir)/website/virt-filesystems.1.html \ + --path $(top_srcdir)/common/options \ --license GPLv2+ \ --warning safe \ $< diff --git a/cat/cat.c b/cat/cat.c index 4f0d7035e..eb070877a 100644 --- a/cat/cat.c +++ b/cat/cat.c @@ -70,6 +70,8 @@ usage (int status) " -d|--domain guest Add disks from libvirt guest\n" " --echo-keys Don't turn off echo for passphrases\n" " --format[=raw|..] Force disk format for -a option\n" + " --blocksize[=512|4096]\n" + " Set sector size of the disk for -a option\n" " --help Display brief help\n" " --key selector Specify a LUKS key\n" " --keys-from-stdin Read passphrases from stdin\n" @@ -101,6 +103,7 @@ main (int argc, char *argv[]) { "domain", 1, 0, 'd' }, { "echo-keys", 0, 0, 0 }, { "format", 2, 0, 0 }, + { "blocksize", 2, 0, 0 }, { "help", 0, 0, HELP_OPTION }, { "key", 1, 0, 0 }, { "keys-from-stdin", 0, 0, 0 }, @@ -118,6 +121,8 @@ main (int argc, char *argv[]) char *p; const char *format = NULL; bool format_consumed = true; + int blocksize = 0; + bool blocksize_consumed = true; int c; int r; int option_index; @@ -143,6 +148,8 @@ main (int argc, char *argv[]) echo_keys = 1; } else if (STREQ (long_options[option_index].name, "format")) { OPTION_format; + } else if (STREQ (long_options[option_index].name, "blocksize")) { + OPTION_blocksize; } else if (STREQ (long_options[option_index].name, "key")) { OPTION_key; } else @@ -232,6 +239,7 @@ main (int argc, char *argv[]) usage (EXIT_FAILURE); CHECK_OPTION_format_consumed; + CHECK_OPTION_blocksize_consumed; /* User must have specified some drives. */ if (drvs == NULL) { diff --git a/cat/filesystems.c b/cat/filesystems.c index 74e994169..447bccc6e 100644 --- a/cat/filesystems.c +++ b/cat/filesystems.c @@ -111,6 +111,8 @@ usage (int status) " --extra Display swap and data filesystems\n" " --filesystems Display mountable filesystems\n" " --format[=raw|..] Force disk format for -a option\n" + " --blocksize[=512|4096]\n" + " Set sector size of the disk for -a option\n" " -h|--human-readable Human-readable sizes in --long output\n" " --help Display brief help\n" " --keys-from-stdin Read passphrases from stdin\n" @@ -156,6 +158,7 @@ main (int argc, char *argv[]) { "extra", 0, 0, 0 }, { "filesystems", 0, 0, 0 }, { "format", 2, 0, 0 }, + { "blocksize", 2, 0, 0 }, { "help", 0, 0, HELP_OPTION }, { "human-readable", 0, 0, 'h' }, { "keys-from-stdin", 0, 0, 0 }, @@ -183,6 +186,8 @@ main (int argc, char *argv[]) struct drv *drvs = NULL; const char *format = NULL; bool format_consumed = true; + int blocksize = 0; + bool blocksize_consumed = true; int c; int option_index; int no_title = 0; /* --no-title */ @@ -210,6 +215,8 @@ main (int argc, char *argv[]) echo_keys = 1; } else if (STREQ (long_options[option_index].name, "format")) { OPTION_format; + } else if (STREQ (long_options[option_index].name, "blocksize")) { + OPTION_blocksize; } else if (STREQ (long_options[option_index].name, "all")) { output = OUTPUT_ALL; } else if (STREQ (long_options[option_index].name, "blkdevs") || @@ -306,6 +313,7 @@ main (int argc, char *argv[]) } CHECK_OPTION_format_consumed; + CHECK_OPTION_blocksize_consumed; /* -h and --csv doesn't make sense. Spreadsheets will corrupt these * fields. (RHBZ#600977). diff --git a/cat/log.c b/cat/log.c index f8a5c85f2..50cd50eb9 100644 --- a/cat/log.c +++ b/cat/log.c @@ -80,6 +80,8 @@ usage (int status) " -d|--domain guest Add disks from libvirt guest\n" " --echo-keys Don't turn off echo for passphrases\n" " --format[=raw|..] Force disk format for -a option\n" + " --blocksize[=512|4096]\n" + " Set sector size of the disk for -a option\n" " --help Display brief help\n" " --key selector Specify a LUKS key\n" " --keys-from-stdin Read passphrases from stdin\n" @@ -109,6 +111,7 @@ main (int argc, char *argv[]) { "domain", 1, 0, 'd' }, { "echo-keys", 0, 0, 0 }, { "format", 2, 0, 0 }, + { "blocksize", 2, 0, 0 }, { "help", 0, 0, HELP_OPTION }, { "key", 1, 0, 0 }, { "keys-from-stdin", 0, 0, 0 }, @@ -121,6 +124,8 @@ main (int argc, char *argv[]) struct drv *drvs = NULL; const char *format = NULL; bool format_consumed = true; + int blocksize = 0; + bool blocksize_consumed = true; int c; int r; int option_index; @@ -146,6 +151,8 @@ main (int argc, char *argv[]) echo_keys = 1; } else if (STREQ (long_options[option_index].name, "format")) { OPTION_format; + } else if (STREQ (long_options[option_index].name, "blocksize")) { + OPTION_blocksize; } else if (STREQ (long_options[option_index].name, "key")) { OPTION_key; } else @@ -204,6 +211,7 @@ main (int argc, char *argv[]) } CHECK_OPTION_format_consumed; + CHECK_OPTION_blocksize_consumed; /* User must have specified some drives. */ if (drvs == NULL) { diff --git a/cat/ls.c b/cat/ls.c index 055939a80..b56f3a46b 100644 --- a/cat/ls.c +++ b/cat/ls.c @@ -111,6 +111,8 @@ usage (int status) " --echo-keys Don't turn off echo for passphrases\n" " --extra-stats Display extra stats\n" " --format[=raw|..] Force disk format for -a option\n" + " --blocksize[=512|4096]\n" + " Set sector size of the disk for -a option\n" " --help Display brief help\n" " -h|--human-readable Human-readable sizes in output\n" " --key selector Specify a LUKS key\n" @@ -158,6 +160,7 @@ main (int argc, char *argv[]) { "extra-stat", 0, 0, 0 }, { "extra-stats", 0, 0, 0 }, { "format", 2, 0, 0 }, + { "blocksize", 2, 0, 0 }, { "help", 0, 0, HELP_OPTION }, { "human-readable", 0, 0, 'h' }, { "key", 1, 0, 0 }, @@ -185,6 +188,8 @@ main (int argc, char *argv[]) char *p; const char *format = NULL; bool format_consumed = true; + int blocksize = 0; + bool blocksize_consumed = true; int c; int option_index; #define MODE_LS_L 1 @@ -213,6 +218,8 @@ main (int argc, char *argv[]) echo_keys = 1; } else if (STREQ (long_options[option_index].name, "format")) { OPTION_format; + } else if (STREQ (long_options[option_index].name, "blocksize")) { + OPTION_blocksize; } else if (STREQ (long_options[option_index].name, "checksum") || STREQ (long_options[option_index].name, "checksums")) { if (!optarg || STREQ (optarg, "")) @@ -338,6 +345,7 @@ main (int argc, char *argv[]) assert (live == 0); CHECK_OPTION_format_consumed; + CHECK_OPTION_blocksize_consumed; /* Many flags only apply to -lR mode. */ if (mode != MODE_LS_LR && diff --git a/cat/tail.c b/cat/tail.c index 9e3af7c7d..c12b32631 100644 --- a/cat/tail.c +++ b/cat/tail.c @@ -78,6 +78,8 @@ usage (int status) " --echo-keys Don't turn off echo for passphrases\n" " -f|--follow Ignored for compatibility with tail\n" " --format[=raw|..] Force disk format for -a option\n" + " --blocksize[=512|4096]\n" + " Set sector size of the disk for -a option\n" " --help Display brief help\n" " --key selector Specify a LUKS key\n" " --keys-from-stdin Read passphrases from stdin\n" @@ -110,6 +112,7 @@ main (int argc, char *argv[]) { "echo-keys", 0, 0, 0 }, { "follow", 0, 0, 'f' }, { "format", 2, 0, 0 }, + { "blocksize", 2, 0, 0 }, { "help", 0, 0, HELP_OPTION }, { "key", 1, 0, 0 }, { "keys-from-stdin", 0, 0, 0 }, @@ -126,6 +129,8 @@ main (int argc, char *argv[]) char *p; const char *format = NULL; bool format_consumed = true; + int blocksize = 0; + bool blocksize_consumed = true; int c; int r; int option_index; @@ -151,6 +156,8 @@ main (int argc, char *argv[]) echo_keys = 1; } else if (STREQ (long_options[option_index].name, "format")) { OPTION_format; + } else if (STREQ (long_options[option_index].name, "blocksize")) { + OPTION_blocksize; } else if (STREQ (long_options[option_index].name, "key")) { OPTION_key; } else @@ -217,6 +224,7 @@ main (int argc, char *argv[]) } CHECK_OPTION_format_consumed; + CHECK_OPTION_blocksize_consumed; /* User must have specified some drives. */ if (drvs == NULL) { diff --git a/cat/virt-cat.pod b/cat/virt-cat.pod index 0c4ce4b77..1eddb67e0 100644 --- a/cat/virt-cat.pod +++ b/cat/virt-cat.pod @@ -121,6 +121,8 @@ If you have untrusted raw-format guest disk images, you should use this option to specify the disk format. This avoids a possible security problem with malicious guests (CVE-2010-3851). +__INCLUDE:blocksize-option.pod__ + __INCLUDE:key-option.pod__ =item B<--keys-from-stdin> diff --git a/cat/virt-filesystems.pod b/cat/virt-filesystems.pod index a3a0fb29a..6954f2ffa 100644 --- a/cat/virt-filesystems.pod +++ b/cat/virt-filesystems.pod @@ -195,6 +195,8 @@ If you have untrusted raw-format guest disk images, you should use this option to specify the disk format. This avoids a possible security problem with malicious guests (CVE-2010-3851). +__INCLUDE:blocksize-option.pod__ + =item B<-h> =item B<--human-readable> diff --git a/cat/virt-log.pod b/cat/virt-log.pod index a6b37662e..0bdfdc70e 100644 --- a/cat/virt-log.pod +++ b/cat/virt-log.pod @@ -105,6 +105,8 @@ If you have untrusted raw-format guest disk images, you should use this option to specify the disk format. This avoids a possible security problem with malicious guests (CVE-2010-3851). +__INCLUDE:blocksize-option.pod__ + __INCLUDE:key-option.pod__ =item B<--keys-from-stdin> diff --git a/cat/virt-ls.pod b/cat/virt-ls.pod index 53141b2c6..9c9488532 100644 --- a/cat/virt-ls.pod +++ b/cat/virt-ls.pod @@ -343,6 +343,8 @@ If you have untrusted raw-format guest disk images, you should use this option to specify the disk format. This avoids a possible security problem with malicious guests (CVE-2010-3851). +__INCLUDE:blocksize-option.pod__ + =item B<-h> =item B<--human-readable> diff --git a/cat/virt-tail.pod b/cat/virt-tail.pod index 9f72ce3f7..2de2be91b 100644 --- a/cat/virt-tail.pod +++ b/cat/virt-tail.pod @@ -123,6 +123,8 @@ If you have untrusted raw-format guest disk images, you should use this option to specify the disk format. This avoids a possible security problem with malicious guests (CVE-2010-3851). +__INCLUDE:blocksize-option.pod__ + __INCLUDE:key-option.pod__ =item B<--keys-from-stdin> diff --git a/df/Makefile.am b/df/Makefile.am index 92493f123..78dccda90 100644 --- a/df/Makefile.am +++ b/df/Makefile.am @@ -70,6 +70,7 @@ stamp-virt-df.pod: virt-df.pod $(PODWRAPPER) \ --man virt-df.1 \ --html $(top_builddir)/website/virt-df.1.html \ + --path $(top_srcdir)/common/options \ --license GPLv2+ \ --warning safe \ $< diff --git a/df/main.c b/df/main.c index bbb2ddb61..fba2d57d1 100644 --- a/df/main.c +++ b/df/main.c @@ -83,6 +83,8 @@ usage (int status) " --csv Output as Comma-Separated Values\n" " -d|--domain guest Add disks from libvirt guest\n" " --format[=raw|..] Force disk format for -a option\n" + " --blocksize[=512|4096]\n" + " Set sector size of the disk for -a option\n" " -h|--human-readable Print sizes in human-readable format\n" " --help Display brief help\n" " -i|--inodes Display inodes\n" @@ -115,6 +117,7 @@ main (int argc, char *argv[]) { "csv", 0, 0, 0 }, { "domain", 1, 0, 'd' }, { "format", 2, 0, 0 }, + { "blocksize", 2, 0, 0 }, { "help", 0, 0, HELP_OPTION }, { "human-readable", 0, 0, 'h' }, { "inodes", 0, 0, 'i' }, @@ -130,6 +133,8 @@ main (int argc, char *argv[]) struct drv *drv; const char *format = NULL; bool format_consumed = true; + int blocksize = 0; + bool blocksize_consumed = true; int c; int option_index; size_t max_threads = 0; @@ -151,6 +156,8 @@ main (int argc, char *argv[]) display_short_options (options); else if (STREQ (long_options[option_index].name, "format")) { OPTION_format; + } else if (STREQ (long_options[option_index].name, "blocksize")) { + OPTION_blocksize; } else if (STREQ (long_options[option_index].name, "csv")) { csv = 1; } else if (STREQ (long_options[option_index].name, "one-per-guest")) { @@ -251,6 +258,7 @@ main (int argc, char *argv[]) usage (EXIT_FAILURE); CHECK_OPTION_format_consumed; + CHECK_OPTION_blocksize_consumed; /* -h and --csv doesn't make sense. Spreadsheets will corrupt these * fields. (RHBZ#600977). diff --git a/df/virt-df.pod b/df/virt-df.pod index de6e6b4e5..36ec95e75 100644 --- a/df/virt-df.pod +++ b/df/virt-df.pod @@ -140,6 +140,8 @@ If you have untrusted raw-format guest disk images, you should use this option to specify the disk format. This avoids a possible security problem with malicious guests (CVE-2010-3851). +__INCLUDE:blocksize-option.pod__ + =item B<-h> =item B<--human-readable> diff --git a/diff/diff.c b/diff/diff.c index c04b5f185..f7ab93726 100644 --- a/diff/diff.c +++ b/diff/diff.c @@ -126,6 +126,8 @@ usage (int status) " --echo-keys Don't turn off echo for passphrases\n" " --extra-stats Display extra stats\n" " --format[=raw|..] Force disk format for -a or -A option\n" + " --blocksize[=512|4096]\n" + " Set sector size of the disk for -a or -A option\n" " --help Display brief help\n" " -h|--human-readable Human-readable sizes in output\n" " --key selector Specify a LUKS key\n" @@ -178,6 +180,7 @@ main (int argc, char *argv[]) { "extra-stat", 0, 0, 0 }, { "extra-stats", 0, 0, 0 }, { "format", 2, 0, 0 }, + { "blocksize", 2, 0, 0 }, { "help", 0, 0, HELP_OPTION }, { "human-readable", 0, 0, 'h' }, { "long-options", 0, 0, 0 }, @@ -201,6 +204,8 @@ main (int argc, char *argv[]) struct drv *drvs2 = NULL; /* Second guest. */ const char *format = NULL; bool format_consumed = true; + int blocksize = 0; + bool blocksize_consumed = true; int c; int option_index; struct tree *tree1, *tree2; @@ -232,6 +237,8 @@ main (int argc, char *argv[]) echo_keys = 1; } else if (STREQ (long_options[option_index].name, "format")) { OPTION_format; + } else if (STREQ (long_options[option_index].name, "blocksize")) { + OPTION_blocksize; } else if (STREQ (long_options[option_index].name, "all")) { enable_extra_stats = enable_times = enable_uids = enable_xattrs = 1; } else if (STREQ (long_options[option_index].name, "atime")) { @@ -366,6 +373,7 @@ main (int argc, char *argv[]) assert (live == 0); CHECK_OPTION_format_consumed; + CHECK_OPTION_blocksize_consumed; unsigned errors = 0; diff --git a/diff/virt-diff.pod b/diff/virt-diff.pod index 0500598bd..4ab402b86 100644 --- a/diff/virt-diff.pod +++ b/diff/virt-diff.pod @@ -160,6 +160,8 @@ If you have untrusted raw-format guest disk images, you should use this option to specify the disk format. This avoids a possible security problem with malicious guests (CVE-2010-3851). +__INCLUDE:blocksize-option.pod__ + =item B<-h> =item B<--human-readable> diff --git a/edit/edit.c b/edit/edit.c index 4b9f1bed1..635995e0d 100644 --- a/edit/edit.c +++ b/edit/edit.c @@ -81,6 +81,8 @@ usage (int status) " --echo-keys Don't turn off echo for passphrases\n" " -e|--edit|--expr expr Non-interactive editing using Perl expr\n" " --format[=raw|..] Force disk format for -a option\n" + " --blocksize[=512|4096]\n" + " Set sector size of the disk for -a option\n" " --help Display brief help\n" " --key selector Specify a LUKS key\n" " --keys-from-stdin Read passphrases from stdin\n" @@ -115,6 +117,7 @@ main (int argc, char *argv[]) { "edit", 1, 0, 'e' }, { "expr", 1, 0, 'e' }, { "format", 2, 0, 0 }, + { "blocksize", 2, 0, 0 }, { "help", 0, 0, HELP_OPTION }, { "key", 1, 0, 0 }, { "keys-from-stdin", 0, 0, 0 }, @@ -132,6 +135,8 @@ main (int argc, char *argv[]) char *p; const char *format = NULL; bool format_consumed = true; + int blocksize = 0; + bool blocksize_consumed = true; int c; int option_index; struct key_store *ks = NULL; @@ -156,6 +161,8 @@ main (int argc, char *argv[]) echo_keys = 1; } else if (STREQ (long_options[option_index].name, "format")) { OPTION_format; + } else if (STREQ (long_options[option_index].name, "blocksize")) { + OPTION_blocksize; } else if (STREQ (long_options[option_index].name, "key")) { OPTION_key; } else @@ -257,6 +264,7 @@ main (int argc, char *argv[]) usage (EXIT_FAILURE); CHECK_OPTION_format_consumed; + CHECK_OPTION_blocksize_consumed; /* User must have specified some drives. */ if (drvs == NULL) { diff --git a/edit/virt-edit.pod b/edit/virt-edit.pod index 4909a7df1..85be485d9 100644 --- a/edit/virt-edit.pod +++ b/edit/virt-edit.pod @@ -153,6 +153,8 @@ If you have untrusted raw-format guest disk images, you should use this option to specify the disk format. This avoids a possible security problem with malicious guests (CVE-2010-3851). +__INCLUDE:blocksize-option.pod__ + __INCLUDE:key-option.pod__ =item B<--keys-from-stdin> diff --git a/fish/fish.c b/fish/fish.c index 2070e370e..419e989df 100644 --- a/fish/fish.c +++ b/fish/fish.c @@ -130,6 +130,8 @@ usage (int status) " --echo-keys Don’t turn off echo for passphrases\n" " -f|--file file Read commands from file\n" " --format[=raw|..] Force disk format for -a option\n" + " --blocksize[=512|4096]\n" + " Set sector size of the disk for -a option\n" " --help Display brief help\n" " -i|--inspector Automatically mount filesystems\n" " --key selector Specify a LUKS key\n" @@ -197,6 +199,7 @@ main (int argc, char *argv[]) { "echo-keys", 0, 0, 0 }, { "file", 1, 0, 'f' }, { "format", 2, 0, 0 }, + { "blocksize", 2, 0, 0 }, { "help", 0, 0, HELP_OPTION }, { "inspector", 0, 0, 'i' }, { "key", 1, 0, 0 }, @@ -228,6 +231,8 @@ main (int argc, char *argv[]) char *p, *file = NULL; const char *format = NULL; bool format_consumed = true; + int blocksize = 0; + bool blocksize_consumed = true; int c; int option_index; struct sigaction sa; @@ -285,6 +290,8 @@ main (int argc, char *argv[]) echo_keys = 1; } else if (STREQ (long_options[option_index].name, "format")) { OPTION_format; + } else if (STREQ (long_options[option_index].name, "blocksize")) { + OPTION_blocksize; } else if (STREQ (long_options[option_index].name, "csh")) { remote_control_csh = 1; } else if (STREQ (long_options[option_index].name, "live")) { @@ -468,6 +475,7 @@ main (int argc, char *argv[]) } CHECK_OPTION_format_consumed; + CHECK_OPTION_blocksize_consumed; /* If we've got drives to add, add them now. */ add_drives (drvs); diff --git a/fish/guestfish.pod b/fish/guestfish.pod index 1904b640c..279b4f000 100644 --- a/fish/guestfish.pod +++ b/fish/guestfish.pod @@ -249,6 +249,8 @@ this option to specify the disk format. This avoids a possible security problem with malicious guests (CVE-2010-3851). See also L</add>. +__INCLUDE:blocksize-option.pod__ + =item B<-i> =item B<--inspector> diff --git a/format/Makefile.am b/format/Makefile.am index 125c57184..01a04dde4 100644 --- a/format/Makefile.am +++ b/format/Makefile.am @@ -60,6 +60,7 @@ stamp-virt-format.pod: virt-format.pod $(PODWRAPPER) \ --man virt-format.1 \ --html $(top_builddir)/website/virt-format.1.html \ + --path $(top_srcdir)/common/options \ --license GPLv2+ \ --warning general \ $< diff --git a/format/format.c b/format/format.c index 5453fc7e1..6176734cd 100644 --- a/format/format.c +++ b/format/format.c @@ -82,6 +82,8 @@ usage (int status) " -a|--add image Add image\n" " --filesystem=.. Create empty filesystem\n" " --format[=raw|..] Force disk format for -a option\n" + " --blocksize[=512|4096]\n" + " Set sector size of the disk for -a option\n" " --help Display brief help\n" " --label=.. Set filesystem label\n" " --lvm=.. Create Linux LVM2 logical volume\n" @@ -114,6 +116,7 @@ main (int argc, char *argv[]) { "add", 1, 0, 'a' }, { "filesystem", 1, 0, 0 }, { "format", 2, 0, 0 }, + { "blocksize", 2, 0, 0 }, { "help", 0, 0, HELP_OPTION }, { "label", 1, 0, 0 }, { "long-options", 0, 0, 0 }, @@ -128,6 +131,8 @@ main (int argc, char *argv[]) struct drv *drvs = NULL; const char *format = NULL; bool format_consumed = true; + int blocksize = 0; + bool blocksize_consumed = true; int c; int option_index; int retry, retries; @@ -148,6 +153,8 @@ main (int argc, char *argv[]) display_short_options (options); else if (STREQ (long_options[option_index].name, "format")) { OPTION_format; + } else if (STREQ (long_options[option_index].name, "blocksize")) { + OPTION_blocksize; } else if (STREQ (long_options[option_index].name, "filesystem")) { if (STREQ (optarg, "none")) filesystem = NULL; @@ -233,6 +240,7 @@ main (int argc, char *argv[]) } CHECK_OPTION_format_consumed; + CHECK_OPTION_blocksize_consumed; /* The user didn't specify any drives to format. */ if (drvs == NULL) { diff --git a/format/virt-format.pod b/format/virt-format.pod index 11b4409a7..755fb7086 100644 --- a/format/virt-format.pod +++ b/format/virt-format.pod @@ -112,6 +112,8 @@ If you have untrusted raw-format guest disk images, you should use this option to specify the disk format. This avoids a possible security problem with malicious guests (CVE-2010-3851). +__INCLUDE:blocksize-option.pod__ + =item B<--label=>LABEL Set the filesystem label. diff --git a/fuse/guestmount.c b/fuse/guestmount.c index 6c35bcca7..6588d0d48 100644 --- a/fuse/guestmount.c +++ b/fuse/guestmount.c @@ -116,6 +116,8 @@ usage (int status) " --echo-keys Don't turn off echo for passphrases\n" " --fd=FD Write to pipe FD when mountpoint is ready\n" " --format[=raw|..] Force disk format for -a option\n" + " --blocksize[=512|4096]\n" + " Set sector size of the disk for -a option\n" " --fuse-help Display extra FUSE options\n" " -i|--inspector Automatically mount filesystems\n" " --help Display help message and exit\n" @@ -163,6 +165,7 @@ main (int argc, char *argv[]) { "echo-keys", 0, 0, 0 }, { "fd", 1, 0, 0 }, { "format", 2, 0, 0 }, + { "blocksize", 2, 0, 0 }, { "fuse-help", 0, 0, 0 }, { "help", 0, 0, HELP_OPTION }, { "inspector", 0, 0, 'i' }, @@ -191,6 +194,8 @@ main (int argc, char *argv[]) char *p; const char *format = NULL; bool format_consumed = true; + int blocksize = 0; + bool blocksize_consumed = true; int c, r; int option_index; struct sigaction sa; @@ -235,6 +240,8 @@ main (int argc, char *argv[]) /* nothing */ } else if (STREQ (long_options[option_index].name, "format")) { OPTION_format; + } else if (STREQ (long_options[option_index].name, "blocksize")) { + OPTION_blocksize; } else if (STREQ (long_options[option_index].name, "keys-from-stdin")) { keys_from_stdin = 1; } else if (STREQ (long_options[option_index].name, "echo-keys")) { @@ -316,6 +323,7 @@ main (int argc, char *argv[]) } CHECK_OPTION_format_consumed; + CHECK_OPTION_blocksize_consumed; /* Check we have the right options. */ if (!live) { diff --git a/fuse/guestmount.pod b/fuse/guestmount.pod index d4e12e641..ad5421db3 100644 --- a/fuse/guestmount.pod +++ b/fuse/guestmount.pod @@ -230,6 +230,8 @@ this option to specify the disk format. This avoids a possible security problem with malicious guests (CVE-2010-3851). See also L<guestfs(3)/guestfs_add_drive_opts>. +__INCLUDE:blocksize-option.pod__ + =item B<--fuse-help> Display help on special FUSE options (see I<-o> below). diff --git a/inspector/inspector.c b/inspector/inspector.c index fa8e721ff..c6f52b90f 100644 --- a/inspector/inspector.c +++ b/inspector/inspector.c @@ -96,6 +96,8 @@ usage (int status) " -d|--domain guest Add disks from libvirt guest\n" " --echo-keys Don't turn off echo for passphrases\n" " --format[=raw|..] Force disk format for -a option\n" + " --blocksize[=512|4096]\n" + " Set sector size of the disk for -a option\n" " --help Display brief help\n" " --key selector Specify a LUKS key\n" " --keys-from-stdin Read passphrases from stdin\n" @@ -128,6 +130,7 @@ main (int argc, char *argv[]) { "domain", 1, 0, 'd' }, { "echo-keys", 0, 0, 0 }, { "format", 2, 0, 0 }, + { "blocksize", 2, 0, 0 }, { "help", 0, 0, HELP_OPTION }, { "key", 1, 0, 0 }, { "keys-from-stdin", 0, 0, 0 }, @@ -144,6 +147,8 @@ main (int argc, char *argv[]) struct drv *drv; const char *format = NULL; bool format_consumed = true; + int blocksize = 0; + bool blocksize_consumed = true; int c; int option_index; struct key_store *ks = NULL; @@ -168,6 +173,8 @@ main (int argc, char *argv[]) echo_keys = 1; } else if (STREQ (long_options[option_index].name, "format")) { OPTION_format; + } else if (STREQ (long_options[option_index].name, "blocksize")) { + OPTION_blocksize; } else if (STREQ (long_options[option_index].name, "xpath")) { xpath = optarg; } else if (STREQ (long_options[option_index].name, "no-applications")) { @@ -262,6 +269,7 @@ main (int argc, char *argv[]) } CHECK_OPTION_format_consumed; + CHECK_OPTION_blocksize_consumed; /* XPath is modal: no drives should be specified. There must be * one extra parameter on the command line. diff --git a/inspector/virt-inspector.pod b/inspector/virt-inspector.pod index 24fbf2e08..ce823a2a8 100644 --- a/inspector/virt-inspector.pod +++ b/inspector/virt-inspector.pod @@ -114,6 +114,8 @@ parameter is ignored. If working with untrusted raw-format guest disk images, you should ensure the format is always specified. +__INCLUDE:blocksize-option.pod__ + __INCLUDE:key-option.pod__ =item B<--keys-from-stdin> diff --git a/rescue/Makefile.am b/rescue/Makefile.am index 8ceb57fb4..4018bc215 100644 --- a/rescue/Makefile.am +++ b/rescue/Makefile.am @@ -66,6 +66,7 @@ stamp-virt-rescue.pod: virt-rescue.pod $(PODWRAPPER) \ --man virt-rescue.1 \ --html $(top_builddir)/website/virt-rescue.1.html \ + --path $(top_srcdir)/common/options \ --license GPLv2+ \ --warning ro-option \ $< diff --git a/rescue/rescue.c b/rescue/rescue.c index 419242381..3865450fa 100644 --- a/rescue/rescue.c +++ b/rescue/rescue.c @@ -92,6 +92,8 @@ usage (int status) " -d|--domain guest Add disks from libvirt guest\n" " -e ^x|none Set or disable escape key (default ^])\n" " --format[=raw|..] Force disk format for -a option\n" + " --blocksize[=512|4096]\n" + " Set sector size of the disk for -a option\n" " --help Display brief help\n" " -i|--inspector Automatically mount filesystems\n" " -m|--mount dev[:mnt[:opts[:fstype]] Mount dev on mnt (if omitted, /)\n" @@ -130,6 +132,7 @@ main (int argc, char *argv[]) { "connect", 1, 0, 'c' }, { "domain", 1, 0, 'd' }, { "format", 2, 0, 0 }, + { "blocksize", 2, 0, 0 }, { "help", 0, 0, HELP_OPTION }, { "inspector", 0, 0, 'i' }, { "long-options", 0, 0, 0 }, @@ -154,6 +157,8 @@ main (int argc, char *argv[]) char *p; const char *format = NULL; bool format_consumed = true; + int blocksize = 0; + bool blocksize_consumed = true; int c; int option_index; int network = 0; @@ -187,6 +192,8 @@ main (int argc, char *argv[]) network = 1; } else if (STREQ (long_options[option_index].name, "format")) { OPTION_format; + } else if (STREQ (long_options[option_index].name, "blocksize")) { + OPTION_blocksize; } else if (STREQ (long_options[option_index].name, "smp")) { if (sscanf (optarg, "%d", &smp) != 1) error (EXIT_FAILURE, 0, @@ -334,6 +341,7 @@ main (int argc, char *argv[]) } CHECK_OPTION_format_consumed; + CHECK_OPTION_blocksize_consumed; /* User must have specified some drives. */ if (drvs == NULL) { diff --git a/rescue/virt-rescue.pod b/rescue/virt-rescue.pod index c7be8b8af..83157e209 100644 --- a/rescue/virt-rescue.pod +++ b/rescue/virt-rescue.pod @@ -176,6 +176,8 @@ If you have untrusted raw-format guest disk images, you should use this option to specify the disk format. This avoids a possible security problem with malicious guests (CVE-2010-3851). +__INCLUDE:blocksize-option.pod__ + =item B<-i> =item B<--inspector> -- 2.17.2
Nikolay Ivanets
2020-Feb-12 08:46 UTC
Re: [Libguestfs] [PATCH v2 0/1] tools: add '--blocksize' option for C-based tools
ср, 12 лют. 2020 о 03:02 Mykola Ivanets <stenavin@gmail.com> пише:> > From: Nikolay Ivanets <stenavin@gmail.com> > > This patch depends on changes in 'common' sub-module posted here: > https://www.redhat.com/archives/libguestfs/2020-February/msg00099.htmlLatest patch to common sub-module is here: https://www.redhat.com/archives/libguestfs/2020-February/msg00111.html -- Mykola Ivanets
Richard W.M. Jones
2020-Feb-13 09:46 UTC
Re: [Libguestfs] [PATCH v2 0/1] tools: add '--blocksize' option for C-based tools
On Wed, Feb 12, 2020 at 03:02:40AM +0200, Mykola Ivanets wrote:> From: Nikolay Ivanets <stenavin@gmail.com> > > This patch depends on changes in 'common' sub-module posted here: > https://www.redhat.com/archives/libguestfs/2020-February/msg00099.html > > v2: > Almost the same as v1 except '--blocksize' option description is moved > into a common submodule (similar to key-option.pod).Use of the POD file fragment is a good improvement in this version, but these options still need to appear in alphabetical order. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org
Possibly Parallel Threads
- [PATCH v3 1/1] tools: add '--blocksize' option for C-based tools
- [PATCH 1/1] tools: add '--blocksize' option for C-based tools
- [PATCH v2 0/1] tools: add '--blocksize' option for C-based tools
- [PATCH v3 0/1] tools: add '--blocksize' option for C-based tools
- [PATCH 0/1] tools: add '--blocksize' option for C-based tools