+extern void free_stringslen (char **argv, int len);
+
+extern int is_power_of_2 (unsigned long v);
+
+#define command(out,err,name,...) commandf((out),(err),0,(name),__VA_ARGS__)
+#define commandr(out,err,name,...) commandrf((out),(err),0,(name),__VA_ARGS__)
+#define commandv(out,err,argv) commandvf((out),(err),0,(argv))
+#define commandrv(out,err,argv) commandrvf((out),(err),0,(argv))
+
+#define COMMAND_FLAG_FD_MASK (1024-1)
+#define COMMAND_FLAG_FOLD_STDOUT_ON_STDERR 1024
+#define COMMAND_FLAG_CHROOT_COPY_FILE_TO_STDIN 2048
+
+extern int commandf (char **stdoutput, char **stderror, int flags,
+ const char *name, ...);
+extern int commandrf (char **stdoutput, char **stderror, int flags,
+ const char *name, ...);
+extern int commandvf (char **stdoutput, char **stderror, int flags,
+ char const *const *argv);
+extern int commandrvf (char **stdoutput, char **stderror, int flags,
+ char const* const *argv);
+
+extern char **split_lines (char *str);
+
+extern void trim (char *str);
+
+extern int device_name_translation (char *device);
+
+extern int prog_exists (const char *prog);
+
+extern void udev_settle (void);
+
+/* This just stops gcc from giving a warning about our custom printf
+ * formatters %Q and %R. See guestfs(3)/EXTENDING LIBGUESTFS for more
+ * info about these.
+ */
+static inline int
+asprintf_nowarn (char **strp, const char *fmt, ...)
+{
+ int r;
+ va_list args;