[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH 2/3] Use the getprogname gnulib module



Make use of the recently added 'getprogname' module in gnulib: replace
our guestfs_int_program_name with the getprogname() provided by the
module, since it does the same thing, and in a portable way.
As consequence of the above, use gnulib in a couple of tests that use
getprogname().

Since guestfs_int_program_name is gone, drop the configure checks
associated with it.
---
 align/scan.c                                  |  8 ++++--
 bootstrap                                     |  1 +
 builder/index-validate.c                      |  7 +++--
 cat/cat.c                                     | 10 ++++---
 cat/filesystems.c                             | 13 +++++----
 cat/log.c                                     | 22 +++++++-------
 cat/ls.c                                      |  9 +++---
 cat/visit.c                                   |  6 ++--
 df/main.c                                     |  8 ++++--
 df/parallel.c                                 |  3 +-
 diff/diff.c                                   | 15 +++++-----
 edit/edit.c                                   |  9 +++---
 fish/config.c                                 |  6 ++--
 fish/fish.c                                   | 41 ++++++++++++++-------------
 fish/inspect.c                                |  7 +++--
 fish/options.c                                | 10 ++++---
 fish/options.h                                |  6 ++--
 fish/uri.c                                    |  9 +++---
 format/format.c                               | 12 ++++----
 fuse/guestmount.c                             | 13 +++++----
 fuse/guestunmount.c                           | 13 +++++----
 fuse/test-guestmount-fd.c                     |  9 +++---
 generator/fish.ml                             |  5 ++--
 inspector/inspector.c                         | 12 ++++----
 m4/.gitignore                                 |  1 +
 m4/guestfs_libraries.m4                       |  4 ---
 make-fs/make-fs.c                             | 29 ++++++++++---------
 mllib/getopt-c.c                              | 11 +++----
 p2v/conversion.c                              |  3 +-
 p2v/gui.c                                     | 11 +++----
 p2v/kernel-cmdline.c                          |  4 ++-
 p2v/kernel.c                                  | 12 ++++----
 p2v/main.c                                    | 11 +++----
 p2v/ssh.c                                     |  9 +++---
 rescue/rescue.c                               | 13 +++++----
 src/guestfs-internal-frontend.h               | 11 -------
 src/handle.c                                  | 11 +++----
 tests/charsets/test-charset-fidelity.c        |  4 ++-
 tests/mount-local/test-parallel-mount-local.c |  5 ++--
 tests/parallel/test-parallel.c                |  5 ++--
 tests/regressions/Makefile.am                 |  8 ++++--
 tests/regressions/rhbz790721.c                |  4 ++-
 tests/regressions/rhbz914931.c                |  4 ++-
 utils/boot-analysis/boot-analysis.c           |  6 ++--
 utils/boot-benchmark/boot-benchmark.c         |  8 ++++--
 utils/qemu-boot/qemu-boot.c                   | 10 ++++---
 utils/qemu-speed-test/qemu-speed-test.c       | 20 +++++++------
 47 files changed, 252 insertions(+), 206 deletions(-)

diff --git a/align/scan.c b/align/scan.c
index 4171f8c..953ee91 100644
--- a/align/scan.c
+++ b/align/scan.c
@@ -38,6 +38,8 @@
 #include <libvirt/virterror.h>
 #endif
 
+#include "getprogname.h"
+
 #include "guestfs.h"
 #include "options.h"
 #include "display-options.h"
@@ -73,7 +75,7 @@ usage (int status)
 {
   if (status != EXIT_SUCCESS)
     fprintf (stderr, _("Try `%s --help' for more information.\n"),
-             guestfs_int_program_name);
+             getprogname ());
   else {
     printf (_("%s: check alignment of virtual machine partitions\n"
               "Copyright (C) 2011 Red Hat Inc.\n"
@@ -93,8 +95,8 @@ usage (int status)
               "  -V|--version         Display version and exit\n"
               "  -x                   Trace libguestfs API calls\n"
               "For more information, see the manpage %s(1).\n"),
-            guestfs_int_program_name, guestfs_int_program_name,
-            guestfs_int_program_name, guestfs_int_program_name);
+            getprogname (), getprogname (),
+            getprogname (), getprogname ());
   }
   exit (status);
 }
diff --git a/bootstrap b/bootstrap
index 5df6f0f..071682c 100755
--- a/bootstrap
+++ b/bootstrap
@@ -56,6 +56,7 @@ full-write
 futimens
 getaddrinfo
 getline
+getprogname
 gitlog-to-changelog
 glob
 gnu-make
diff --git a/builder/index-validate.c b/builder/index-validate.c
index 967c2d3..d3912f3 100644
--- a/builder/index-validate.c
+++ b/builder/index-validate.c
@@ -30,6 +30,7 @@
 
 #include <guestfs.h>
 
+#include "getprogname.h"
 #include "guestfs-internal-frontend.h"
 
 #include "index-struct.h"
@@ -40,7 +41,7 @@ extern int do_parse (struct parse_context *context, FILE *in);
 static void
 usage (int exit_status)
 {
-  printf ("%s index\n", guestfs_int_program_name);
+  printf ("%s index\n", getprogname ());
   exit (exit_status);
 }
 
@@ -90,7 +91,7 @@ main (int argc, char *argv[])
 
     case 'V':
       printf ("%s %s%s\n",
-              guestfs_int_program_name,
+              getprogname (),
               PACKAGE_VERSION, PACKAGE_VERSION_EXTRA);
       exit (EXIT_SUCCESS);
 
@@ -115,7 +116,7 @@ main (int argc, char *argv[])
 
   if (fclose (in) == EOF) {
     fprintf (stderr, _("%s: %s: error closing input file: %m (ignored)\n"),
-             guestfs_int_program_name, input);
+             getprogname (), input);
   }
 
   if (ret != 0) {
diff --git a/cat/cat.c b/cat/cat.c
index 9c8d1a9..1ac32d7 100644
--- a/cat/cat.c
+++ b/cat/cat.c
@@ -30,6 +30,8 @@
 #include <assert.h>
 #include <libintl.h>
 
+#include "getprogname.h"
+
 #include "guestfs.h"
 #include "options.h"
 #include "display-options.h"
@@ -53,7 +55,7 @@ usage (int status)
 {
   if (status != EXIT_SUCCESS)
     fprintf (stderr, _("Try `%s --help' for more information.\n"),
-             guestfs_int_program_name);
+             getprogname ());
   else {
     printf (_("%s: display files in a virtual machine\n"
               "Copyright (C) 2010 Red Hat Inc.\n"
@@ -74,8 +76,8 @@ usage (int status)
               "  -V|--version         Display version and exit\n"
               "  -x                   Trace libguestfs API calls\n"
               "For more information, see the manpage %s(1).\n"),
-            guestfs_int_program_name, guestfs_int_program_name,
-            guestfs_int_program_name, guestfs_int_program_name);
+            getprogname (), getprogname (),
+            getprogname (), getprogname ());
   }
   exit (status);
 }
@@ -227,7 +229,7 @@ main (int argc, char *argv[])
   /* User must have specified some drives. */
   if (drvs == NULL) {
     fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"),
-             guestfs_int_program_name);
+             getprogname ());
     usage (EXIT_FAILURE);
   }
 
diff --git a/cat/filesystems.c b/cat/filesystems.c
index 6c8ce01..73967d7 100644
--- a/cat/filesystems.c
+++ b/cat/filesystems.c
@@ -33,6 +33,7 @@
 
 #include "c-ctype.h"
 #include "human.h"
+#include "getprogname.h"
 
 #include "guestfs.h"
 #include "options.h"
@@ -87,7 +88,7 @@ usage (int status)
 {
   if (status != EXIT_SUCCESS)
     fprintf (stderr, _("Try `%s --help' for more information.\n"),
-             guestfs_int_program_name);
+             getprogname ());
   else {
     printf (_("%s: list filesystems, partitions, block devices, LVM in a VM\n"
               "Copyright (C) 2010 Red Hat Inc.\n"
@@ -123,8 +124,8 @@ usage (int status)
               "                       Display LVM volume groups\n"
               "  -x                   Trace libguestfs API calls\n"
               "For more information, see the manpage %s(1).\n"),
-            guestfs_int_program_name, guestfs_int_program_name,
-            guestfs_int_program_name, guestfs_int_program_name);
+            getprogname (), getprogname (),
+            getprogname (), getprogname ());
   }
   exit (status);
 }
@@ -296,7 +297,7 @@ main (int argc, char *argv[])
     fprintf (stderr, _("%s: error: extra argument '%s' on command line.\n"
              "Make sure to specify the argument for --format "
              "like '--format=%s'.\n"),
-             guestfs_int_program_name, argv[optind], argv[optind]);
+             getprogname (), argv[optind], argv[optind]);
     usage (EXIT_FAILURE);
   }
 
@@ -337,7 +338,7 @@ main (int argc, char *argv[])
   /* User must have specified some drives. */
   if (drvs == NULL) {
     fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"),
-             guestfs_int_program_name);
+             getprogname ());
     usage (EXIT_FAILURE);
   }
 
@@ -486,7 +487,7 @@ do_output_filesystems (void)
       if (subvolume == NULL && guestfs_last_errno (g) != EINVAL) {
         fprintf (stderr,
                  _("%s: cannot determine the subvolume for %s: %s: %s\n"),
-                guestfs_int_program_name, fses[i],
+                getprogname (), fses[i],
                 guestfs_last_error (g),
                 strerror (guestfs_last_errno (g)));
         exit (EXIT_FAILURE);
diff --git a/cat/log.c b/cat/log.c
index 0968ef5..f8f5a4b 100644
--- a/cat/log.c
+++ b/cat/log.c
@@ -35,6 +35,8 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 
+#include "getprogname.h"
+
 #include "guestfs.h"
 #include "options.h"
 #include "display-options.h"
@@ -62,7 +64,7 @@ usage (int status)
 {
   if (status != EXIT_SUCCESS)
     fprintf (stderr, _("Try `%s --help' for more information.\n"),
-             guestfs_int_program_name);
+             getprogname ());
   else {
     printf (_("%s: display log files in a virtual machine\n"
               "Copyright (C) 2010-2016 Red Hat Inc.\n"
@@ -81,8 +83,8 @@ usage (int status)
               "  -V|--version         Display version and exit\n"
               "  -x                   Trace libguestfs API calls\n"
               "For more information, see the manpage %s(1).\n"),
-            guestfs_int_program_name, guestfs_int_program_name,
-            guestfs_int_program_name, guestfs_int_program_name);
+            getprogname (), getprogname (),
+            getprogname (), getprogname ());
   }
   exit (status);
 }
@@ -189,7 +191,7 @@ main (int argc, char *argv[])
     fprintf (stderr, _("%s: error: extra argument '%s' on command line.\n"
              "Make sure to specify the argument for --format "
              "like '--format=%s'.\n"),
-             guestfs_int_program_name, argv[optind], argv[optind]);
+             getprogname (), argv[optind], argv[optind]);
     usage (EXIT_FAILURE);
   }
 
@@ -198,7 +200,7 @@ main (int argc, char *argv[])
   /* User must have specified some drives. */
   if (drvs == NULL) {
     fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"),
-             guestfs_int_program_name);
+             getprogname ());
     usage (EXIT_FAILURE);
   }
 
@@ -250,7 +252,7 @@ do_log (void)
 
     fprintf (stderr,
              _("%s: Windows Event Log for pre-Vista guests is not supported.\n"),
-             guestfs_int_program_name);
+             getprogname ());
     return -1;
   }
 
@@ -358,7 +360,7 @@ do_log_journal (void)
       if (strftime (buf, sizeof buf, "%b %d %H:%M:%S",
                     localtime_r (&t, &tm)) <= 0) {
         fprintf (stderr, _("%s: could not format journal entry timestamp\n"),
-                 guestfs_int_program_name);
+                 getprogname ());
         errors++;
         continue;
       }
@@ -427,7 +429,7 @@ do_log_windows_evtx (void)
                        "in order to parse Windows Event Logs.  If you cannot install this, then\n"
                        "use virt-copy-out(1) to copy the contents of /Windows/System32/winevt/Logs\n"
                        "from this guest, and examine in a binary file viewer.\n"),
-             guestfs_int_program_name);
+             getprogname ());
     return -1;
   }
 
@@ -443,7 +445,7 @@ do_log_windows_evtx (void)
                             GUESTFS_IS_FILE_OPTS_FOLLOWSYMLINKS, 1,
                             -1) <= 0) {
     fprintf (stderr, _("%s: Windows Event Log file (%s) not found\n"),
-             guestfs_int_program_name, filename);
+             getprogname (), filename);
     return -1;
   }
 
@@ -475,7 +477,7 @@ do_log_windows_evtx (void)
   if (status) {
     char buf[256];
     fprintf (stderr, "%s: %s\n",
-             guestfs_int_program_name,
+             getprogname (),
              guestfs_int_exit_status_to_string (status, "evtxdump.py",
                                                 buf, sizeof buf));
     return -1;
diff --git a/cat/ls.c b/cat/ls.c
index 53bc6fc..2e327d9 100644
--- a/cat/ls.c
+++ b/cat/ls.c
@@ -34,6 +34,7 @@
 #include <sys/sysmacros.h>
 
 #include "human.h"
+#include "getprogname.h"
 
 #include "guestfs.h"
 
@@ -84,7 +85,7 @@ usage (int status)
 {
   if (status != EXIT_SUCCESS)
     fprintf (stderr, _("Try `%s --help' for more information.\n"),
-             guestfs_int_program_name);
+             getprogname ());
   else {
     printf (_("%s: list files in a virtual machine\n"
               "Copyright (C) 2010-2012 Red Hat Inc.\n"
@@ -116,8 +117,8 @@ usage (int status)
               "  -V|--version         Display version and exit\n"
               "  -x                   Trace libguestfs API calls\n"
               "For more information, see the manpage %s(1).\n"),
-            guestfs_int_program_name, guestfs_int_program_name,
-            guestfs_int_program_name, guestfs_int_program_name);
+            getprogname (), getprogname (),
+            getprogname (), getprogname ());
   }
   exit (status);
 }
@@ -344,7 +345,7 @@ main (int argc, char *argv[])
   /* User must have specified some drives. */
   if (drvs == NULL) {
     fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"),
-             guestfs_int_program_name);
+             getprogname ());
     usage (EXIT_FAILURE);
   }
 
diff --git a/cat/visit.c b/cat/visit.c
index 6a6cb1e..f29235c 100644
--- a/cat/visit.c
+++ b/cat/visit.c
@@ -33,6 +33,8 @@
 #include <assert.h>
 #include <libintl.h>
 
+#include "getprogname.h"
+
 #include "guestfs.h"
 #include "guestfs-internal-frontend.h"
 
@@ -128,7 +130,7 @@ _visit (guestfs_h *g, int depth, const char *dir,
 
     if (xattrs->val[xattrp].attrval_len == 0) {
       fprintf (stderr, _("%s: error getting extended attrs for %s %s\n"),
-               guestfs_int_program_name, dir, names[i]);
+               getprogname (), dir, names[i]);
       return -1;
     }
     /* attrval is not \0-terminated. */
@@ -142,7 +144,7 @@ _visit (guestfs_h *g, int depth, const char *dir,
     attrval[xattrs->val[xattrp].attrval_len] = '\0';
     if (sscanf (attrval, "%zu", &nr_xattrs) != 1) {
       fprintf (stderr, _("%s: error: cannot parse xattr count for %s %s\n"),
-               guestfs_int_program_name, dir, names[i]);
+               getprogname (), dir, names[i]);
       return -1;
     }
 
diff --git a/df/main.c b/df/main.c
index 3f9296f..b4fe0e0 100644
--- a/df/main.c
+++ b/df/main.c
@@ -36,6 +36,8 @@
 #include <libvirt/virterror.h>
 #endif
 
+#include "getprogname.h"
+
 #include "guestfs.h"
 #include "options.h"
 #include "display-options.h"
@@ -66,7 +68,7 @@ usage (int status)
 {
   if (status != EXIT_SUCCESS)
     fprintf (stderr, _("Try `%s --help' for more information.\n"),
-             guestfs_int_program_name);
+             getprogname ());
   else {
     printf (_("%s: display free space on virtual filesystems\n"
               "Copyright (C) 2010 Red Hat Inc.\n"
@@ -89,8 +91,8 @@ usage (int status)
               "  -V|--version         Display version and exit\n"
               "  -x                   Trace libguestfs API calls\n"
               "For more information, see the manpage %s(1).\n"),
-            guestfs_int_program_name, guestfs_int_program_name,
-            guestfs_int_program_name, guestfs_int_program_name);
+            getprogname (), getprogname (),
+            getprogname (), getprogname ());
   }
   exit (status);
 }
diff --git a/df/parallel.c b/df/parallel.c
index d8aa375..97b9a3a 100644
--- a/df/parallel.c
+++ b/df/parallel.c
@@ -44,6 +44,7 @@
 #endif
 
 #include "ignore-value.h"
+#include "getprogname.h"
 
 #include "guestfs.h"
 #include "guestfs-internal-frontend.h"
@@ -298,7 +299,7 @@ static void
 thread_failure (const char *fn, int err)
 {
   fprintf (stderr, "%s: %s: %s\n",
-           guestfs_int_program_name, fn, strerror (err));
+           getprogname (), fn, strerror (err));
 }
 
 #endif /* HAVE_LIBVIRT */
diff --git a/diff/diff.c b/diff/diff.c
index 9ec515d..2087857 100644
--- a/diff/diff.c
+++ b/diff/diff.c
@@ -36,6 +36,7 @@
 
 #include "c-ctype.h"
 #include "human.h"
+#include "getprogname.h"
 
 #include "guestfs.h"
 
@@ -93,7 +94,7 @@ usage (int status)
 {
   if (status != EXIT_SUCCESS)
     fprintf (stderr, _("Try `%s --help' for more information.\n"),
-             guestfs_int_program_name);
+             getprogname ());
   else {
     printf (_("%s: list differences between virtual machines\n"
               "Copyright (C) 2010-2016 Red Hat Inc.\n"
@@ -128,8 +129,8 @@ usage (int status)
               "  -x                   Trace libguestfs API calls\n"
               "  --xattrs             Display extended attributes\n"
               "For more information, see the manpage %s(1).\n"),
-            guestfs_int_program_name, guestfs_int_program_name,
-            guestfs_int_program_name, guestfs_int_program_name);
+            getprogname (), getprogname (),
+            getprogname (), getprogname ());
   }
   exit (status);
 }
@@ -316,12 +317,12 @@ main (int argc, char *argv[])
 
   if (drvs == NULL) {
     fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"),
-             guestfs_int_program_name);
+             getprogname ());
     usage (EXIT_FAILURE);
   }
   if (drvs2 == NULL) {
     fprintf (stderr, _("%s: error: you must specify at least one -A or -D option.\n"),
-             guestfs_int_program_name);
+             getprogname ());
     usage (EXIT_FAILURE);
   }
 
@@ -335,7 +336,7 @@ main (int argc, char *argv[])
     fprintf (stderr, _("%s: error: extra argument '%s' on command line.\n"
              "Make sure to specify the argument for --checksum or --format "
              "like '--format=%s'.\n"),
-             guestfs_int_program_name, argv[optind], argv[optind]);
+             getprogname (), argv[optind], argv[optind]);
     usage (EXIT_FAILURE);
   }
 
@@ -734,7 +735,7 @@ diff (struct file *file1, guestfs_h *g1, struct file *file2, guestfs_h *g2)
     fprintf (stderr, "%s\n", cmd);
   r = system (cmd);
   if (!WIFEXITED (r) || WEXITSTATUS (r) != 0) {
-    fprintf (stderr, _("%s: external diff command failed\n"), guestfs_int_program_name);
+    fprintf (stderr, _("%s: external diff command failed\n"), getprogname ());
     goto out;
   }
 
diff --git a/edit/edit.c b/edit/edit.c
index 6f3e388..06f7f28 100644
--- a/edit/edit.c
+++ b/edit/edit.c
@@ -34,6 +34,7 @@
 #include <utime.h>
 
 #include "xvasprintf.h"
+#include "getprogname.h"
 
 #include "guestfs.h"
 #include "options.h"
@@ -63,7 +64,7 @@ usage (int status)
 {
   if (status != EXIT_SUCCESS)
     fprintf (stderr, _("Try `%s --help' for more information.\n"),
-             guestfs_int_program_name);
+             getprogname ());
   else {
     printf (_("%s: Edit a file in a virtual machine\n"
               "Copyright (C) 2009-2016 Red Hat Inc.\n"
@@ -86,8 +87,8 @@ usage (int status)
               "  -V|--version          Display version and exit\n"
               "  -x                    Trace libguestfs API calls\n"
               "For more information, see the manpage %s(1).\n"),
-            guestfs_int_program_name, guestfs_int_program_name,
-            guestfs_int_program_name, guestfs_int_program_name);
+            getprogname (), getprogname (),
+            getprogname (), getprogname ());
   }
   exit (status);
 }
@@ -256,7 +257,7 @@ main (int argc, char *argv[])
   /* User must have specified some drives. */
   if (drvs == NULL) {
     fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"),
-             guestfs_int_program_name);
+             getprogname ());
     usage (EXIT_FAILURE);
   }
 
diff --git a/fish/config.c b/fish/config.c
index 8f10ad4..dd9f6ec 100644
--- a/fish/config.c
+++ b/fish/config.c
@@ -38,6 +38,8 @@
 #include <libconfig.h>
 #endif
 
+#include "getprogname.h"
+
 #include "guestfs.h"
 
 #include "options.h"
@@ -62,7 +64,7 @@ read_config_from_file (const char *filename)
     /*
     if (verbose)
       fprintf (stderr, "%s: reading configuration from %s\n",
-               guestfs_int_program_name, filename);
+               getprogname (), filename);
     */
 
     if (config_read (&conf, fp) == CONFIG_FALSE)
@@ -155,7 +157,7 @@ parse_config (void)
   if (verbose)
     fprintf (stderr,
              _("%s: compiled without libconfig, guestfish configuration file ignored\n"),
-             guestfs_int_program_name);
+             getprogname ());
   */
 }
 
diff --git a/fish/fish.c b/fish/fish.c
index f20fbc0..1f6f043 100644
--- a/fish/fish.c
+++ b/fish/fish.c
@@ -54,6 +54,7 @@
 #include "c-ctype.h"
 #include "closeout.h"
 #include "ignore-value.h"
+#include "getprogname.h"
 
 /* Return from parse_command_line.  See description below. */
 struct parsed_command {
@@ -110,7 +111,7 @@ usage (int status)
 {
   if (status != EXIT_SUCCESS)
     fprintf (stderr, _("Try `%s --help' for more information.\n"),
-             guestfs_int_program_name);
+             getprogname ());
   else {
     printf (_("%s: guest filesystem shell\n"
               "%s lets you edit virtual machine filesystems\n"
@@ -159,10 +160,10 @@ usage (int status)
               "run again without -i and use 'run' + 'list-filesystems' + 'mount' cmds.\n"
               "\n"
               "For more information, see the manpage %s(1).\n"),
-            guestfs_int_program_name, guestfs_int_program_name,
-            guestfs_int_program_name, guestfs_int_program_name,
-            guestfs_int_program_name, guestfs_int_program_name,
-            guestfs_int_program_name);
+            getprogname (), getprogname (),
+            getprogname (), getprogname (),
+            getprogname (), getprogname (),
+            getprogname ());
   }
   exit (status);
 }
@@ -311,7 +312,7 @@ main (int argc, char *argv[])
 
     case 'D':
       fprintf (stderr, _("%s: warning: -D option is deprecated, use --no-dest-paths instead\n"),
-               guestfs_int_program_name);
+               getprogname ());
       complete_dest_paths = 0;
       break;
 
@@ -854,7 +855,7 @@ parse_command_line (char *buf, int *exit_on_error_rtn)
       if (p[len+1] && (p[len+1] != ' ' && p[len+1] != '\t')) {
         fprintf (stderr,
                  _("%s: command arguments not separated by whitespace\n"),
-                 guestfs_int_program_name);
+                 getprogname ());
         pcmd.status = -1;
         return pcmd;
       }
@@ -863,14 +864,14 @@ parse_command_line (char *buf, int *exit_on_error_rtn)
       p++;
       len = strcspn (p, "'");
       if (p[len] == '\0') {
-        fprintf (stderr, _("%s: unterminated single quote\n"), guestfs_int_program_name);
+        fprintf (stderr, _("%s: unterminated single quote\n"), getprogname ());
         pcmd.status = -1;
         return pcmd;
       }
       if (p[len+1] && (p[len+1] != ' ' && p[len+1] != '\t')) {
         fprintf (stderr,
                  _("%s: command arguments not separated by whitespace\n"),
-                 guestfs_int_program_name);
+                 getprogname ());
         pcmd.status = -1;
         return pcmd;
       }
@@ -894,7 +895,7 @@ parse_command_line (char *buf, int *exit_on_error_rtn)
         pend = &p[len];
     } else {
       fprintf (stderr, _("%s: internal error parsing string at '%s'\n"),
-               guestfs_int_program_name, p);
+               getprogname (), p);
       abort ();
     }
 
@@ -910,7 +911,7 @@ parse_command_line (char *buf, int *exit_on_error_rtn)
   }
 
   if (i == argv_len) {
-    fprintf (stderr, _("%s: too many arguments\n"), guestfs_int_program_name);
+    fprintf (stderr, _("%s: too many arguments\n"), getprogname ());
     pcmd.status = -1;
     return pcmd;
   }
@@ -987,7 +988,7 @@ parse_quoted_string (char *p)
       default:
       error:
         fprintf (stderr, _("%s: invalid escape sequence in string (starting at offset %d)\n"),
-                 guestfs_int_program_name, (int) (p - start));
+                 getprogname (), (int) (p - start));
         return -1;
       }
       memmove (p+1, p+1+m, strlen (p+1+m) + 1);
@@ -995,7 +996,7 @@ parse_quoted_string (char *p)
   }
 
   if (!*p) {
-    fprintf (stderr, _("%s: unterminated double quote\n"), guestfs_int_program_name);
+    fprintf (stderr, _("%s: unterminated double quote\n"), getprogname ());
     return -1;
   }
 
@@ -1190,7 +1191,7 @@ issue_command (const char *cmd, char *argv[], const char *pipecmd,
   }
   if (ferror (stdout)) {
     if (!pipecmd || pipe_error) {
-      fprintf (stderr, "%s: write error%s\n", guestfs_int_program_name,
+      fprintf (stderr, "%s: write error%s\n", getprogname (),
                pipecmd ? " on pipe" : "");
       r = -1;
     }
@@ -1736,13 +1737,13 @@ win_prefix_drive_letter (char drive_letter, const char *path)
     return NULL;
   if (roots[0] == NULL) {
     fprintf (stderr, _("%s: to use Windows drive letters, you must inspect the guest (\"-i\" option or run \"inspect-os\" command)\n"),
-             guestfs_int_program_name);
+             getprogname ());
     return NULL;
   }
   drives = guestfs_inspect_get_drive_mappings (g, roots[0]);
   if (drives == NULL || drives[0] == NULL) {
     fprintf (stderr, _("%s: to use Windows drive letters, this must be a Windows guest\n"),
-             guestfs_int_program_name);
+             getprogname ());
     return NULL;
   }
 
@@ -1756,7 +1757,7 @@ win_prefix_drive_letter (char drive_letter, const char *path)
 
   if (device == NULL) {
     fprintf (stderr, _("%s: drive '%c:' not found.  To list available drives do:\n  inspect-get-drive-mappings %s\n"),
-             guestfs_int_program_name, drive_letter, roots[0]);
+             getprogname (), drive_letter, roots[0]);
     return NULL;
   }
 
@@ -1775,7 +1776,7 @@ win_prefix_drive_letter (char drive_letter, const char *path)
 
   if (mountpoint == NULL) {
     fprintf (stderr, _("%s: to access '%c:', mount %s first.  One way to do this is:\n  umount-all\n  mount %s /\n"),
-             guestfs_int_program_name, drive_letter, device, device);
+             getprogname (), drive_letter, device, device);
     return NULL;
   }
 
@@ -1814,7 +1815,7 @@ file_in (const char *arg)
     const char *endmarker = &arg[3];
     if (*endmarker == '\0') {
       fprintf (stderr, "%s: missing end marker in -<< expression\n",
-               guestfs_int_program_name);
+               getprogname ());
       return NULL;
     }
     ret = file_in_heredoc (endmarker);
@@ -1885,7 +1886,7 @@ file_in_heredoc (const char *endmarker)
    * is likely to be an error.
    */
   fprintf (stderr, "%s: end of input reached without finding '%s'\n",
-           guestfs_int_program_name, endmarker);
+           getprogname (), endmarker);
   goto error2;
 
  found_end:
diff --git a/fish/inspect.c b/fish/inspect.c
index c20d891..952d4f7 100644
--- a/fish/inspect.c
+++ b/fish/inspect.c
@@ -33,6 +33,7 @@
 #include <libintl.h>
 
 #include "c-ctype.h"
+#include "getprogname.h"
 
 #include "guestfs.h"
 
@@ -93,7 +94,7 @@ inspect_mount_handle (guestfs_h *g)
 	       "If using other virt tools, this disk image won't work\n"
 	       "with these tools.  Use the guestfish equivalent commands\n"
 	       "(see the virt tool manual page).\n"),
-             guestfs_int_program_name);
+             getprogname ());
     guestfs_int_free_string_list (roots);
     exit (EXIT_FAILURE);
   }
@@ -114,7 +115,7 @@ inspect_mount_handle (guestfs_h *g)
 	       "If using other virt tools, multi-boot operating systems won't work\n"
 	       "with these tools.  Use the guestfish equivalent commands\n"
 	       "(see the virt tool manual page).\n"),
-             guestfs_int_program_name);
+             getprogname ());
     guestfs_int_free_string_list (roots);
     exit (EXIT_FAILURE);
   }
@@ -163,7 +164,7 @@ inspect_mount_root (guestfs_h *g, const char *root)
 
   if (mount_errors)
     fprintf (stderr, _("%s: some filesystems could not be mounted (ignored)\n"),
-             guestfs_int_program_name);
+             getprogname ());
 }
 
 /**
diff --git a/fish/options.c b/fish/options.c
index 96db212..b88c194 100644
--- a/fish/options.c
+++ b/fish/options.c
@@ -39,6 +39,8 @@
 #include <error.h>
 #include <libintl.h>
 
+#include "getprogname.h"
+
 #include "guestfs.h"
 #include "options.h"
 #include "uri.h"
@@ -276,15 +278,15 @@ display_mountpoints_on_failure (const char *mp_device,
     return;
 
   fprintf (stderr, _("%s: '%s' could not be mounted.\n"),
-           guestfs_int_program_name, mp_device);
+           getprogname (), mp_device);
 
   if (user_supplied_options)
     fprintf (stderr, _("%s: Check mount(8) man page to ensure options '%s'\n"
                        "%s: are supported by the filesystem that is being mounted.\n"),
-             guestfs_int_program_name, user_supplied_options, guestfs_int_program_name);
+             getprogname (), user_supplied_options, getprogname ());
 
   fprintf (stderr, _("%s: Did you mean to mount one of these filesystems?\n"),
-           guestfs_int_program_name);
+           getprogname ());
 
   for (i = 0; fses[i] != NULL; i += 2) {
     CLEANUP_FREE char *p = NULL;
@@ -309,7 +311,7 @@ display_mountpoints_on_failure (const char *mp_device,
       p = guestfs_canonical_device_name (g, fses[i]);
     }
 
-    fprintf (stderr, "%s: \t%s (%s)\n", guestfs_int_program_name,
+    fprintf (stderr, "%s: \t%s (%s)\n", getprogname (),
              p ? p : fses[i], fses[i+1]);
   }
 }
diff --git a/fish/options.h b/fish/options.h
index 89afe9e..061b41f 100644
--- a/fish/options.h
+++ b/fish/options.h
@@ -215,7 +215,7 @@ extern void free_mps (struct mp *mp);
 #define OPTION_V                                                        \
   {                                                                     \
     printf ("%s %s\n",                                                  \
-            guestfs_int_program_name,                                   \
+            getprogname (),                                             \
             PACKAGE_VERSION_FULL);                                      \
     exit (EXIT_SUCCESS);                                                \
   }
@@ -223,7 +223,7 @@ extern void free_mps (struct mp *mp);
 #define OPTION_w                                                        \
   if (read_only) {                                                      \
     fprintf (stderr, _("%s: cannot mix --ro and --rw options\n"),       \
-             guestfs_int_program_name);                                 \
+             getprogname ());                                           \
     exit (EXIT_FAILURE);                                                \
   }
 
@@ -235,7 +235,7 @@ extern void free_mps (struct mp *mp);
     if (!format_consumed) {                                             \
       fprintf (stderr,                                                  \
                _("%s: --format parameter must appear before -a parameter\n"), \
-               guestfs_int_program_name);                               \
+               getprogname ());                                         \
       exit (EXIT_FAILURE);                                              \
     }                                                                   \
   } while (0)
diff --git a/fish/uri.c b/fish/uri.c
index fc955a5..ae30bce 100644
--- a/fish/uri.c
+++ b/fish/uri.c
@@ -34,6 +34,7 @@
 #include <libxml/uri.h>
 
 #include "c-ctype.h"
+#include "getprogname.h"
 
 #include "guestfs.h"
 #include "guestfs-internal-frontend.h"
@@ -116,7 +117,7 @@ parse (const char *arg, char **path_ret, char **protocol_ret,
   uri = xmlParseURI (arg);
   if (!uri) {
     fprintf (stderr, _("%s: --add: could not parse URI '%s'\n"),
-             guestfs_int_program_name, arg);
+             getprogname (), arg);
     return -1;
   }
 
@@ -127,7 +128,7 @@ parse (const char *arg, char **path_ret, char **protocol_ret,
   if (uri->scheme == NULL || STREQ (uri->scheme, "")) {
     /* Probably can never happen. */
     fprintf (stderr, _("%s: %s: scheme of URI is NULL or empty\n"),
-             guestfs_int_program_name, arg);
+             getprogname (), arg);
     return -1;
   }
 
@@ -135,14 +136,14 @@ parse (const char *arg, char **path_ret, char **protocol_ret,
 
   if (uri->server && STRNEQ (uri->server, "") && socket) {
     fprintf (stderr, _("%s: %s: cannot both a server name and a socket query parameter\n"),
-             guestfs_int_program_name, arg);
+             getprogname (), arg);
     return -1;
   }
 
   /* Is this needed? XXX
   if (socket && socket[0] != '/') {
     fprintf (stderr, _("%s: --add %s: socket query parameter must be an absolute path\n"),
-             guestfs_int_program_name, arg);
+             getprogname (), arg);
     return -1;
   }
   */
diff --git a/format/format.c b/format/format.c
index 0ce4ac4..e70f32d 100644
--- a/format/format.c
+++ b/format/format.c
@@ -31,6 +31,8 @@
 #include <assert.h>
 #include <libintl.h>
 
+#include "getprogname.h"
+
 #include "guestfs.h"
 #include "options.h"
 #include "display-options.h"
@@ -65,7 +67,7 @@ usage (int status)
 
   if (status != EXIT_SUCCESS)
     fprintf (stderr, _("Try `%s --help' for more information.\n%s\n"),
-             guestfs_int_program_name, warning);
+             getprogname (), warning);
   else {
     printf (_("%s: erase and make a blank disk\n"
               "Copyright (C) 2012 Red Hat Inc.\n"
@@ -89,8 +91,8 @@ usage (int status)
               "For more information, see the manpage %s(1).\n"
               "\n"
               "%s\n\n"),
-            guestfs_int_program_name, warning,
-            guestfs_int_program_name, guestfs_int_program_name,
+            getprogname (), warning,
+            getprogname (), getprogname (),
             warning);
   }
   exit (status);
@@ -224,7 +226,7 @@ main (int argc, char *argv[])
     fprintf (stderr, _("%s: error: extra argument '%s' on command line.\n"
              "Make sure to specify the argument for --format, --lvm "
              "or --partition like '--format=%s'.\n"),
-             guestfs_int_program_name, argv[optind], argv[optind]);
+             getprogname (), argv[optind], argv[optind]);
     usage (EXIT_FAILURE);
   }
 
@@ -233,7 +235,7 @@ main (int argc, char *argv[])
   /* The user didn't specify any drives to format. */
   if (drvs == NULL) {
     fprintf (stderr, _("%s: error: you must specify at least one -a option.\n"),
-             guestfs_int_program_name);
+             getprogname ());
     usage (EXIT_FAILURE);
   }
 
diff --git a/fuse/guestmount.c b/fuse/guestmount.c
index 9da96d2..c5ca3b6 100644
--- a/fuse/guestmount.c
+++ b/fuse/guestmount.c
@@ -39,6 +39,7 @@
 #include "guestfs.h"
 
 #include "ignore-value.h"
+#include "getprogname.h"
 
 #include "options.h"
 #include "display-options.h"
@@ -88,7 +89,7 @@ static void __attribute__((noreturn))
 fuse_help (void)
 {
   static struct fuse_operations null_operations;
-  const char *tmp_argv[] = { guestfs_int_program_name, "--help", NULL };
+  const char *tmp_argv[] = { getprogname (), "--help", NULL };
   fuse_main (2, (char **) tmp_argv, &null_operations, NULL);
   exit (EXIT_SUCCESS);
 }
@@ -98,7 +99,7 @@ usage (int status)
 {
   if (status != EXIT_SUCCESS)
     fprintf (stderr, _("Try `%s --help' for more information.\n"),
-             guestfs_int_program_name);
+             getprogname ());
   else {
     printf (_("%s: FUSE module for libguestfs\n"
               "%s lets you mount a virtual machine filesystem\n"
@@ -130,8 +131,8 @@ usage (int status)
               "  -w|--rw              Mount read-write\n"
               "  -x|--trace           Trace guestfs API calls\n"
               ),
-            guestfs_int_program_name, guestfs_int_program_name,
-            guestfs_int_program_name);
+            getprogname (), getprogname (),
+            getprogname ());
   }
   exit (status);
 }
@@ -313,12 +314,12 @@ main (int argc, char *argv[])
   if (!live) {
     if (drvs == NULL) {
       fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"),
-               guestfs_int_program_name);
+               getprogname ());
       usage (EXIT_FAILURE);
     }
     if (!(mps || inspector)) {
       fprintf (stderr, _("%s: error: you must specify either -i at least one -m option.\n"),
-               guestfs_int_program_name);
+               getprogname ());
       usage (EXIT_FAILURE);
     }
   } else {
diff --git a/fuse/guestunmount.c b/fuse/guestunmount.c
index fe86706..dde691a 100644
--- a/fuse/guestunmount.c
+++ b/fuse/guestunmount.c
@@ -38,6 +38,7 @@
 #include "guestfs-internal-frontend.h"
 
 #include "ignore-value.h"
+#include "getprogname.h"
 
 #include "display-options.h"
 
@@ -53,7 +54,7 @@ usage (int status)
 {
   if (status != EXIT_SUCCESS)
     fprintf (stderr, _("Try `%s --help' for more information.\n"),
-             guestfs_int_program_name);
+             getprogname ());
   else {
     printf (_("%s: clean up a mounted filesystem\n"
               "Copyright (C) 2013 Red Hat Inc.\n"
@@ -68,7 +69,7 @@ usage (int status)
               "  -v|--verbose         Verbose messages\n"
               "  -V|--version         Display version and exit\n"
               ),
-            guestfs_int_program_name, guestfs_int_program_name);
+            getprogname (), getprogname ());
   }
   exit (status);
 }
@@ -204,7 +205,7 @@ main (int argc, char *argv[])
   /* fusermount failed after N retries */
   if (!quiet) {
     fprintf (stderr, _("%s: failed to unmount %s: %s\n"),
-             guestfs_int_program_name, mountpoint, error_str);
+             getprogname (), mountpoint, error_str);
     do_fuser (mountpoint);
   }
   free (error_str);
@@ -215,7 +216,7 @@ main (int argc, char *argv[])
  not_mounted:
   if (!quiet)
     fprintf (stderr, _("%s: %s is not mounted: %s\n"),
-             guestfs_int_program_name, mountpoint, error_str);
+             getprogname (), mountpoint, error_str);
 
   free (error_str);
 
@@ -240,7 +241,7 @@ do_fusermount (const char *mountpoint, char **error_rtn)
 
   if (verbose)
     fprintf (stderr, "%s: running: fusermount -u %s\n",
-             guestfs_int_program_name, mountpoint);
+             getprogname (), mountpoint);
 
   pid = fork ();
   if (pid == -1)
@@ -315,7 +316,7 @@ do_fusermount (const char *mountpoint, char **error_rtn)
 
   if (verbose)
     fprintf (stderr, "%s: fusermount successful\n",
-             guestfs_int_program_name);
+             getprogname ());
 
   free (buf);
   return 0;                     /* fusermount successful */
diff --git a/fuse/test-guestmount-fd.c b/fuse/test-guestmount-fd.c
index 9f302b4..abef7b2 100644
--- a/fuse/test-guestmount-fd.c
+++ b/fuse/test-guestmount-fd.c
@@ -30,6 +30,7 @@
 #include <sys/wait.h>
 
 #include "ignore-value.h"
+#include "getprogname.h"
 
 #include "guestfs.h"
 #include "guestfs-internal-frontend.h"
@@ -109,7 +110,7 @@ main (int argc, char *argv[])
   }
   if (r == 0) {
     fprintf (stderr, "%s: unexpected end of file on pipe fd.\n",
-             guestfs_int_program_name);
+             getprogname ());
     ignore_value (rmdir (MOUNTPOINT));
     exit (EXIT_FAILURE);
   }
@@ -117,7 +118,7 @@ main (int argc, char *argv[])
   /* Check that the test image was mounted. */
   if (access (TEST_FILE, R_OK) == -1) {
     fprintf (stderr, "%s: test failed because test image is not mounted and ready.",
-             guestfs_int_program_name);
+             getprogname ());
     ignore_value (rmdir (MOUNTPOINT));
     exit (EXIT_FAILURE);
   }
@@ -127,7 +128,7 @@ main (int argc, char *argv[])
   if (r != 0) {
     char status_string[80];
 
-    fprintf (stderr, "%s: test failed: %s\n", guestfs_int_program_name,
+    fprintf (stderr, "%s: test failed: %s\n", getprogname (),
              guestfs_int_exit_status_to_string (r, GUESTUNMOUNT_BINARY,
 						status_string,
 						sizeof status_string));
@@ -148,7 +149,7 @@ main (int argc, char *argv[])
     char status_string[80];
 
     fprintf (stderr, "%s: test failed: %s\n",
-             guestfs_int_program_name,
+             getprogname (),
              guestfs_int_exit_status_to_string (status, GUESTMOUNT_BINARY,
 						status_string,
 						sizeof status_string));
diff --git a/generator/fish.ml b/generator/fish.ml
index b16326b..62752e8 100644
--- a/generator/fish.ml
+++ b/generator/fish.ml
@@ -94,6 +94,7 @@ let generate_fish_run_cmds actions () =
   pr "\n";
   pr "#include \"full-write.h\"\n";
   pr "#include \"xstrtol.h\"\n";
+  pr "#include \"getprogname.h\"\n";
   pr "\n";
   pr "#include \"guestfs.h\"\n";
   pr "#include \"guestfs-internal-frontend.h\"\n";
@@ -287,7 +288,7 @@ let generate_fish_run_cmds actions () =
             pr "    case -1:\n";
             pr "      fprintf (stderr,\n";
             pr "               _(\"%%s: '%%s': invalid boolean value, use 'true' or 'false'\\n\"),\n";
-            pr "               guestfs_int_program_name, argv[i-1]);\n";
+            pr "               getprogname (), argv[i-1]);\n";
             pr "      goto out_%s;\n" name;
             pr "    case 0:  %s = 0; break;\n" name;
             pr "    default: %s = 1;\n" name;
@@ -330,7 +331,7 @@ let generate_fish_run_cmds actions () =
                  pr "        case -1:\n";
                  pr "          fprintf (stderr,\n";
                  pr "                   _(\"%%s: '%%s': invalid boolean value, use 'true' or 'false'\\n\"),\n";
-                 pr "                   guestfs_int_program_name, &argv[i][%d]);\n" (len+1);
+                 pr "                   getprogname (), &argv[i][%d]);\n" (len+1);
                  pr "          goto out;\n";
                  pr "        case 0:  optargs_s.%s = 0; break;\n" n;
                  pr "        default: optargs_s.%s = 1;\n" n;
diff --git a/inspector/inspector.c b/inspector/inspector.c
index 9a8fa4d..8f9d04d 100644
--- a/inspector/inspector.c
+++ b/inspector/inspector.c
@@ -37,6 +37,8 @@
 #include <libxml/tree.h>
 #include <libxml/xmlsave.h>
 
+#include "getprogname.h"
+
 #include "guestfs.h"
 #include "options.h"
 #include "display-options.h"
@@ -69,7 +71,7 @@ usage (int status)
 {
   if (status != EXIT_SUCCESS)
     fprintf (stderr, _("Try `%s --help' for more information.\n"),
-             guestfs_int_program_name);
+             getprogname ());
   else {
     printf (_("%s: display information about a virtual machine\n"
               "Copyright (C) 2010 Red Hat Inc.\n"
@@ -91,8 +93,8 @@ usage (int status)
               "  -x                   Trace libguestfs API calls\n"
               "  --xpath query        Perform an XPath query\n"
               "For more information, see the manpage %s(1).\n"),
-            guestfs_int_program_name, guestfs_int_program_name,
-            guestfs_int_program_name, guestfs_int_program_name);
+            getprogname (), getprogname (),
+            getprogname (), getprogname ());
   }
   exit (status);
 }
@@ -238,7 +240,7 @@ main (int argc, char *argv[])
     fprintf (stderr, _("%s: error: extra argument '%s' on command line.\n"
              "Make sure to specify the argument for --format "
              "like '--format=%s'.\n"),
-             guestfs_int_program_name, argv[optind], argv[optind]);
+             getprogname (), argv[optind], argv[optind]);
     usage (EXIT_FAILURE);
   }
 
@@ -260,7 +262,7 @@ main (int argc, char *argv[])
   /* User must have specified some drives. */
   if (drvs == NULL) {
     fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"),
-             guestfs_int_program_name);
+             getprogname ());
     usage (EXIT_FAILURE);
   }
 
diff --git a/m4/.gitignore b/m4/.gitignore
index b447284..42cb69f 100644
--- a/m4/.gitignore
+++ b/m4/.gitignore
@@ -77,6 +77,7 @@
 /getlogin_r.m4
 /getopt.m4
 /getpagesize.m4
+/getprogname.m4
 /gettime.m4
 /gettimeofday.m4
 /getugroups.m4
diff --git a/m4/guestfs_libraries.m4 b/m4/guestfs_libraries.m4
index 582cbbf..90123de 100644
--- a/m4/guestfs_libraries.m4
+++ b/m4/guestfs_libraries.m4
@@ -34,9 +34,6 @@ AC_CHECK_MEMBER([struct stat.st_ctim.tv_nsec],[
 dnl Define a C symbol for the host CPU architecture.
 AC_DEFINE_UNQUOTED([host_cpu],["$host_cpu"],[Host architecture.])
 
-dnl Check if libc has program_invocation_short_name.
-AC_CHECK_DECLS([program_invocation_short_name], [], [], [#include <errno.h>])
-
 dnl Headers.
 AC_CHECK_HEADERS([\
     attr/xattr.h \
@@ -63,7 +60,6 @@ AC_CHECK_FUNCS([\
     be32toh \
     fsync \
     futimens \
-    getprogname \
     getxattr \
     htonl \
     htons \
diff --git a/make-fs/make-fs.c b/make-fs/make-fs.c
index ade2e60..7d01173 100644
--- a/make-fs/make-fs.c
+++ b/make-fs/make-fs.c
@@ -38,6 +38,7 @@
 #include "guestfs-internal-frontend.h"
 
 #include "xstrtol.h"
+#include "getprogname.h"
 
 #include "options.h"
 #include "display-options.h"
@@ -74,7 +75,7 @@ usage (int status)
 {
   if (status != EXIT_SUCCESS)
     fprintf (stderr, _("Try `%s --help' for more information.\n"),
-             guestfs_int_program_name);
+             getprogname ());
   else {
     printf (_("%s: make a filesystem from a tar archive or files\n"
               "Copyright (C) 2010-2016 Red Hat Inc.\n"
@@ -94,9 +95,9 @@ usage (int status)
               "  -V|--version             Display version and exit\n"
               "  -x                       Trace libguestfs API calls\n"
               "For more information, see the manpage %s(1).\n"),
-            guestfs_int_program_name, guestfs_int_program_name,
-            guestfs_int_program_name, guestfs_int_program_name,
-            guestfs_int_program_name);
+            getprogname (), getprogname (),
+            getprogname (), getprogname (),
+            getprogname ());
   }
   exit (status);
 }
@@ -183,7 +184,7 @@ main (int argc, char *argv[])
   if (optind + 2 != argc) {
     fprintf (stderr,
              _("%s: missing input and output arguments on the command line\n"),
-             guestfs_int_program_name);
+             getprogname ());
     usage (EXIT_FAILURE);
   }
 
@@ -202,7 +203,7 @@ check_ntfs_available (void)
       guestfs_feature_available (g, (char **) ntfs_features) == 0) {
     fprintf (stderr,
              _("%s: NTFS support was disabled when libguestfs was compiled\n"),
-             guestfs_int_program_name);
+             getprogname ());
     return -1;
   }
 
@@ -252,7 +253,7 @@ exec_command (char **argv, const char *file)
     }
     if (!WIFEXITED (status) || WEXITSTATUS (status) != 0) {
       fprintf (stderr, _("%s: %s command failed\n"),
-               guestfs_int_program_name, argv[0]);
+               getprogname (), argv[0]);
       return -1;
     }
     return 0;
@@ -316,7 +317,7 @@ exec_command_count_output (char **argv, uint64_t *bytes_rtn)
     }
     if (!WIFEXITED (status) || WEXITSTATUS (status) != 0) {
       fprintf (stderr, _("%s: %s command failed\n"),
-               guestfs_int_program_name, argv[0]);
+               getprogname (), argv[0]);
       return -1;
     }
     return 0;
@@ -441,7 +442,7 @@ estimate_input (const char *input, uint64_t *estimate_rtn, char **ifmt_rtn)
 
     if (sscanf (line, "%" SCNu64, estimate_rtn) != 1) {
       fprintf (stderr, _("%s: cannot parse the output of 'du' command: %s\n"),
-               guestfs_int_program_name, line);
+               getprogname (), line);
       return -1;
     }
   }
@@ -476,7 +477,7 @@ estimate_input (const char *input, uint64_t *estimate_rtn, char **ifmt_rtn)
 
     if (strstr (line, "tar archive") == NULL) {
       fprintf (stderr, _("%s: %s: input is not a directory, tar archive or compressed tar archive\n"),
-               guestfs_int_program_name, input);
+               getprogname (), input);
       return -1;
     }
 
@@ -507,7 +508,7 @@ estimate_input (const char *input, uint64_t *estimate_rtn, char **ifmt_rtn)
       }
       else {
         fprintf (stderr, _("%s: %s: unknown compressed input format (%s)\n"),
-                 guestfs_int_program_name, input, line);
+                 getprogname (), input, line);
         return -1;
       }
 
@@ -630,7 +631,7 @@ parse_size (const char *str, uint64_t estimate, uint64_t *size_rtn)
   if (xerr != LONGINT_OK) {
     fprintf (stderr,
              _("%s: %s: invalid size parameter '%s' (%s returned %u)\n"),
-             guestfs_int_program_name, "parse_size", str, "xstrtoull", xerr);
+             getprogname (), "parse_size", str, "xstrtoull", xerr);
     return -1;
   }
 
@@ -778,7 +779,7 @@ do_make_fs (const char *input, const char *output_str)
     if (r == -1) {
       /* Provide more guidance in the error message (RHBZ#823883). */
       fprintf (stderr, "%s: 'mkfs' (create filesystem) operation failed: %s\n",
-               guestfs_int_program_name, guestfs_last_error (g));
+               getprogname (), guestfs_last_error (g));
       if (STREQ (type, "fat"))
         fprintf (stderr, "Instead of 'fat', try 'vfat' (long filenames) or 'msdos' (short filenames).\n");
       else
@@ -835,7 +836,7 @@ do_make_fs (const char *input, const char *output_str)
       return -1;
     }
     if (!WIFEXITED (status) || WEXITSTATUS (status) != 0) {
-      fprintf (stderr, _("%s: subprocess failed\n"), guestfs_int_program_name);
+      fprintf (stderr, _("%s: subprocess failed\n"), getprogname ());
       return -1;
     }
   }
diff --git a/mllib/getopt-c.c b/mllib/getopt-c.c
index 29845f6..955dc18 100644
--- a/mllib/getopt-c.c
+++ b/mllib/getopt-c.c
@@ -31,6 +31,7 @@
 #include <assert.h>
 
 #include "xstrtol.h"
+#include "getprogname.h"
 
 #include <caml/alloc.h>
 #include <caml/fail.h>
@@ -70,7 +71,7 @@ static void __attribute__((noreturn))
 show_error (int status)
 {
   fprintf (stderr, _("Try `%s --help' or consult %s(1) for more information.\n"),
-           guestfs_int_program_name, guestfs_int_program_name);
+           getprogname (), getprogname ());
   exit (status);
 }
 
@@ -189,13 +190,13 @@ strtoint (const char *arg)
 
   if (xstrtol (arg, NULL, 0, &num, "") != LONGINT_OK) {
     fprintf (stderr, _("%s: '%s' is not a numeric value.\n"),
-             guestfs_int_program_name, arg);
+             getprogname (), arg);
     show_error (EXIT_FAILURE);
   }
 
   if (num < -(1<<30) || num > (1<<30)-1) {
     fprintf (stderr, _("%s: %s: integer out of range\n"),
-             guestfs_int_program_name, arg);
+             getprogname (), arg);
     show_error (EXIT_FAILURE);
   }
 
@@ -375,10 +376,10 @@ guestfs_int_mllib_getopt_parse (value argsv, value specsv, value anon_funv, valu
       if (!list_mem (v, optarg)) {
         if (c != 0) {
           fprintf (stderr, _("%s: '%s' is not allowed for -%c; allowed values are:\n"),
-                   guestfs_int_program_name, optarg, c);
+                   getprogname (), optarg, c);
         } else {
           fprintf (stderr, _("%s: '%s' is not allowed for %s%s; allowed values are:\n"),
-                   guestfs_int_program_name, optarg,
+                   getprogname (), optarg,
                    vector_has_dashdash_opt (specv, longopts[option_index].name) ? "--" : "-",
                    longopts[option_index].name);
         }
diff --git a/p2v/conversion.c b/p2v/conversion.c
index e8f5741..3be9a45 100644
--- a/p2v/conversion.c
+++ b/p2v/conversion.c
@@ -54,6 +54,7 @@
 #include <libxml/xmlwriter.h>
 
 #include "ignore-value.h"
+#include "getprogname.h"
 
 #include "miniexpect.h"
 #include "p2v.h"
@@ -268,7 +269,7 @@ start_conversion (struct config *config,
 #if DEBUG_STDERR
     fprintf (stderr,
              "%s: data connection for %s: SSH remote port %d, local port %d\n",
-             guestfs_int_program_name, device,
+             getprogname (), device,
              data_conns[i].nbd_remote_port, data_conns[i].nbd_local_port);
 #endif
 
diff --git a/p2v/gui.c b/p2v/gui.c
index 3ef1e77..36bb655 100644
--- a/p2v/gui.c
+++ b/p2v/gui.c
@@ -76,6 +76,7 @@
 #pragma GCC diagnostic pop
 
 #include "ignore-value.h"
+#include "getprogname.h"
 
 #include "p2v.h"
 
@@ -275,7 +276,7 @@ create_connection_dialog (struct config *config)
   char port_str[64];
 
   conn_dlg = gtk_dialog_new ();
-  gtk_window_set_title (GTK_WINDOW (conn_dlg), guestfs_int_program_name);
+  gtk_window_set_title (GTK_WINDOW (conn_dlg), getprogname ());
   gtk_window_set_resizable (GTK_WINDOW (conn_dlg), FALSE);
 
   /* The main dialog area. */
@@ -683,7 +684,7 @@ static void
 about_button_clicked (GtkWidget *w, gpointer data)
 {
   gtk_show_about_dialog (GTK_WINDOW (conn_dlg),
-                         "program-name", guestfs_int_program_name,
+                         "program-name", getprogname (),
                          "version", PACKAGE_VERSION_FULL " (" host_cpu ")",
                          "copyright", "\u00A9 2009-2016 Red Hat Inc.",
                          "comments",
@@ -766,7 +767,7 @@ create_conversion_dialog (struct config *config)
   char memory_str[64];
 
   conv_dlg = gtk_dialog_new ();
-  gtk_window_set_title (GTK_WINDOW (conv_dlg), guestfs_int_program_name);
+  gtk_window_set_title (GTK_WINDOW (conv_dlg), getprogname ());
   gtk_window_set_resizable (GTK_WINDOW (conv_dlg), FALSE);
   /* XXX It would be nice not to have to set this explicitly, but
    * if we don't then Gtk chooses a very small window.
@@ -1639,7 +1640,7 @@ create_running_dialog (void)
   GtkTextBuffer *buf;
 
   run_dlg = gtk_dialog_new ();
-  gtk_window_set_title (GTK_WINDOW (run_dlg), guestfs_int_program_name);
+  gtk_window_set_title (GTK_WINDOW (run_dlg), getprogname ());
   gtk_window_set_resizable (GTK_WINDOW (run_dlg), FALSE);
 
   /* The main dialog area. */
@@ -2157,7 +2158,7 @@ notify_ui_callback (int type, const char *data)
   default:
     fprintf (stderr,
              "%s: unknown message during conversion: type=%d data=%s\n",
-             guestfs_int_program_name, type, data);
+             getprogname (), type, data);
     free (copy);
   }
 }
diff --git a/p2v/kernel-cmdline.c b/p2v/kernel-cmdline.c
index c10c045..c53b978 100644
--- a/p2v/kernel-cmdline.c
+++ b/p2v/kernel-cmdline.c
@@ -29,6 +29,8 @@
 #include <errno.h>
 #include <error.h>
 
+#include "getprogname.h"
+
 #include "p2v.h"
 
 static void
@@ -141,7 +143,7 @@ parse_cmdline_string (const char *cmdline)
     break;
   case VALUE_QUOTED:            /* unterminated key="value" */
     fprintf (stderr, "%s: warning: unterminated quoted string on kernel command line\n",
-             guestfs_int_program_name);
+             getprogname ());
     add_string (&ret, &len, value, p-value);
   }
 
diff --git a/p2v/kernel.c b/p2v/kernel.c
index 793e2f6..e225103 100644
--- a/p2v/kernel.c
+++ b/p2v/kernel.c
@@ -35,6 +35,8 @@
 #include <sys/types.h>
 #include <sys/wait.h>
 
+#include "getprogname.h"
+
 #include "p2v.h"
 
 static void notify_ui_callback (int type, const char *data);
@@ -163,7 +165,7 @@ update_config_from_kernel_cmdline (struct config *config, char **cmdline)
       config->output_allocation = OUTPUT_ALLOCATION_PREALLOCATED;
     else
       fprintf (stderr, "%s: warning: don't know what p2v.oa=%s means\n",
-               guestfs_int_program_name, p);
+               getprogname (), p);
   }
 
   p = get_cmdline_key (cmdline, "p2v.oc");
@@ -230,7 +232,7 @@ kernel_conversion (struct config *config, char **cmdline, int cmdline_source)
     const char *err = get_conversion_error ();
 
     fprintf (stderr, "%s: error during conversion: %s\n",
-             guestfs_int_program_name, err);
+             getprogname (), err);
 
     p = get_cmdline_key (cmdline, "p2v.fail");
     if (p)
@@ -259,7 +261,7 @@ notify_ui_callback (int type, const char *data)
   switch (type) {
   case NOTIFY_LOG_DIR:
     ansi_magenta (stdout);
-    printf ("%s: remote log directory location: ", guestfs_int_program_name);
+    printf ("%s: remote log directory location: ", getprogname ());
     ansi_red (stdout);
     fputs (data, stdout);
     ansi_restore (stdout);
@@ -272,7 +274,7 @@ notify_ui_callback (int type, const char *data)
 
   case NOTIFY_STATUS:
     ansi_magenta (stdout);
-    printf ("%s: %s", guestfs_int_program_name, data);
+    printf ("%s: %s", getprogname (), data);
     ansi_restore (stdout);
     putchar ('\n');
     break;
@@ -280,7 +282,7 @@ notify_ui_callback (int type, const char *data)
   default:
     ansi_red (stdout);
     printf ("%s: unknown message during conversion: type=%d data=%s",
-            guestfs_int_program_name, type, data);
+            getprogname (), type, data);
     ansi_restore (stdout);
     putchar ('\n');
   }
diff --git a/p2v/main.c b/p2v/main.c
index a375280..f601456 100644
--- a/p2v/main.c
+++ b/p2v/main.c
@@ -44,6 +44,7 @@
 #pragma GCC diagnostic pop
 
 #include "ignore-value.h"
+#include "getprogname.h"
 #include "p2v.h"
 
 char **all_disks;
@@ -84,7 +85,7 @@ usage (int status)
 {
   if (status != EXIT_SUCCESS)
     fprintf (stderr, _("Try `%s --help' for more information.\n"),
-             guestfs_int_program_name);
+             getprogname ());
   else {
     printf (_("%s: Convert a physical machine to use KVM\n"
               "Copyright (C) 2009-2016 Red Hat Inc.\n"
@@ -99,8 +100,8 @@ usage (int status)
               "  -v|--verbose           Verbose messages\n"
               "  -V|--version           Display version and exit\n"
               "For more information, see the manpage %s(1).\n"),
-            guestfs_int_program_name, guestfs_int_program_name,
-            guestfs_int_program_name);
+            getprogname (), getprogname (),
+            getprogname ());
   }
   exit (status);
 }
@@ -198,7 +199,7 @@ main (int argc, char *argv[])
       break;
 
     case 'V':
-      printf ("%s %s\n", guestfs_int_program_name, PACKAGE_VERSION_FULL);
+      printf ("%s %s\n", getprogname (), PACKAGE_VERSION_FULL);
       exit (EXIT_SUCCESS);
 
     case HELP_OPTION:
@@ -211,7 +212,7 @@ main (int argc, char *argv[])
 
   if (optind != argc) {
     fprintf (stderr, _("%s: unused arguments on the command line\n"),
-             guestfs_int_program_name);
+             getprogname ());
     usage (EXIT_FAILURE);
   }
 
diff --git a/p2v/ssh.c b/p2v/ssh.c
index d10a121..5c657ed 100644
--- a/p2v/ssh.c
+++ b/p2v/ssh.c
@@ -54,6 +54,7 @@
 #include <sys/wait.h>
 
 #include "ignore-value.h"
+#include "getprogname.h"
 
 #include "miniexpect.h"
 #include "p2v.h"
@@ -140,7 +141,7 @@ compile_regexps (void)
     pcre_fullinfo ((re), NULL, PCRE_INFO_OKPARTIAL, &p);		\
     if (p != 1) {							\
       fprintf (stderr, "%s: %s:%d: internal error: pattern '%s' cannot be used for partial matching\n", \
-	       guestfs_int_program_name,				\
+	       getprogname (),				\
 	       __FILE__, __LINE__, (pattern));				\
       abort ();								\
     }									\
@@ -778,7 +779,7 @@ test_connection (struct config *config)
       v2v_version = strndup (&h->buffer[ovector[2]], ovector[3]-ovector[2]);
 #if DEBUG_STDERR
       fprintf (stderr, "%s: remote virt-v2v version: %s\n",
-               guestfs_int_program_name, v2v_version);
+               getprogname (), v2v_version);
 #endif
       break;
 
@@ -860,7 +861,7 @@ test_connection (struct config *config)
     case 101:                   /* virt-v2v supports --colours option */
 #if DEBUG_STDERR
   fprintf (stderr, "%s: remote virt-v2v supports --colours option\n",
-           guestfs_int_program_name);
+           getprogname ());
 #endif
       feature_colours_option = 1;
       break;
@@ -974,7 +975,7 @@ add_option (const char *type, char ***drivers, const char *name, size_t len)
 
 #if DEBUG_STDERR
   fprintf (stderr, "%s: remote virt-v2v supports %s driver %s\n",
-           guestfs_int_program_name, type, (*drivers)[n-1]);
+           getprogname (), type, (*drivers)[n-1]);
 #endif
 }
 
diff --git a/rescue/rescue.c b/rescue/rescue.c
index 0f83f04..0c04396 100644
--- a/rescue/rescue.c
+++ b/rescue/rescue.c
@@ -32,6 +32,7 @@
 
 #include "ignore-value.h"
 #include "xvasprintf.h"
+#include "getprogname.h"
 
 #include "guestfs.h"
 #include "options.h"
@@ -56,7 +57,7 @@ usage (int status)
 {
   if (status != EXIT_SUCCESS)
     fprintf (stderr, _("Try `%s --help' for more information.\n"),
-             guestfs_int_program_name);
+             getprogname ());
   else {
     printf (_("%s: Run a rescue shell on a virtual machine\n"
               "Copyright (C) 2009-2016 Red Hat Inc.\n"
@@ -82,8 +83,8 @@ usage (int status)
               "  -w|--rw              Mount read-write\n"
               "  -x                   Trace libguestfs API calls\n"
               "For more information, see the manpage %s(1).\n"),
-            guestfs_int_program_name, guestfs_int_program_name,
-            guestfs_int_program_name, guestfs_int_program_name);
+            getprogname (), getprogname (),
+            getprogname (), getprogname ());
   }
   exit (status);
 }
@@ -279,7 +280,7 @@ main (int argc, char *argv[])
     fprintf (stderr, _("%s: error: extra argument '%s' on command line.\n"
              "Make sure to specify the argument for --format or --scratch "
              "like '--format=%s'.\n"),
-             guestfs_int_program_name, argv[optind], argv[optind]);
+             getprogname (), argv[optind], argv[optind]);
     usage (EXIT_FAILURE);
   }
 
@@ -288,7 +289,7 @@ main (int argc, char *argv[])
   /* User must have specified some drives. */
   if (drvs == NULL) {
     fprintf (stderr, _("%s: error: you must specify at least one -a or -d option.\n"),
-             guestfs_int_program_name);
+             getprogname ());
     usage (EXIT_FAILURE);
   }
 
@@ -306,7 +307,7 @@ main (int argc, char *argv[])
           STRPREFIX (backend, "libvirt:")) {
         fprintf (stderr, _("%s: warning: virt-rescue doesn't work with the libvirt backend\n"
                            "at the moment.  As a workaround, forcing backend = 'direct'.\n"),
-                 guestfs_int_program_name);
+                 getprogname ());
         if (guestfs_set_backend (g, "direct") == -1)
           exit (EXIT_FAILURE);
       }
diff --git a/src/guestfs-internal-frontend.h b/src/guestfs-internal-frontend.h
index 5676934..da7709a 100644
--- a/src/guestfs-internal-frontend.h
+++ b/src/guestfs-internal-frontend.h
@@ -129,17 +129,6 @@ extern void guestfs_int_cleanup_pclose (void *ptr);
  */
 #include "guestfs-internal-frontend-cleanups.h"
 
-/* Current program name.  Note <errno.h> must be included in all files
- * that want to use 'guestfs_int_program_name'.
- */
-#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME == 1
-#  define guestfs_int_program_name program_invocation_short_name
-#elif HAVE_GETPROGNAME
-#  define guestfs_int_program_name getprogname()
-#else
-#  define guestfs_int_program_name "libguestfs"
-#endif
-
 /* Close all file descriptors matching the condition. */
 #define close_file_descriptors(cond) do {                               \
     int max_fd = sysconf (_SC_OPEN_MAX);                                \
diff --git a/src/handle.c b/src/handle.c
index 81a3cb1..b28a1e0 100644
--- a/src/handle.c
+++ b/src/handle.c
@@ -34,6 +34,7 @@
 #include "glthread/lock.h"
 #include "ignore-value.h"
 #include "c-ctype.h"
+#include "getprogname.h"
 
 #include "guestfs.h"
 #include "guestfs-internal.h"
@@ -120,15 +121,11 @@ guestfs_create_flags (unsigned flags, ...)
   if (!g->hv) goto error;
 
   /* Get program name. */
-#if HAVE_DECL_PROGRAM_INVOCATION_SHORT_NAME == 1
-  if (STRPREFIX (program_invocation_short_name, "lt-"))
+  if (STRPREFIX (getprogname (), "lt-"))
     /* Remove libtool (lt-*) prefix from short name. */
-    g->program = strdup (program_invocation_short_name + 3);
+    g->program = strdup (getprogname () + 3);
   else
-    g->program = strdup (program_invocation_short_name);
-#else
-  g->program = strdup ("");
-#endif
+    g->program = strdup (getprogname ());
   if (!g->program) goto error;
 
   g->identifier = strdup ("");
diff --git a/tests/charsets/test-charset-fidelity.c b/tests/charsets/test-charset-fidelity.c
index 9a477ce..952256e 100644
--- a/tests/charsets/test-charset-fidelity.c
+++ b/tests/charsets/test-charset-fidelity.c
@@ -33,6 +33,8 @@
 #include "guestfs.h"
 #include "guestfs-internal-frontend.h"
 
+#include "getprogname.h"
+
 static const char ourenvvar[] = "SKIP_TEST_CHARSET_FIDELITY";
 
 struct filesystem {
@@ -83,7 +85,7 @@ main (int argc, char *argv[])
   str = getenv (ourenvvar);
   if (str && guestfs_int_is_true (str) > 0) {
     printf ("%s: test skipped because environment variable is set.\n",
-            guestfs_int_program_name);
+            getprogname ());
     exit (77);
   }
 
diff --git a/tests/mount-local/test-parallel-mount-local.c b/tests/mount-local/test-parallel-mount-local.c
index 37b2b3d..3e5d95c 100644
--- a/tests/mount-local/test-parallel-mount-local.c
+++ b/tests/mount-local/test-parallel-mount-local.c
@@ -42,6 +42,7 @@
 #include "estimate-max-threads.h"
 
 #include "ignore-value.h"
+#include "getprogname.h"
 
 #define TOTAL_TIME 60           /* Seconds, excluding launch. */
 #define DEBUG 1                 /* Print overview debugging messages. */
@@ -96,13 +97,13 @@ main (int argc, char *argv[])
   skip = getenv ("SKIP_TEST_PARALLEL_MOUNT_LOCAL");
   if (skip && guestfs_int_is_true (skip) > 0) {
     fprintf (stderr, "%s: test skipped because environment variable set.\n",
-             guestfs_int_program_name);
+             getprogname ());
     exit (77);
   }
 
   if (access ("/dev/fuse", W_OK) == -1) {
     fprintf (stderr, "%s: test skipped because /dev/fuse is not writable.\n",
-             guestfs_int_program_name);
+             getprogname ());
     exit (77);
   }
 
diff --git a/tests/parallel/test-parallel.c b/tests/parallel/test-parallel.c
index e0d1385..20100d1 100644
--- a/tests/parallel/test-parallel.c
+++ b/tests/parallel/test-parallel.c
@@ -38,6 +38,7 @@
 #include "guestfs-internal-frontend.h"
 
 #include "ignore-value.h"
+#include "getprogname.h"
 
 #define TOTAL_TIME 600          /* Seconds, excluding launch. */
 #define NR_THREADS 5
@@ -79,7 +80,7 @@ main (int argc, char *argv[])
   slow = getenv ("SLOW");
   if (!slow || guestfs_int_is_true (slow) <= 0) {
     fprintf (stderr, "%s: use 'make check-slow' to run this test.\n",
-             guestfs_int_program_name);
+             getprogname ());
     exit (77);
   }
 
@@ -87,7 +88,7 @@ main (int argc, char *argv[])
   skip = getenv ("SKIP_TEST_PARALLEL");
   if (skip && guestfs_int_is_true (skip) > 0) {
     fprintf (stderr, "%s: test skipped because environment variable set.\n",
-             guestfs_int_program_name);
+             getprogname ());
     exit (77);
   }
 
diff --git a/tests/regressions/Makefile.am b/tests/regressions/Makefile.am
index 32bbc83..dc91c60 100644
--- a/tests/regressions/Makefile.am
+++ b/tests/regressions/Makefile.am
@@ -112,15 +112,18 @@ rhbz501893_LDADD = \
 
 rhbz790721_SOURCES = rhbz790721.c
 rhbz790721_CPPFLAGS = \
+	-I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \
 	-I$(top_srcdir)/src -I$(top_builddir)/src
 rhbz790721_CFLAGS = \
 	-pthread \
 	$(WARN_CFLAGS) $(WERROR_CFLAGS)
 rhbz790721_LDADD = \
-	$(top_builddir)/src/libguestfs.la
+	$(top_builddir)/src/libguestfs.la \
+	$(top_builddir)/gnulib/lib/libgnu.la
 
 rhbz914931_SOURCES = rhbz914931.c
 rhbz914931_CPPFLAGS = \
+	-I$(top_srcdir)/gnulib/lib -I$(top_builddir)/gnulib/lib \
 	-I$(top_srcdir)/src -I$(top_builddir)/src \
 	-DGUESTFS_PRIVATE=1
 rhbz914931_CFLAGS = \
@@ -129,7 +132,8 @@ rhbz914931_CFLAGS = \
 rhbz914931_LDADD = \
 	$(top_builddir)/src/libutils.la \
 	$(LTLIBINTL) \
-	$(top_builddir)/src/libguestfs.la
+	$(top_builddir)/src/libguestfs.la \
+	$(top_builddir)/gnulib/lib/libgnu.la
 
 rhbz1055452_SOURCES = rhbz1055452.c
 rhbz1055452_CPPFLAGS = \
diff --git a/tests/regressions/rhbz790721.c b/tests/regressions/rhbz790721.c
index e2178e5..2dfcd27 100644
--- a/tests/regressions/rhbz790721.c
+++ b/tests/regressions/rhbz790721.c
@@ -45,6 +45,8 @@
 #include "guestfs.h"
 #include "guestfs-internal-frontend.h"
 
+#include "getprogname.h"
+
 /* Number of worker threads running the test. */
 #define NR_THREADS 20
 
@@ -71,7 +73,7 @@ main (int argc, char *argv[])
   }
   if (STRNEQ (backend, "direct")) {
     fprintf (stderr, "%s: test skipped because backend isn't 'direct'.\n",
-             guestfs_int_program_name);
+             getprogname ());
     free (backend);
     guestfs_close (g);
     exit (77);
diff --git a/tests/regressions/rhbz914931.c b/tests/regressions/rhbz914931.c
index 61b81ba..93878db 100644
--- a/tests/regressions/rhbz914931.c
+++ b/tests/regressions/rhbz914931.c
@@ -33,6 +33,8 @@
 #include "guestfs.h"
 #include "guestfs-internal-frontend.h"
 
+#include "getprogname.h"
+
 int
 main (int argc, char *argv[])
 {
@@ -44,7 +46,7 @@ main (int argc, char *argv[])
   str = getenv ("SKIP_TEST_RHBZ914931");
   if (str && guestfs_int_is_true (str) > 0) {
     printf ("%s: test skipped because environment variable is set.\n",
-            guestfs_int_program_name);
+            getprogname ());
     exit (77);
   }
 
diff --git a/utils/boot-analysis/boot-analysis.c b/utils/boot-analysis/boot-analysis.c
index 2b042d9..04b3bdd 100644
--- a/utils/boot-analysis/boot-analysis.c
+++ b/utils/boot-analysis/boot-analysis.c
@@ -45,6 +45,8 @@
 #include "boot-analysis.h"
 #include "boot-analysis-utils.h"
 
+#include "getprogname.h"
+
 /* Activities taking longer than this % of the total time, except
  * those flagged as LONG_ACTIVITY, are highlighted in red.
  */
@@ -167,13 +169,13 @@ main (int argc, char *argv[])
         break;
       }
       fprintf (stderr, "%s: unknown long option: %s (%d)\n",
-               guestfs_int_program_name, long_options[option_index].name, option_index);
+               getprogname (), long_options[option_index].name, option_index);
       exit (EXIT_FAILURE);
 
     case 'm':
       if (sscanf (optarg, "%d", &memsize) != 1) {
         fprintf (stderr, "%s: could not parse memsize parameter: %s\n",
-                 guestfs_int_program_name, optarg);
+                 getprogname (), optarg);
         exit (EXIT_FAILURE);
       }
       break;
diff --git a/utils/boot-benchmark/boot-benchmark.c b/utils/boot-benchmark/boot-benchmark.c
index fb946de..73da722 100644
--- a/utils/boot-benchmark/boot-benchmark.c
+++ b/utils/boot-benchmark/boot-benchmark.c
@@ -38,6 +38,8 @@
 
 #include "boot-analysis-utils.h"
 
+#include "getprogname.h"
+
 #define NR_WARMUP_PASSES 3
 #define NR_TEST_PASSES   10
 
@@ -102,19 +104,19 @@ main (int argc, char *argv[])
       else if (STREQ (long_options[option_index].name, "smp")) {
         if (sscanf (optarg, "%d", &smp) != 1) {
           fprintf (stderr, "%s: could not parse smp parameter: %s\n",
-                   guestfs_int_program_name, optarg);
+                   getprogname (), optarg);
           exit (EXIT_FAILURE);
         }
         break;
       }
       fprintf (stderr, "%s: unknown long option: %s (%d)\n",
-               guestfs_int_program_name, long_options[option_index].name, option_index);
+               getprogname (), long_options[option_index].name, option_index);
       exit (EXIT_FAILURE);
 
     case 'm':
       if (sscanf (optarg, "%d", &memsize) != 1) {
         fprintf (stderr, "%s: could not parse memsize parameter: %s\n",
-                 guestfs_int_program_name, optarg);
+                 getprogname (), optarg);
         exit (EXIT_FAILURE);
       }
       break;
diff --git a/utils/qemu-boot/qemu-boot.c b/utils/qemu-boot/qemu-boot.c
index 2703014..d99fa3c 100644
--- a/utils/qemu-boot/qemu-boot.c
+++ b/utils/qemu-boot/qemu-boot.c
@@ -39,6 +39,8 @@
 #include "guestfs-internal-frontend.h"
 #include "estimate-max-threads.h"
 
+#include "getprogname.h"
+
 #define MIN(a,b) ((a)<(b)?(a):(b))
 
 /* Maximum number of threads we would ever run.  Note this should not
@@ -204,7 +206,7 @@ run_test (size_t P)
     err = pthread_join (threads[i], &status);
     if (err != 0) {
       fprintf (stderr, "%s: pthread_join[%zu]: %s\n",
-               guestfs_int_program_name, i, strerror (err));
+               getprogname (), i, strerror (err));
       errors++;
     }
     if (*(int *)status == -1)
@@ -235,7 +237,7 @@ start_thread (void *thread_data_vp)
     err = pthread_mutex_lock (&mutex);
     if (err != 0) {
       fprintf (stderr, "%s: pthread_mutex_lock: %s",
-               guestfs_int_program_name, strerror (err));
+               getprogname (), strerror (err));
       goto error;
     }
 
@@ -252,7 +254,7 @@ start_thread (void *thread_data_vp)
     err = pthread_mutex_unlock (&mutex);
     if (err != 0) {
       fprintf (stderr, "%s: pthread_mutex_unlock: %s",
-               guestfs_int_program_name, strerror (err));
+               getprogname (), strerror (err));
       goto error;
     }
 
@@ -320,7 +322,7 @@ start_thread (void *thread_data_vp)
 
   if (errors > 0) {
     fprintf (stderr, "%s: thread %d: %u errors were ignored\n",
-             guestfs_int_program_name, thread_data->thread_num, errors);
+             getprogname (), thread_data->thread_num, errors);
     goto error;
   }
 
diff --git a/utils/qemu-speed-test/qemu-speed-test.c b/utils/qemu-speed-test/qemu-speed-test.c
index 0919594..54875fa 100644
--- a/utils/qemu-speed-test/qemu-speed-test.c
+++ b/utils/qemu-speed-test/qemu-speed-test.c
@@ -41,6 +41,8 @@
 #include "guestfs.h"
 #include "guestfs-internal-frontend.h"
 
+#include "getprogname.h"
+
 static void test_virtio_serial (void);
 static void test_block_device (void);
 
@@ -133,7 +135,7 @@ main (int argc, char *argv[])
       }
       else {
         fprintf (stderr, "%s: unknown long option: %s (%d)\n",
-                 guestfs_int_program_name, long_options[option_index].name, option_index);
+                 getprogname (), long_options[option_index].name, option_index);
         exit (EXIT_FAILURE);
       }
       break;
@@ -142,7 +144,7 @@ main (int argc, char *argv[])
       if (sscanf (optarg, "%d", &max_time_override) != 1 ||
           max_time_override < 0) {
         fprintf (stderr, "%s: -t: argument is not a positive integer\n",
-                 guestfs_int_program_name);
+                 getprogname ());
         exit (EXIT_FAILURE);
       }
       break;
@@ -157,7 +159,7 @@ main (int argc, char *argv[])
 
   if (optind != argc) {
     fprintf (stderr, "%s: extra arguments found on the command line\n",
-             guestfs_int_program_name);
+             getprogname ());
     exit (EXIT_FAILURE);
   }
 
@@ -312,14 +314,14 @@ test_virtio_serial (void)
     if (r == -1 && guestfs_last_errno (g) != EINTR) {
       fprintf (stderr,
                "%s: expecting upload command to return EINTR\n%s\n",
-               guestfs_int_program_name, guestfs_last_error (g));
+               getprogname (), guestfs_last_error (g));
       exit (EXIT_FAILURE);
     }
 
     if (rate == -1) {
     rate_error:
       fprintf (stderr, "%s: internal error: progress callback was not called! (r=%d, errno=%d)\n",
-               guestfs_int_program_name,
+               getprogname (),
                r, guestfs_last_errno (g));
       exit (EXIT_FAILURE);
     }
@@ -348,7 +350,7 @@ test_virtio_serial (void)
     if (r == -1 && guestfs_last_errno (g) != EINTR) {
       fprintf (stderr,
                "%s: expecting download command to return EINTR\n%s\n",
-               guestfs_int_program_name, guestfs_last_error (g));
+               getprogname (), guestfs_last_error (g));
       exit (EXIT_FAILURE);
     }
 
@@ -417,7 +419,7 @@ test_block_device (void)
     exit (EXIT_FAILURE);
   if (devices[0] == NULL) {
     fprintf (stderr, "%s: expected guestfs_list_devices to return at least 1 device\n",
-             guestfs_int_program_name);
+             getprogname ());
     exit (EXIT_FAILURE);
   }
 
@@ -433,7 +435,7 @@ test_block_device (void)
 
     if (sscanf (r, "%" SCNi64, &bytes_written) != 1) {
       fprintf (stderr, "%s: could not parse device_speed output\n",
-               guestfs_int_program_name);
+               getprogname ());
       exit (EXIT_FAILURE);
     }
 
@@ -452,7 +454,7 @@ test_block_device (void)
 
     if (sscanf (r, "%" SCNi64, &bytes_read) != 1) {
       fprintf (stderr, "%s: could not parse device_speed output\n",
-               guestfs_int_program_name);
+               getprogname ());
       exit (EXIT_FAILURE);
     }
 
-- 
2.7.4


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]