X-Git-Url: http://git.annexia.org/?p=libguestfs.git;a=blobdiff_plain;f=daemon%2Finotify.c;h=c8862e552cc4c5d7448a47aae8e4fe0a4d30360c;hp=d5a5a73ef3dce7c3b29490a5408510d276a5648c;hb=7f16c346bbeba2f2fe3c31ccb85158178a284d84;hpb=dc706a639eec16084c0618baf7bfde00c6565f63 diff --git a/daemon/inotify.c b/daemon/inotify.c index d5a5a73..c8862e5 100644 --- a/daemon/inotify.c +++ b/daemon/inotify.c @@ -28,7 +28,7 @@ #include #endif -#include "../src/guestfs_protocol.h" +#include "guestfs_protocol.h" #include "daemon.h" #include "actions.h" #include "optgroups.h" @@ -70,7 +70,7 @@ do_inotify_init (int max_events) #ifdef HAVE_SYS_INOTIFY_H FILE *fp; - NEED_ROOT (0, return -1); + NEED_ROOT (, return -1); if (max_events < 0) { reply_with_error ("max_events < 0"); @@ -314,7 +314,7 @@ do_inotify_files (void) char **ret = NULL; int size = 0, alloc = 0; unsigned int i; - FILE *fp; + FILE *fp = NULL; guestfs_int_inotify_event_list *events; char buf[PATH_MAX]; @@ -361,13 +361,12 @@ do_inotify_files (void) if (len > 0 && buf[len-1] == '\n') buf[len-1] = '\0'; - if (add_string (&ret, &size, &alloc, buf) == -1) { - fclose (fp); + if (add_string (&ret, &size, &alloc, buf) == -1) goto error; - } } fclose (fp); + fp = NULL; if (add_string (&ret, &size, &alloc, NULL) == -1) goto error; @@ -376,6 +375,9 @@ do_inotify_files (void) return ret; error: + if (fp != NULL) + fclose (fp); + unlink ("/tmp/inotify"); return NULL; #else