Richard W.M. Jones
2010-Feb-12 14:40 UTC
[Libguestfs] [PATCH 0/2] Fix doubling of command names in some error messages
Depending on which commands you run and from which language bindings, the command name in error messages can be doubled or even tripled. You could see errors like: foo: foo: /path: File not found These two patches address the problem. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming blog: http://rwmj.wordpress.com Fedora now supports 80 OCaml packages (the OPEN alternative to F#) http://cocan.org/getting_started_with_ocaml_on_red_hat_and_fedora
Richard W.M. Jones
2010-Feb-12 14:43 UTC
[Libguestfs] [PATCH 1/2] perl: Don't prefix error messages with command name.
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into Xen guests. http://et.redhat.com/~rjones/virt-p2v -------------- next part -------------->From 26a2aa2a2b4440e170c51c7ee82cba31d65b78ea Mon Sep 17 00:00:00 2001From: Richard Jones <rjones at redhat.com> Date: Fri, 12 Feb 2010 13:42:57 +0000 Subject: [PATCH 1/2] perl: Don't prefix error messages with command name. The command name is already being added by the RPC stubs, so adding it again in Perl just results in doubled error messages like: foo: foo: the error --- src/generator.ml | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/generator.ml b/src/generator.ml index 607b6d1..b0ffc58 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -8149,7 +8149,7 @@ DESTROY (g) pr ";\n"; do_cleanups (); pr " if (r == -1)\n"; - pr " croak (\"%s: %%s\", guestfs_last_error (g));\n" name; + pr " croak (\"%%s\", guestfs_last_error (g));\n"; | RInt n | RBool n -> pr "PREINIT:\n"; @@ -8160,7 +8160,7 @@ DESTROY (g) pr ";\n"; do_cleanups (); pr " if (%s == -1)\n" n; - pr " croak (\"%s: %%s\", guestfs_last_error (g));\n" name; + pr " croak (\"%%s\", guestfs_last_error (g));\n"; pr " RETVAL = newSViv (%s);\n" n; pr " OUTPUT:\n"; pr " RETVAL\n" @@ -8173,7 +8173,7 @@ DESTROY (g) pr ";\n"; do_cleanups (); pr " if (%s == -1)\n" n; - pr " croak (\"%s: %%s\", guestfs_last_error (g));\n" name; + pr " croak (\"%%s\", guestfs_last_error (g));\n"; pr " RETVAL = my_newSVll (%s);\n" n; pr " OUTPUT:\n"; pr " RETVAL\n" @@ -8186,7 +8186,7 @@ DESTROY (g) pr ";\n"; do_cleanups (); pr " if (%s == NULL)\n" n; - pr " croak (\"%s: %%s\", guestfs_last_error (g));\n" name; + pr " croak (\"%%s\", guestfs_last_error (g));\n"; pr " RETVAL = newSVpv (%s, 0);\n" n; pr " OUTPUT:\n"; pr " RETVAL\n" @@ -8213,7 +8213,7 @@ DESTROY (g) pr ";\n"; do_cleanups (); pr " if (%s == NULL)\n" n; - pr " croak (\"%s: %%s\", guestfs_last_error (g));\n" name; + pr " croak (\"%%s\", guestfs_last_error (g));\n"; pr " RETVAL = newSVpv (%s, 0);\n" n; pr " free (%s);\n" n; pr " OUTPUT:\n"; @@ -8228,7 +8228,7 @@ DESTROY (g) pr ";\n"; do_cleanups (); pr " if (%s == NULL)\n" n; - pr " croak (\"%s: %%s\", guestfs_last_error (g));\n" name; + pr " croak (\"%%s\", guestfs_last_error (g));\n"; pr " for (n = 0; %s[n] != NULL; ++n) /**/;\n" n; pr " EXTEND (SP, n);\n"; pr " for (i = 0; i < n; ++i) {\n"; @@ -8252,7 +8252,7 @@ DESTROY (g) pr ";\n"; do_cleanups (); pr " if (%s == NULL)\n" n; - pr " croak (\"%s: %%s\", guestfs_last_error (g));\n" name; + pr " croak (\"%%s\", guestfs_last_error (g));\n"; pr " RETVAL = newSVpv (%s, size);\n" n; pr " free (%s);\n" n; pr " OUTPUT:\n"; -- 1.6.5.2
Richard W.M. Jones
2010-Feb-12 14:43 UTC
[Libguestfs] [PATCH 2/2] daemon: Don't need to prefix error messages with the command name.
-- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://et.redhat.com/~rjones/libguestfs/ See what it can do: http://et.redhat.com/~rjones/libguestfs/recipes.html -------------- next part -------------->From 0804010588f85ae5ec4eca3f1a8074a04df587ee Mon Sep 17 00:00:00 2001From: Richard Jones <rjones at redhat.com> Date: Fri, 12 Feb 2010 14:06:25 +0000 Subject: [PATCH 2/2] daemon: Don't need to prefix error messages with the command name. The RPC stubs already prefix the command name to error messages. The daemon doesn't have to do this. As a (small) benefit this also makes the daemon slightly smaller. Code in the daemon such as: if (argv[0] == NULL) { reply_with_error ("passed an empty list"); return NULL; } now results in error messages like this: ><fs> command "" libguestfs: error: command: passed an empty list (whereas previously you would have seen ..command: command:..) --- daemon/blkid.c | 2 +- daemon/blockdev.c | 2 +- daemon/cmp.c | 2 +- daemon/command.c | 2 +- daemon/cpmv.c | 2 +- daemon/daemon.h | 5 ++++- daemon/dd.c | 2 +- daemon/debug.c | 2 +- daemon/df.c | 4 ++-- daemon/dir.c | 16 ++++++++-------- daemon/dmesg.c | 2 +- daemon/du.c | 4 ++-- daemon/ext2.c | 30 +++++++++++++++--------------- daemon/fallocate.c | 4 ++-- daemon/file.c | 24 ++++++++++++------------ daemon/fill.c | 4 ++-- daemon/find.c | 2 +- daemon/fsck.c | 2 +- daemon/glob.c | 2 +- daemon/grub.c | 2 +- daemon/hexdump.c | 2 +- daemon/initrd.c | 2 +- daemon/inotify.c | 12 ++++++------ daemon/link.c | 2 +- daemon/lvm.c | 8 ++++---- daemon/mkfs.c | 2 +- daemon/mknod.c | 2 +- daemon/mount.c | 12 ++++++------ daemon/ntfs.c | 2 +- daemon/parted.c | 16 ++++++++-------- daemon/realpath.c | 6 +++--- daemon/scrub.c | 6 +++--- daemon/sfdisk.c | 2 +- daemon/stat.c | 2 +- daemon/strings.c | 2 +- daemon/swap.c | 4 ++-- daemon/tar.c | 4 ++-- daemon/upload.c | 2 +- daemon/wc.c | 2 +- daemon/xattr.c | 22 +++++++++++----------- daemon/zerofree.c | 2 +- src/generator.ml | 2 +- 42 files changed, 117 insertions(+), 114 deletions(-) diff --git a/daemon/blkid.c b/daemon/blkid.c index 4e14881..4c77b82 100644 --- a/daemon/blkid.c +++ b/daemon/blkid.c @@ -36,7 +36,7 @@ do_vfs_type (const char *device) r = command (&out, &err, "/sbin/blkid", "-o", "value", "-s", "TYPE", device, NULL); if (r == -1) { - reply_with_error ("vfs_type: %s: %s", device, err); + reply_with_error ("%s: %s", device, err); free (out); free (err); return NULL; diff --git a/daemon/blockdev.c b/daemon/blockdev.c index 4d3c2ab..95e5246 100644 --- a/daemon/blockdev.c +++ b/daemon/blockdev.c @@ -111,7 +111,7 @@ int do_blockdev_setbsz (const char *device, int blocksize) { if (blocksize <= 0 /* || blocksize >= what? */) { - reply_with_error ("blockdev_setbsz: blocksize must be > 0"); + reply_with_error ("blocksize must be > 0"); return -1; } return (int) call_blockdev (device, "--setbsz", blocksize, 0); diff --git a/daemon/cmp.c b/daemon/cmp.c index 2b7e33b..bbf9c74 100644 --- a/daemon/cmp.c +++ b/daemon/cmp.c @@ -53,7 +53,7 @@ do_equal (const char *file1, const char *file2) free (file2buf); if (r == -1 || r > 1) { - reply_with_error ("cmp: %s", err); + reply_with_error ("%s", err); free (err); return -1; } diff --git a/daemon/command.c b/daemon/command.c index b2350ec..ca06478 100644 --- a/daemon/command.c +++ b/daemon/command.c @@ -43,7 +43,7 @@ do_command (char *const *argv) * commandv. We just have to check the list is non-empty. */ if (argv[0] == NULL) { - reply_with_error ("command: passed an empty list"); + reply_with_error ("passed an empty list"); return NULL; } diff --git a/daemon/cpmv.c b/daemon/cpmv.c index 47b8aa2..587e017 100644 --- a/daemon/cpmv.c +++ b/daemon/cpmv.c @@ -74,7 +74,7 @@ cpmv_cmd (const char *cmd, const char *flags, const char *src, const char *dest) free (destbuf); if (r == -1) { - reply_with_error ("%s: %s", cmd, err); + reply_with_error ("%s", err); free (err); return -1; } diff --git a/daemon/daemon.h b/daemon/daemon.h index 88d0306..bb1ebb3 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -116,7 +116,10 @@ extern int sync_disks (void); /*-- in proto.c --*/ extern void main_loop (int sock) __attribute__((noreturn)); -/* ordinary daemon functions use these to indicate errors */ +/* ordinary daemon functions use these to indicate errors + * NB: you don't need to prefix the string with the current command, + * it is added automatically by the client-side RPC stubs. + */ extern void reply_with_error (const char *fs, ...) __attribute__((format (printf,1,2))); extern void reply_with_perror_errno (int err, const char *fs, ...) diff --git a/daemon/dd.c b/daemon/dd.c index 0a53b31..d92dac0 100644 --- a/daemon/dd.c +++ b/daemon/dd.c @@ -62,7 +62,7 @@ do_dd (const char *src, const char *dest) free (of_arg); if (r == -1) { - reply_with_error ("dd: %s: %s: %s", src, dest, err); + reply_with_error ("%s: %s: %s", src, dest, err); free (err); return -1; } diff --git a/daemon/debug.c b/daemon/debug.c index cb905cb..5d26c4e 100644 --- a/daemon/debug.c +++ b/daemon/debug.c @@ -215,7 +215,7 @@ debug_sh (const char *subcmd, int argc, char *const *const argv) char *out; if (argc < 1) { - reply_with_error ("debug: sh: expecting a command to run"); + reply_with_error ("sh: expecting a command to run"); return NULL; } diff --git a/daemon/df.c b/daemon/df.c index 563760d..b5c4980 100644 --- a/daemon/df.c +++ b/daemon/df.c @@ -37,7 +37,7 @@ do_df (void) r = command (&out, &err, "df", NULL); if (r == -1) { - reply_with_error ("df: %s", err); + reply_with_error ("%s", err); free (out); free (err); return NULL; @@ -58,7 +58,7 @@ do_df_h (void) r = command (&out, &err, "df", "-h", NULL); if (r == -1) { - reply_with_error ("df -h: %s", err); + reply_with_error ("%s", err); free (out); free (err); return NULL; diff --git a/daemon/dir.c b/daemon/dir.c index 300bb4c..205139b 100644 --- a/daemon/dir.c +++ b/daemon/dir.c @@ -39,7 +39,7 @@ do_rmdir (const char *path) CHROOT_OUT; if (r == -1) { - reply_with_perror ("rmdir: %s", path); + reply_with_perror ("%s", path); return -1; } @@ -57,7 +57,7 @@ do_rm_rf (const char *path) char *buf, *err; if (STREQ (path, "/")) { - reply_with_error ("rm -rf: cannot remove root directory"); + reply_with_error ("cannot remove root directory"); return -1; } @@ -72,7 +72,7 @@ do_rm_rf (const char *path) /* rm -rf is never supposed to fail. I/O errors perhaps? */ if (r == -1) { - reply_with_error ("rm -rf: %s: %s", path, err); + reply_with_error ("%s: %s", path, err); free (err); return -1; } @@ -92,7 +92,7 @@ do_mkdir (const char *path) CHROOT_OUT; if (r == -1) { - reply_with_perror ("mkdir: %s", path); + reply_with_perror ("%s", path); return -1; } @@ -109,7 +109,7 @@ do_mkdir_mode (const char *path, int mode) CHROOT_OUT; if (r == -1) { - reply_with_perror ("mkdir_mode: %s", path); + reply_with_perror ("%s", path); return -1; } @@ -174,11 +174,11 @@ do_mkdir_p (const char *path) CHROOT_OUT; if (r == -1) { - reply_with_perror ("mkdir -p: %s", path); + reply_with_perror ("%s", path); return -1; } if (r == -2) { - reply_with_error ("mkdir -p: %s: a path element was not a directory", path); + reply_with_error ("%s: a path element was not a directory", path); return -1; } @@ -221,7 +221,7 @@ do_mkdtemp (const char *template) CHROOT_OUT; if (r == NULL) { - reply_with_perror ("mkdtemp: %s", template); + reply_with_perror ("%s", template); free (writable); } diff --git a/daemon/dmesg.c b/daemon/dmesg.c index adc3426..462787a 100644 --- a/daemon/dmesg.c +++ b/daemon/dmesg.c @@ -35,7 +35,7 @@ do_dmesg (void) r = command (&out, &err, "dmesg", NULL); if (r == -1) { - reply_with_error ("dmesg: %s", err); + reply_with_error ("%s", err); free (out); free (err); return NULL; diff --git a/daemon/du.c b/daemon/du.c index e6df245..942a699 100644 --- a/daemon/du.c +++ b/daemon/du.c @@ -46,7 +46,7 @@ do_du (const char *path) r = command (&out, &err, "du", "-s", buf, NULL); free (buf); if (r == -1) { - reply_with_error ("du: %s: %s", path, err); + reply_with_error ("%s: %s", path, err); free (out); free (err); return -1; @@ -55,7 +55,7 @@ do_du (const char *path) free (err); if (sscanf (out, "%"SCNi64, &rv) != 1) { - reply_with_error ("du: %s: could not read output: %s", path, out); + reply_with_error ("%s: could not read output: %s", path, out); free (out); return -1; } diff --git a/daemon/ext2.c b/daemon/ext2.c index f46bac9..85ddce5 100644 --- a/daemon/ext2.c +++ b/daemon/ext2.c @@ -39,7 +39,7 @@ do_tune2fs_l (const char *device) r = command (&out, &err, "/sbin/tune2fs", "-l", device, NULL); if (r == -1) { - reply_with_error ("tune2fs: %s", err); + reply_with_error ("%s", err); free (err); free (out); return NULL; @@ -53,7 +53,7 @@ do_tune2fs_l (const char *device) p = strchr (p, '\n'); if (p) p++; else { - reply_with_error ("tune2fs: truncated output"); + reply_with_error ("truncated output"); free (out); return NULL; } @@ -123,7 +123,7 @@ do_set_e2label (const char *device, const char *label) r = command (NULL, &err, "/sbin/e2label", device, label, NULL); if (r == -1) { - reply_with_error ("e2label: %s", err); + reply_with_error ("%s", err); free (err); return -1; } @@ -140,7 +140,7 @@ do_get_e2label (const char *device) r = command (&out, &err, "/sbin/e2label", device, NULL); if (r == -1) { - reply_with_error ("e2label: %s", err); + reply_with_error ("%s", err); free (out); free (err); return NULL; @@ -164,7 +164,7 @@ do_set_e2uuid (const char *device, const char *uuid) r = command (NULL, &err, "/sbin/tune2fs", "-U", uuid, device, NULL); if (r == -1) { - reply_with_error ("tune2fs -U: %s", err); + reply_with_error ("%s", err); free (err); return -1; } @@ -186,7 +186,7 @@ do_get_e2uuid (const char *device) r = command (&out, &err, "/sbin/tune2fs", "-l", device, NULL); if (r == -1) { - reply_with_error ("tune2fs -l: %s", err); + reply_with_error ("%s", err); free (out); free (err); return NULL; @@ -242,7 +242,7 @@ do_resize2fs (const char *device) r = command (NULL, &err, "/sbin/resize2fs", device, NULL); if (r == -1) { - reply_with_error ("resize2fs: %s", err); + reply_with_error ("%s", err); free (err); return -1; } @@ -259,7 +259,7 @@ do_e2fsck_f (const char *device) r = command (NULL, &err, "/sbin/e2fsck", "-p", "-f", device, NULL); if (r == -1) { - reply_with_error ("e2fsck: %s", err); + reply_with_error ("%s", err); free (err); return -1; } @@ -281,7 +281,7 @@ do_mke2journal (int blocksize, const char *device) "/sbin/mke2fs", "-O", "journal_dev", "-b", blocksize_s, device, NULL); if (r == -1) { - reply_with_error ("mke2journal: %s", err); + reply_with_error ("%s", err); free (err); return -1; } @@ -304,7 +304,7 @@ do_mke2journal_L (int blocksize, const char *label, const char *device) "-L", label, device, NULL); if (r == -1) { - reply_with_error ("mke2journal_L: %s", err); + reply_with_error ("%s", err); free (err); return -1; } @@ -327,7 +327,7 @@ do_mke2journal_U (int blocksize, const char *uuid, const char *device) "-U", uuid, device, NULL); if (r == -1) { - reply_with_error ("mke2journal_U: %s", err); + reply_with_error ("%s", err); free (err); return -1; } @@ -366,7 +366,7 @@ get_mke2fs (void) if (access (progs[i], F_OK) == 0) return progs[i]; - reply_with_error ("mke2fs: no mke2fs binary found in appliance"); + reply_with_error ("no mke2fs binary found in appliance"); return NULL; } @@ -391,7 +391,7 @@ do_mke2fs_J (const char *fstype, int blocksize, const char *device, prog, "-t", fstype, "-J", jdev, "-b", blocksize_s, device, NULL); if (r == -1) { - reply_with_error ("mke2fs_J: %s", err); + reply_with_error ("%s", err); free (err); return -1; } @@ -421,7 +421,7 @@ do_mke2fs_JL (const char *fstype, int blocksize, const char *device, prog, "-t", fstype, "-J", jdev, "-b", blocksize_s, device, NULL); if (r == -1) { - reply_with_error ("mke2fs_JL: %s", err); + reply_with_error ("%s", err); free (err); return -1; } @@ -451,7 +451,7 @@ do_mke2fs_JU (const char *fstype, int blocksize, const char *device, prog, "-t", fstype, "-J", jdev, "-b", blocksize_s, device, NULL); if (r == -1) { - reply_with_error ("mke2fs_JU: %s", err); + reply_with_error ("%s", err); free (err); return -1; } diff --git a/daemon/fallocate.c b/daemon/fallocate.c index 1800292..7f17f8b 100644 --- a/daemon/fallocate.c +++ b/daemon/fallocate.c @@ -36,7 +36,7 @@ do_fallocate (const char *path, int len) fd = open (path, O_WRONLY | O_CREAT | O_TRUNC | O_NOCTTY, 0666); CHROOT_OUT; if (fd == -1) { - reply_with_perror ("failed to open %s", path); + reply_with_perror ("open: %s", path); return -1; } @@ -45,7 +45,7 @@ do_fallocate (const char *path, int len) r = posix_fallocate (fd, 0, len); if (r == -1) { - reply_with_perror ("posix_fallocate: %s", path); + reply_with_perror ("%s", path); close (fd); return -1; } diff --git a/daemon/file.c b/daemon/file.c index 839713f..dbdbbaa 100644 --- a/daemon/file.c +++ b/daemon/file.c @@ -87,7 +87,7 @@ do_cat (const char *path) if (size >= alloc) { alloc += 8192; if (alloc > max) { - reply_with_error ("cat: %s: file is too large for message buffer", + reply_with_error ("%s: file is too large for message buffer", path); free (buf); close (fd); @@ -186,7 +186,7 @@ do_rm (const char *path) CHROOT_OUT; if (r == -1) { - reply_with_perror ("unlink: %s", path); + reply_with_perror ("%s", path); return -1; } @@ -203,7 +203,7 @@ do_chmod (int mode, const char *path) CHROOT_OUT; if (r == -1) { - reply_with_perror ("chmod: %s: 0%o", path, mode); + reply_with_perror ("%s: 0%o", path, mode); return -1; } @@ -220,7 +220,7 @@ do_chown (int owner, int group, const char *path) CHROOT_OUT; if (r == -1) { - reply_with_perror ("chown: %s: %d.%d", path, owner, group); + reply_with_perror ("%s: %d.%d", path, owner, group); return -1; } @@ -237,7 +237,7 @@ do_lchown (int owner, int group, const char *path) CHROOT_OUT; if (r == -1) { - reply_with_perror ("lchown: %s: %d.%d", path, owner, group); + reply_with_perror ("%s: %d.%d", path, owner, group); return -1; } @@ -338,7 +338,7 @@ do_read_file (const char *path, size_t *size_r) * be caught later when we try to serialize the message. */ if (*size_r >= GUESTFS_MESSAGE_MAX) { - reply_with_error ("read_file: %s: file is too large for the protocol, use guestfs_download instead", path); + reply_with_error ("%s: file is too large for the protocol, use guestfs_download instead", path); close (fd); return NULL; } @@ -378,7 +378,7 @@ do_pread (const char *path, int count, int64_t offset, size_t *size_r) * will be caught later when we try to serialize the message. */ if (count >= GUESTFS_MESSAGE_MAX) { - reply_with_error ("pread: %s: count is too large for the protocol, use smaller reads", path); + reply_with_error ("%s: count is too large for the protocol, use smaller reads", path); return NULL; } @@ -453,7 +453,7 @@ do_file (const char *path) if (r == -1) { free (out); - reply_with_error ("file: %s: %s", path, err); + reply_with_error ("%s: %s", path, err); free (err); return NULL; } @@ -482,7 +482,7 @@ do_zfile (const char *method, const char *path) else if (STREQ (method, "bzip2")) zcat = "bzcat"; else { - reply_with_error ("zfile: unknown method"); + reply_with_error ("unknown method"); return NULL; } @@ -504,13 +504,13 @@ do_zfile (const char *method, const char *path) free (cmd); if (fgets (line, sizeof line, fp) == NULL) { - reply_with_perror ("zfile: fgets"); + reply_with_perror ("fgets"); fclose (fp); return NULL; } if (fclose (fp) == -1) { - reply_with_perror ("zfile: fclose"); + reply_with_perror ("fclose"); return NULL; } @@ -532,7 +532,7 @@ do_filesize (const char *path) CHROOT_OUT; if (r == -1) { - reply_with_perror ("filesize: %s", path); + reply_with_perror ("%s", path); return -1; } diff --git a/daemon/fill.c b/daemon/fill.c index 9551502..5a391aa 100644 --- a/daemon/fill.c +++ b/daemon/fill.c @@ -38,12 +38,12 @@ do_fill (int c, int len, const char *path) char buf[BUFSIZ]; if (c < 0 || c > 255) { - reply_with_error ("fill: %d: byte number must be in range 0..255", c); + reply_with_error ("%d: byte number must be in range 0..255", c); return -1; } memset (buf, c, BUFSIZ); if (len < 0) { - reply_with_error ("fill: %d: length is < 0", len); + reply_with_error ("%d: length is < 0", len); return -1; } len_sz = (size_t) len; diff --git a/daemon/find.c b/daemon/find.c index 391b87b..535e46f 100644 --- a/daemon/find.c +++ b/daemon/find.c @@ -114,7 +114,7 @@ do_find (const char *dir) } } if (pclose (fp) != 0) { - reply_with_perror ("pclose: find"); + reply_with_perror ("pclose"); free_stringslen (res, size); return NULL; } diff --git a/daemon/fsck.c b/daemon/fsck.c index 7139094..932f1c5 100644 --- a/daemon/fsck.c +++ b/daemon/fsck.c @@ -34,7 +34,7 @@ do_fsck (const char *fstype, const char *device) r = commandr (NULL, &err, "/sbin/fsck", "-a", "-t", fstype, device, NULL); if (r == -1) { - reply_with_error ("fsck: %s: %s", device, err); + reply_with_error ("%s: %s", device, err); free (err); return -1; } diff --git a/daemon/glob.c b/daemon/glob.c index 4fe76f3..e94e4aa 100644 --- a/daemon/glob.c +++ b/daemon/glob.c @@ -46,7 +46,7 @@ do_glob_expand (const char *pattern) if (r != 0) { if (errno != 0) - reply_with_perror ("glob: %s", pattern); + reply_with_perror ("%s", pattern); else reply_with_error ("glob failed: %s", pattern); return NULL; diff --git a/daemon/grub.c b/daemon/grub.c index 657abbb..579cc6b 100644 --- a/daemon/grub.c +++ b/daemon/grub.c @@ -41,7 +41,7 @@ do_grub_install (const char *root, const char *device) free (buf); if (r == -1) { - reply_with_error ("grub-install: %s", err); + reply_with_error ("%s", err); free (err); return -1; } diff --git a/daemon/hexdump.c b/daemon/hexdump.c index 7016faf..1b33eeb 100644 --- a/daemon/hexdump.c +++ b/daemon/hexdump.c @@ -41,7 +41,7 @@ do_hexdump (const char *path) r = command (&out, &err, "hexdump", "-C", buf, NULL); free (buf); if (r == -1) { - reply_with_error ("hexdump: %s: %s", path, err); + reply_with_error ("%s: %s", path, err); free (err); free (out); return NULL; diff --git a/daemon/initrd.c b/daemon/initrd.c index 5e73d40..addeb14 100644 --- a/daemon/initrd.c +++ b/daemon/initrd.c @@ -149,7 +149,7 @@ do_initrd_cat (const char *path, const char *filename, size_t *size_r) * be caught later when we try to serialize the message. */ if (*size_r >= GUESTFS_MESSAGE_MAX) { - reply_with_error ("initrd_cat: %s:%s: file is too large for the protocol", + reply_with_error ("%s:%s: file is too large for the protocol", path, filename); goto cleanup; } diff --git a/daemon/inotify.c b/daemon/inotify.c index 24ce76e..ec3aa64 100644 --- a/daemon/inotify.c +++ b/daemon/inotify.c @@ -73,7 +73,7 @@ do_inotify_init (int max_events) NEED_ROOT (return -1); if (max_events < 0) { - reply_with_error ("inotify_init: max_events < 0"); + reply_with_error ("max_events < 0"); return -1; } @@ -94,7 +94,7 @@ do_inotify_init (int max_events) #ifdef HAVE_INOTIFY_INIT1 inotify_fd = inotify_init1 (IN_NONBLOCK | IN_CLOEXEC); if (inotify_fd == -1) { - reply_with_perror ("inotify_init"); + reply_with_perror ("inotify_init1"); return -1; } #else @@ -130,7 +130,7 @@ do_inotify_close (void) NEED_INOTIFY (-1); if (inotify_fd == -1) { - reply_with_error ("inotify_close: handle is not open"); + reply_with_error ("handle is not open"); return -1; } @@ -166,7 +166,7 @@ do_inotify_add_watch (const char *path, int mask) r = inotify_add_watch (inotify_fd, buf, mask); free (buf); if (r == -1) { - reply_with_perror ("inotify_add_watch: %s", path); + reply_with_perror ("%s", path); return -1; } @@ -183,7 +183,7 @@ do_inotify_rm_watch (int wd) NEED_INOTIFY (-1); if (inotify_rm_watch (inotify_fd, wd) == -1) { - reply_with_perror ("inotify_rm_watch: %d", wd); + reply_with_perror ("%d", wd); return -1; } @@ -230,7 +230,7 @@ do_inotify_read (void) goto error; } if (r == 0) { /* End of file - we're not expecting it. */ - reply_with_error ("inotify_read: unexpected end of file"); + reply_with_error ("unexpected end of file"); goto error; } diff --git a/daemon/link.c b/daemon/link.c index 5ea0d39..3766d8c 100644 --- a/daemon/link.c +++ b/daemon/link.c @@ -68,7 +68,7 @@ do_readlinklist (const char *path, char *const *names) CHROOT_OUT; if (fd_cwd == -1) { - reply_with_perror ("readlinklist: %s", path); + reply_with_perror ("open: %s", path); return NULL; } diff --git a/daemon/lvm.c b/daemon/lvm.c index 7a05a54..b100cd3 100644 --- a/daemon/lvm.c +++ b/daemon/lvm.c @@ -270,7 +270,7 @@ do_lvresize (const char *logvol, int mbytes) "/sbin/lvm", "lvresize", "-L", size, logvol, NULL); if (r == -1) { - reply_with_error ("lvresize: %s", err); + reply_with_error ("%s", err); free (err); return -1; } @@ -418,7 +418,7 @@ do_pvresize (const char *device) r = command (NULL, &err, "/sbin/lvm", "pvresize", device, NULL); if (r == -1) { - reply_with_error ("pvresize: %s: %s", device, err); + reply_with_error ("%s: %s", device, err); free (err); return -1; } @@ -479,7 +479,7 @@ do_lvrename (const char *logvol, const char *newlogvol) "/sbin/lvm", "lvrename", logvol, newlogvol, NULL); if (r == -1) { - reply_with_error ("lvrename: %s -> %s: %s", logvol, newlogvol, err); + reply_with_error ("%s -> %s: %s", logvol, newlogvol, err); free (err); return -1; } @@ -501,7 +501,7 @@ do_vgrename (const char *volgroup, const char *newvolgroup) "/sbin/lvm", "vgrename", volgroup, newvolgroup, NULL); if (r == -1) { - reply_with_error ("vgrename: %s -> %s: %s", volgroup, newvolgroup, err); + reply_with_error ("%s -> %s: %s", volgroup, newvolgroup, err); free (err); return -1; } diff --git a/daemon/mkfs.c b/daemon/mkfs.c index ba245b3..2beb82a 100644 --- a/daemon/mkfs.c +++ b/daemon/mkfs.c @@ -83,7 +83,7 @@ mkfs (const char *fstype, const char *device, r = commandv (NULL, &err, argv); if (r == -1) { - reply_with_error ("mkfs: %s: %s: %s", fstype, device, err); + reply_with_error ("%s: %s: %s", fstype, device, err); free (err); return -1; } diff --git a/daemon/mknod.c b/daemon/mknod.c index 46a1839..50865a6 100644 --- a/daemon/mknod.c +++ b/daemon/mknod.c @@ -56,7 +56,7 @@ do_mknod (int mode, int devmajor, int devminor, const char *path) CHROOT_OUT; if (r == -1) { - reply_with_perror ("mknod: %s", path); + reply_with_perror ("%s", path); return -1; } diff --git a/daemon/mount.c b/daemon/mount.c index 49a0eab..838bef8 100644 --- a/daemon/mount.c +++ b/daemon/mount.c @@ -53,7 +53,7 @@ do_mount_vfs (const char *options, const char *vfstype, is_root = STREQ (mountpoint, "/"); if (!root_mounted && !is_root) { - reply_with_error ("mount: you must mount something on / first"); + reply_with_error ("you must mount something on / first"); return -1; } @@ -71,7 +71,7 @@ do_mount_vfs (const char *options, const char *vfstype, "mount", "-o", options, device, mp, NULL); free (mp); if (r == -1) { - reply_with_error ("mount: %s on %s: %s", device, mountpoint, error); + reply_with_error ("%s on %s: %s", device, mountpoint, error); free (error); return -1; } @@ -127,7 +127,7 @@ do_umount (const char *pathordevice) free (buf); if (r == -1) { - reply_with_error ("umount: %s: %s", pathordevice, err); + reply_with_error ("%s: %s", pathordevice, err); free (err); return -1; } @@ -338,7 +338,7 @@ do_mount_loop (const char *file, const char *mountpoint) free (mp); free (buf); if (r == -1) { - reply_with_error ("mount: %s on %s: %s", file, mountpoint, error); + reply_with_error ("%s on %s: %s", file, mountpoint, error); free (error); return -1; } @@ -363,7 +363,7 @@ do_mkmountpoint (const char *path) CHROOT_OUT; if (r == -1) { - reply_with_perror ("mkmountpoint: %s", path); + reply_with_perror ("%s", path); return -1; } @@ -388,7 +388,7 @@ do_rmmountpoint (const char *path) CHROOT_OUT; if (r == -1) { - reply_with_perror ("rmmountpoint: %s", path); + reply_with_perror ("%s", path); return -1; } diff --git a/daemon/ntfs.c b/daemon/ntfs.c index b353008..73ccbbc 100644 --- a/daemon/ntfs.c +++ b/daemon/ntfs.c @@ -45,7 +45,7 @@ do_ntfs_3g_probe (int rw, const char *device) r = commandr (NULL, &err, "ntfs-3g.probe", rw_flag, device, NULL); if (r == -1) { - reply_with_error ("ntfs-3g.probe: %s: %s", device, err); + reply_with_error ("%s: %s", device, err); free (err); return -1; } diff --git a/daemon/parted.c b/daemon/parted.c index 2b0df44..3b656bc 100644 --- a/daemon/parted.c +++ b/daemon/parted.c @@ -103,7 +103,7 @@ do_part_init (const char *device, const char *parttype) { parttype = check_parttype (parttype); if (!parttype) { - reply_with_error ("part-init: unknown partition type: common choices are \"gpt\" and \"msdos\""); + reply_with_error ("unknown partition type: common choices are \"gpt\" and \"msdos\""); return -1; } @@ -133,12 +133,12 @@ do_part_add (const char *device, const char *prlogex, else if (STREQ (prlogex, "e")) prlogex = "extended"; else { - reply_with_error ("part-add: unknown partition type: %s: this should be \"primary\", \"logical\" or \"extended\"", prlogex); + reply_with_error ("unknown partition type: %s: this should be \"primary\", \"logical\" or \"extended\"", prlogex); return -1; } if (startsect < 0) { - reply_with_error ("part-add: startsect cannot be negative"); + reply_with_error ("startsect cannot be negative"); return -1; } /* but endsect can be negative */ @@ -166,7 +166,7 @@ do_part_disk (const char *device, const char *parttype) parttype = check_parttype (parttype); if (!parttype) { - reply_with_error ("part-disk: unknown partition type: common choices are \"gpt\" and \"msdos\""); + reply_with_error ("unknown partition type: common choices are \"gpt\" and \"msdos\""); return -1; } @@ -249,14 +249,14 @@ print_partition_table (const char *device) return NULL; if (lines[0] == NULL || STRNEQ (lines[0], "BYT;")) { - reply_with_error ("parted print: unknown signature, expected \"BYT;\" as first line of the output: %s", + reply_with_error ("unknown signature, expected \"BYT;\" as first line of the output: %s", lines[0] ? lines[0] : "(signature was null)"); free_strings (lines); return NULL; } if (lines[1] == NULL) { - reply_with_error ("parted print: parted didn't return a line describing the device"); + reply_with_error ("parted didn't return a line describing the device"); free_strings (lines); return NULL; } @@ -284,7 +284,7 @@ do_part_get_parttype (const char *device) || strtok (NULL, ":") == NULL /* physical sector size */ || (r = strtok (NULL, ":")) == NULL /* return value */ ) { - reply_with_error ("part_get_parttype: too few fields in output from parted print command: %s", lines[1]); + reply_with_error ("too few fields in output from parted print command: %s", lines[1]); free_strings (lines); return NULL; } @@ -339,7 +339,7 @@ do_part_list (const char *device) &r->guestfs_int_partition_list_val[i].part_start, &r->guestfs_int_partition_list_val[i].part_end, &r->guestfs_int_partition_list_val[i].part_size) != 4) { - reply_with_error ("part_list: could not parse row from output of parted print command: %s", lines[row]); + reply_with_error ("could not parse row from output of parted print command: %s", lines[row]); goto error3; } } diff --git a/daemon/realpath.c b/daemon/realpath.c index e6c81ef..89f7737 100644 --- a/daemon/realpath.c +++ b/daemon/realpath.c @@ -56,7 +56,7 @@ do_realpath (const char *path) ret = realpath (path, NULL); CHROOT_OUT; if (ret == NULL) { - reply_with_perror ("realpath"); + reply_with_perror ("%s", path); return NULL; } @@ -98,11 +98,11 @@ do_case_sensitive_path (const char *path) if ((i == 1 && path[0] == '.') || (i == 2 && path[0] == '.' && path[1] == '.')) { - reply_with_error ("case_sensitive_path: path contained . or .. elements"); + reply_with_error ("path contained . or .. elements"); goto error; } if (i > NAME_MAX) { - reply_with_error ("case_sensitive_path: path element too long"); + reply_with_error ("path element too long"); goto error; } diff --git a/daemon/scrub.c b/daemon/scrub.c index e37a1e1..08c6d47 100644 --- a/daemon/scrub.c +++ b/daemon/scrub.c @@ -43,7 +43,7 @@ do_scrub_device (const char *device) r = command (NULL, &err, "scrub", device, NULL); if (r == -1) { - reply_with_error ("scrub_device: %s: %s", device, err); + reply_with_error ("%s: %s", device, err); free (err); return -1; } @@ -70,7 +70,7 @@ do_scrub_file (const char *file) r = command (NULL, &err, "scrub", "-r", buf, NULL); free (buf); if (r == -1) { - reply_with_error ("scrub_file: %s: %s", file, err); + reply_with_error ("%s: %s", file, err); free (err); return -1; } @@ -97,7 +97,7 @@ do_scrub_freespace (const char *dir) r = command (NULL, &err, "scrub", "-X", buf, NULL); free (buf); if (r == -1) { - reply_with_error ("scrub_freespace: %s: %s", dir, err); + reply_with_error ("%s: %s", dir, err); free (err); return -1; } diff --git a/daemon/sfdisk.c b/daemon/sfdisk.c index b68b9f6..14297e7 100644 --- a/daemon/sfdisk.c +++ b/daemon/sfdisk.c @@ -124,7 +124,7 @@ sfdisk_flag (const char *device, const char *flag) r = command (&out, &err, "/sbin/sfdisk", flag, device, NULL); if (r == -1) { - reply_with_error ("sfdisk: %s: %s", device, err); + reply_with_error ("%s: %s", device, err); free (out); free (err); return NULL; diff --git a/daemon/stat.c b/daemon/stat.c index 20f4b70..c939e8e 100644 --- a/daemon/stat.c +++ b/daemon/stat.c @@ -151,7 +151,7 @@ do_lstatlist (const char *path, char *const *names) CHROOT_OUT; if (path_fd == -1) { - reply_with_perror ("lstatlist: %s", path); + reply_with_perror ("%s", path); free (ret->guestfs_int_stat_list_val); free (ret); return NULL; diff --git a/daemon/strings.c b/daemon/strings.c index d7dc392..4701716 100644 --- a/daemon/strings.c +++ b/daemon/strings.c @@ -42,7 +42,7 @@ do_strings_e (const char *encoding, const char *path) r = command (&out, &err, "strings", "-e", encoding, buf, NULL); free (buf); if (r == -1) { - reply_with_error ("strings: %s: %s", path, err); + reply_with_error ("%s: %s", path, err); free (err); free (out); return NULL; diff --git a/daemon/swap.c b/daemon/swap.c index 2d3d9ff..fbeb895 100644 --- a/daemon/swap.c +++ b/daemon/swap.c @@ -58,7 +58,7 @@ mkswap (const char *device, const char *flag, const char *value) r = command (NULL, &err, "/sbin/mkswap", "-f", flag, value, device, NULL); if (r == -1) { - reply_with_error ("mkswap: %s", err); + reply_with_error ("%s", err); free (err); return -1; } @@ -115,7 +115,7 @@ swaponoff (const char *cmd, const char *flag, const char *value) r = command (NULL, &err, cmd, flag, value, NULL); if (r == -1) { - reply_with_error ("%s: %s: %s", cmd, value, err); + reply_with_error ("%s: %s", value, err); free (err); return -1; } diff --git a/daemon/tar.c b/daemon/tar.c index c3bdcf7..ebcaded 100644 --- a/daemon/tar.c +++ b/daemon/tar.c @@ -44,7 +44,7 @@ do_tar_in (const char *dir) if (!root_mounted || dir[0] != '/') { cancel_receive (); - reply_with_error ("tar-in: root must be mounted and path must be absolute"); + reply_with_error ("root must be mounted and path must be absolute"); return -1; } @@ -165,7 +165,7 @@ do_tgz_in (const char *dir) if (!root_mounted || dir[0] != '/') { cancel_receive (); - reply_with_error ("tar-in: root must be mounted and path must be absolute"); + reply_with_error ("root must be mounted and path must be absolute"); return -1; } diff --git a/daemon/upload.c b/daemon/upload.c index fdb8654..e15eade 100644 --- a/daemon/upload.c +++ b/daemon/upload.c @@ -44,7 +44,7 @@ do_upload (const char *filename) if (!is_dev) { if (!root_mounted || filename[0] != '/') { cancel_receive (); - reply_with_error ("upload: root must be mounted and path must be absolute"); + reply_with_error ("root must be mounted and path must be absolute"); return -1; } } diff --git a/daemon/wc.c b/daemon/wc.c index b64940b..fe27bf1 100644 --- a/daemon/wc.c +++ b/daemon/wc.c @@ -60,7 +60,7 @@ wc (const char *flag, const char *path) /* Parse the number. */ if (sscanf (out, "%d", &r) != 1) { - reply_with_error ("wc: cannot parse number: %s", out); + reply_with_error ("cannot parse number: %s", out); free (out); return -1; } diff --git a/daemon/xattr.c b/daemon/xattr.c index e58dc7e..6d356fa 100644 --- a/daemon/xattr.c +++ b/daemon/xattr.c @@ -52,7 +52,7 @@ do_getxattrs (const char *path) #if defined(HAVE_LISTXATTR) && defined(HAVE_GETXATTR) return getxattrs (path, listxattr, getxattr); #else - reply_with_error ("getxattrs: no support for listxattr and getxattr"); + reply_with_error ("no support for listxattr and getxattr"); return NULL; #endif } @@ -63,7 +63,7 @@ do_lgetxattrs (const char *path) #if defined(HAVE_LLISTXATTR) && defined(HAVE_LGETXATTR) return getxattrs (path, llistxattr, lgetxattr); #else - reply_with_error ("lgetxattrs: no support for llistxattr and lgetxattr"); + reply_with_error ("no support for llistxattr and lgetxattr"); return NULL; #endif } @@ -74,7 +74,7 @@ do_setxattr (const char *xattr, const char *val, int vallen, const char *path) #if defined(HAVE_SETXATTR) return _setxattr (xattr, val, vallen, path, setxattr); #else - reply_with_error ("setxattr: no support for setxattr"); + reply_with_error ("no support for setxattr"); return -1; #endif } @@ -85,7 +85,7 @@ do_lsetxattr (const char *xattr, const char *val, int vallen, const char *path) #if defined(HAVE_LSETXATTR) return _setxattr (xattr, val, vallen, path, lsetxattr); #else - reply_with_error ("lsetxattr: no support for lsetxattr"); + reply_with_error ("no support for lsetxattr"); return -1; #endif } @@ -96,7 +96,7 @@ do_removexattr (const char *xattr, const char *path) #if defined(HAVE_REMOVEXATTR) return _removexattr (xattr, path, removexattr); #else - reply_with_error ("removexattr: no support for removexattr"); + reply_with_error ("no support for removexattr"); return -1; #endif } @@ -107,7 +107,7 @@ do_lremovexattr (const char *xattr, const char *path) #if defined(HAVE_LREMOVEXATTR) return _removexattr (xattr, path, lremovexattr); #else - reply_with_error ("lremovexattr: no support for lremovexattr"); + reply_with_error ("no support for lremovexattr"); return -1; #endif } @@ -127,7 +127,7 @@ getxattrs (const char *path, len = listxattr (path, NULL, 0); CHROOT_OUT; if (len == -1) { - reply_with_perror ("listxattr"); + reply_with_perror ("listxattr: %s", path); goto error; } @@ -141,7 +141,7 @@ getxattrs (const char *path, len = listxattr (path, buf, len); CHROOT_OUT; if (len == -1) { - reply_with_perror ("listxattr"); + reply_with_perror ("listxattr: %s", path); goto error; } @@ -266,7 +266,7 @@ do_lxattrlist (const char *path, char *const *names) char *buf = NULL; if (path_len >= PATH_MAX) { - reply_with_perror ("lxattrlist: path longer than PATH_MAX"); + reply_with_perror ("path longer than PATH_MAX"); goto error; } @@ -288,7 +288,7 @@ do_lxattrlist (const char *path, char *const *names) * outgoing struct list. */ if (path_len + strlen (names[k]) + 2 > PATH_MAX) { - reply_with_perror ("lxattrlist: path and name longer than PATH_MAX"); + reply_with_perror ("path and name longer than PATH_MAX"); goto error; } pathname[path_len] = '/'; @@ -443,7 +443,7 @@ do_lxattrlist (const char *path, char *const *names) } return NULL; #else - reply_with_error ("lxattrlist: no support for llistxattr and lgetxattr"); + reply_with_error ("no support for llistxattr and lgetxattr"); return NULL; #endif } diff --git a/daemon/zerofree.c b/daemon/zerofree.c index 05a547b..84073dd 100644 --- a/daemon/zerofree.c +++ b/daemon/zerofree.c @@ -43,7 +43,7 @@ do_zerofree (const char *device) r = command (NULL, &err, "/usr/sbin/zerofree", device, NULL); if (r == -1) { - reply_with_error ("zerofree: %s: %s", device, err); + reply_with_error ("%s: %s", device, err); free (err); return -1; } diff --git a/src/generator.ml b/src/generator.ml index b0ffc58..3c9899b 100755 --- a/src/generator.ml +++ b/src/generator.ml @@ -5810,7 +5810,7 @@ and generate_daemon_actions () pr " memset (&args, 0, sizeof args);\n"; pr "\n"; pr " if (!xdr_guestfs_%s_args (xdr_in, &args)) {\n" name; - pr " reply_with_error (\"%%s: daemon failed to decode procedure arguments\", \"%s\");\n" name; + pr " reply_with_error (\"daemon failed to decode procedure arguments\");\n"; pr " return;\n"; pr " }\n"; let pr_args n -- 1.6.5.2
Apparently Analagous Threads
- [PATCH 0/13 v2] Prepare for adding write support to hivex (Windows registry) library
- [PATCH 0/2] Add readonly=on option to qemu -drive command line
- [PATCH 0/2] Implement guestfs_available API.
- [PATCH 0/7] Prepare for adding write support to hivex (windows registry) library
- [PATCH 0/4] Fix RHBZ#597112 (get-e2uuid command)