git.annexia.org
/
libguestfs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix 'unknown filesystem' warnings in old inspection code (RHBZ#678231 RHBZ#666578).
[libguestfs.git]
/
daemon
/
inotify.c
diff --git
a/daemon/inotify.c
b/daemon/inotify.c
index
465d0b6
..
c8862e5
100644
(file)
--- a/
daemon/inotify.c
+++ b/
daemon/inotify.c
@@
-28,9
+28,10
@@
#include <sys/inotify.h>
#endif
#include <sys/inotify.h>
#endif
-#include "
../src/
guestfs_protocol.h"
+#include "guestfs_protocol.h"
#include "daemon.h"
#include "actions.h"
#include "daemon.h"
#include "actions.h"
+#include "optgroups.h"
#ifdef HAVE_SYS_INOTIFY_H
/* Currently open inotify handle, or -1 if not opened. */
#ifdef HAVE_SYS_INOTIFY_H
/* Currently open inotify handle, or -1 if not opened. */
@@
-38,6
+39,18
@@
static int inotify_fd = -1;
static char inotify_buf[64*1024*1024]; /* Event buffer, [0..posn-1] is valid */
static size_t inotify_posn = 0;
static char inotify_buf[64*1024*1024]; /* Event buffer, [0..posn-1] is valid */
static size_t inotify_posn = 0;
+
+int
+optgroup_inotify_available (void)
+{
+ return 1;
+}
+#else /* !HAVE_SYS_INOTIFY_H */
+int
+optgroup_inotify_available (void)
+{
+ return 0;
+}
#endif
/* Because inotify_init does NEED_ROOT, NEED_INOTIFY implies NEED_ROOT. */
#endif
/* Because inotify_init does NEED_ROOT, NEED_INOTIFY implies NEED_ROOT. */
@@
-57,10
+70,10
@@
do_inotify_init (int max_events)
#ifdef HAVE_SYS_INOTIFY_H
FILE *fp;
#ifdef HAVE_SYS_INOTIFY_H
FILE *fp;
- NEED_ROOT (return -1);
+ NEED_ROOT (
,
return -1);
if (max_events < 0) {
if (max_events < 0) {
- reply_with_error ("
inotify_init:
max_events < 0");
+ reply_with_error ("max_events < 0");
return -1;
}
return -1;
}
@@
-81,7
+94,7
@@
do_inotify_init (int max_events)
#ifdef HAVE_INOTIFY_INIT1
inotify_fd = inotify_init1 (IN_NONBLOCK | IN_CLOEXEC);
if (inotify_fd == -1) {
#ifdef HAVE_INOTIFY_INIT1
inotify_fd = inotify_init1 (IN_NONBLOCK | IN_CLOEXEC);
if (inotify_fd == -1) {
- reply_with_perror ("inotify_init");
+ reply_with_perror ("inotify_init
1
");
return -1;
}
#else
return -1;
}
#else
@@
-106,8
+119,7
@@
do_inotify_init (int max_events)
return 0;
#else
return 0;
#else
- reply_with_error ("%s is not available", __func__);
- return -1;
+ NOT_AVAILABLE (-1);
#endif
}
#endif
}
@@
-118,7
+130,7
@@
do_inotify_close (void)
NEED_INOTIFY (-1);
if (inotify_fd == -1) {
NEED_INOTIFY (-1);
if (inotify_fd == -1) {
- reply_with_error ("
inotify_close:
handle is not open");
+ reply_with_error ("handle is not open");
return -1;
}
return -1;
}
@@
-132,8
+144,7
@@
do_inotify_close (void)
return 0;
#else
return 0;
#else
- reply_with_error ("%s is not available", __func__);
- return -1;
+ NOT_AVAILABLE (-1);
#endif
}
#endif
}
@@
-155,14
+166,13
@@
do_inotify_add_watch (const char *path, int mask)
r = inotify_add_watch (inotify_fd, buf, mask);
free (buf);
if (r == -1) {
r = inotify_add_watch (inotify_fd, buf, mask);
free (buf);
if (r == -1) {
- reply_with_perror ("
inotify_add_watch:
%s", path);
+ reply_with_perror ("%s", path);
return -1;
}
return r;
#else
return -1;
}
return r;
#else
- reply_with_error ("%s is not available", __func__);
- return -1;
+ NOT_AVAILABLE (-1);
#endif
}
#endif
}
@@
-173,14
+183,13
@@
do_inotify_rm_watch (int wd)
NEED_INOTIFY (-1);
if (inotify_rm_watch (inotify_fd, wd) == -1) {
NEED_INOTIFY (-1);
if (inotify_rm_watch (inotify_fd, wd) == -1) {
- reply_with_perror ("
inotify_rm_watch:
%d", wd);
+ reply_with_perror ("%d", wd);
return -1;
}
return 0;
#else
return -1;
}
return 0;
#else
- reply_with_error ("%s is not available", __func__);
- return -1;
+ NOT_AVAILABLE (-1);
#endif
}
#endif
}
@@
-221,7
+230,7
@@
do_inotify_read (void)
goto error;
}
if (r == 0) { /* End of file - we're not expecting it. */
goto error;
}
if (r == 0) { /* End of file - we're not expecting it. */
- reply_with_error ("
inotify_read:
unexpected end of file");
+ reply_with_error ("unexpected end of file");
goto error;
}
goto error;
}
@@
-294,8
+303,7
@@
do_inotify_read (void)
free (ret);
return NULL;
#else
free (ret);
return NULL;
#else
- reply_with_error ("%s is not available", __func__);
- return NULL;
+ NOT_AVAILABLE (NULL);
#endif
}
#endif
}
@@
-306,7
+314,7
@@
do_inotify_files (void)
char **ret = NULL;
int size = 0, alloc = 0;
unsigned int i;
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];
guestfs_int_inotify_event_list *events;
char buf[PATH_MAX];
@@
-353,13
+361,12
@@
do_inotify_files (void)
if (len > 0 && buf[len-1] == '\n')
buf[len-1] = '\0';
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;
goto error;
- }
}
fclose (fp);
}
fclose (fp);
+ fp = NULL;
if (add_string (&ret, &size, &alloc, NULL) == -1)
goto error;
if (add_string (&ret, &size, &alloc, NULL) == -1)
goto error;
@@
-368,10
+375,12
@@
do_inotify_files (void)
return ret;
error:
return ret;
error:
+ if (fp != NULL)
+ fclose (fp);
+
unlink ("/tmp/inotify");
return NULL;
#else
unlink ("/tmp/inotify");
return NULL;
#else
- reply_with_error ("%s is not available", __func__);
- return NULL;
+ NOT_AVAILABLE (NULL);
#endif
}
#endif
}