tests: Don't use <guestfs-internal.h> in tests.
[libguestfs.git] / daemon / swap.c
index bcc5f1b..fbeb895 100644 (file)
 #include "../src/guestfs_protocol.h"
 #include "daemon.h"
 #include "actions.h"
+#include "optgroups.h"
+
+/* Convenient place to test for the later version of e2fsprogs
+ * and util-linux which supports -U parameters to specify UUIDs.
+ * (Not supported in RHEL 5).
+ */
+int
+optgroup_linuxfsuuid_available (void)
+{
+  char *err;
+  int av;
+
+  /* Ignore return code - mkswap --help *will* fail. */
+  command (NULL, &err, "/sbin/mkswap", "--help", NULL);
+
+  av = strstr (err, "-U") != NULL;
+  free (err);
+  return av;
+}
 
 static int
 mkswap (const char *device, const char *flag, const char *value)
@@ -39,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;
   }
@@ -96,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;
   }