X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;ds=sidebyside;f=daemon%2Fdaemon.h;h=b4f99a81a1d8a4a94cca1b778aa1d7465d61e55f;hb=ffc01285ee4289da90983a3320873f27b3d31c4d;hp=3a67758b88b5be07b0e552600945cba5033eedf7;hpb=a0e3b2183733c7440ad017c4ffe361935672339b;p=libguestfs.git diff --git a/daemon/daemon.h b/daemon/daemon.h index 3a67758..b4f99a8 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); @@ -174,6 +174,41 @@ extern void reply (xdrproc_t xdrp, char *ret); */ extern void notify_progress (uint64_t position, uint64_t total); +/* Pulse mode progress messages. + * + * Call pulse_mode_start to start sending progress messages. + * + * Call pulse_mode_end along the ordinary exit path (ie. before a + * reply message is sent). + * + * Call pulse_mode_cancel along all error paths *before* any reply is + * sent. pulse_mode_cancel does not modify errno, so it is safe to + * call it before reply_with_perror. + * + * Pulse mode and ordinary notify_progress must not be mixed. + */ +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 functions that need a root filesystem mounted. * NB. Cannot be used for FileIn functions. */