[libvirt] [PATCH RFC 47/48] iohelper: Teach command line 'sparse' argument

Michal Privoznik mprivozn at redhat.com
Wed Jun 22 14:44:04 UTC 2016


If formatted messages are required, iohelper is spawned with
'sparse' argument. Teach it to actually deal with it.

Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
---
 src/iohelper/iohelper.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/iohelper/iohelper.c b/src/iohelper/iohelper.c
index 4224d97..65fbc63 100644
--- a/src/iohelper/iohelper.c
+++ b/src/iohelper/iohelper.c
@@ -252,7 +252,7 @@ usage(int status)
         fprintf(stderr, _("%s: try --help for more details"), program_name);
     } else {
         printf(_("Usage: %s FILENAME OFLAGS MODE OFFSET LENGTH DELETE\n"
-                 "   or: %s FILENAME LENGTH FD\n"),
+                 "   or: %s FILENAME LENGTH FD [sparse]\n"),
                program_name, program_name);
     }
     exit(status);
@@ -307,13 +307,15 @@ main(int argc, char **argv)
             exit(EXIT_FAILURE);
         }
         fd = prepare(path, oflags, mode, offset);
-    } else if (argc == 4) { /* FILENAME LENGTH FD */
+    } else if (argc == 4 || argc == 5) { /* FILENAME LENGTH FD [sparse] */
         lengthIndex = 2;
         if (virStrToLong_i(argv[3], NULL, 10, &fd) < 0) {
             fprintf(stderr, _("%s: malformed fd %s"),
                     program_name, argv[3]);
             exit(EXIT_FAILURE);
         }
+        if (argc == 5)
+            sparse = STREQ(argv[4], "sparse");
 #ifdef F_GETFL
         oflags = fcntl(fd, F_GETFL);
 #else
-- 
2.8.4




More information about the libvir-list mailing list