X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=daemon%2Fdaemon.h;h=69097c34f957c4124f3916fdef9dd631bcba0f1a;hb=c649817586e5b4df53b251d1290422f5ef046045;hp=40a087de773a3b9915734446cd2855a11cb7c107;hpb=40f7323134e058c0920caa18c667ea99a4c8b3e8;p=libguestfs.git diff --git a/daemon/daemon.h b/daemon/daemon.h index 40a087d..69097c3 100644 --- a/daemon/daemon.h +++ b/daemon/daemon.h @@ -36,7 +36,7 @@ extern int verbose; extern int autosync_umount; extern const char *sysroot; -extern int sysroot_len; +extern size_t sysroot_len; extern char *sysroot_path (const char *path); @@ -47,6 +47,7 @@ extern int xwrite (int sock, const void *buf, size_t len) extern int xread (int sock, void *buf, size_t len) __attribute__((__warn_unused_result__)); +extern int add_string_nodup (char ***argv, int *size, int *alloc, char *str); extern int add_string (char ***argv, int *size, int *alloc, const char *str); extern size_t count_strings (char *const *argv); extern void sort_strings (char **argv, int len); @@ -134,6 +135,9 @@ extern int e2prog (char *name); /* Massive hack for RHEL 5. */ /*-- in lvm.c --*/ extern int lv_canonical (const char *device, char **ret); +/*-- in lvm-filter.c --*/ +extern void copy_lvm (void); + /*-- in proto.c --*/ extern void main_loop (int sock) __attribute__((noreturn)); @@ -191,6 +195,36 @@ extern void pulse_mode_start (void); extern void pulse_mode_end (void); extern void pulse_mode_cancel (void); +/* Return true iff the buffer is all zero bytes. + * + * Note that gcc is smart enough to optimize this properly: + * http://stackoverflow.com/questions/1493936/faster-means-of-checking-for-an-empty-buffer-in-c/1493989#1493989 + */ +static inline int +is_zero (const char *buffer, size_t size) +{ + size_t i; + + for (i = 0; i < size; ++i) { + if (buffer[i] != 0) + return 0; + } + + return 1; +} + +/* Helper for building up short lists of arguments. Your code has to + * define MAX_ARGS to a suitable value. + */ +#define ADD_ARG(argv,i,v) \ + do { \ + if ((i) >= MAX_ARGS) { \ + fprintf (stderr, "%s: %d: internal error: exceeded MAX_ARGS (%zu) when constructing the command line\n", __FILE__, __LINE__, (size_t) MAX_ARGS); \ + abort (); \ + } \ + (argv)[(i)++] = (v); \ + } while (0) + /* Helper for functions that need a root filesystem mounted. * NB. Cannot be used for FileIn functions. */