X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=daemon%2Fdaemon.h;h=c3b9120932eaee6b23bffc8c988afe68f77f90cd;hp=001c7038d04b8f924decea316df199fbb52d9a51;hb=875dc84cc01dacb1e254e294a66e179b96fbdbc6;hpb=0703248d233744047515418893dac05ce013a642 diff --git a/daemon/daemon.h b/daemon/daemon.h index 001c703..c3b9120 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -22,8 +22,6 @@ #include #include #include -#include -#include #include #include @@ -47,8 +45,12 @@ extern int commandv (char **stdoutput, char **stderror, extern int commandrv (char **stdoutput, char **stderror, char * const* const argv); +extern char **split_lines (char *str); + extern int shell_quote (char *out, int len, const char *in); +extern int device_name_translation (char *device, const char *func); + extern int verbose; /*-- in proto.c --*/ @@ -118,20 +120,21 @@ extern void reply (xdrproc_t xdrp, char *ret); } \ } while (0) -/* Helper for functions that need an argument ("path") that is a device. +/* All functions that need an argument that is a device or partition name + * must call this macro. It checks that the device exists and does + * device name translation (described in the guestfs(3) manpage). + * Note that the "path" argument may be modified. + * * NB. Cannot be used for FileIn functions. */ #define IS_DEVICE(path,errcode) \ do { \ - struct stat statbuf; \ if (strncmp ((path), "/dev/", 5) != 0) { \ reply_with_error ("%s: %s: expecting a device name", __func__, (path)); \ return (errcode); \ } \ - if (stat ((path), &statbuf) == -1) { \ - reply_with_perror ("%s: %s", __func__, (path)); \ + if (device_name_translation ((path), __func__) == -1) \ return (errcode); \ - } \ } while (0) /* Helper for functions which need either an absolute path in the