summaryrefslogtreecommitdiffstats
path: root/daemon/inotify.c
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2009-11-20 14:10:06 +0000
committerRichard Jones <rjones@redhat.com>2009-11-20 18:03:36 +0000
commit2d9953097b6d3b71122d444a4550047e97aee009 (patch)
tree6737890f7e75cc83b635eccf2fb839b5cec3c616 /daemon/inotify.c
parent8fd7f255d611d2092a244c4a48c6b7b4529e98b1 (diff)
downloadlibguestfs-2d9953097b6d3b71122d444a4550047e97aee009.tar.gz
libguestfs-2d9953097b6d3b71122d444a4550047e97aee009.tar.xz
libguestfs-2d9953097b6d3b71122d444a4550047e97aee009.zip
availability: Add optional groups and implement guestfs_available call.
The current groups are defined very conservatively using the following criteria: (a) Would be impossible to implement on Windows because of sheer architectural differences (eg: mknod). (b) Already optional (augeas, inotify). (c) Not currently optional but not implemented on older RHEL and Debian releases (ntfs-3g.probe, scrub, zerofree). The optional groups I've defined according to these criteria are: . augeas . inotify . linuxfsuuid . linuxmodules . linuxxattrs . lvm2 . mknod . ntfs3g . scrub . selinux . zerofree (Note that these choices don't prevent us from adding more optional groups in future. On the other hand to avoid breaking ABIs we would not wish to change the above groups). The rest of this large commit is really just implementation: Each optional function is classified using Optional "group" flag in the generator. The daemon has to implement a function int optgroup_<name>_available (void); for each optional group. Some of these functions are fixed at compile time, and some do simple run-time tests. The do_available implementation in the daemon looks up the correct function in a table and runs it. We document the optional groups in the guestfs(3) man page. Also: I added a NOT_AVAILABLE macro in order to unify all the existing places where we had a message equivalent to "function __func__ is not available".
Diffstat (limited to 'daemon/inotify.c')
-rw-r--r--daemon/inotify.c31
1 files changed, 19 insertions, 12 deletions
diff --git a/daemon/inotify.c b/daemon/inotify.c
index 465d0b6e..24ce76e2 100644
--- a/daemon/inotify.c
+++ b/daemon/inotify.c
@@ -31,6 +31,7 @@
#include "../src/guestfs_protocol.h"
#include "daemon.h"
#include "actions.h"
+#include "optgroups.h"
#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;
+
+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. */
@@ -106,8 +119,7 @@ do_inotify_init (int max_events)
return 0;
#else
- reply_with_error ("%s is not available", __func__);
- return -1;
+ NOT_AVAILABLE (-1);
#endif
}
@@ -132,8 +144,7 @@ do_inotify_close (void)
return 0;
#else
- reply_with_error ("%s is not available", __func__);
- return -1;
+ NOT_AVAILABLE (-1);
#endif
}
@@ -161,8 +172,7 @@ do_inotify_add_watch (const char *path, int mask)
return r;
#else
- reply_with_error ("%s is not available", __func__);
- return -1;
+ NOT_AVAILABLE (-1);
#endif
}
@@ -179,8 +189,7 @@ do_inotify_rm_watch (int wd)
return 0;
#else
- reply_with_error ("%s is not available", __func__);
- return -1;
+ NOT_AVAILABLE (-1);
#endif
}
@@ -294,8 +303,7 @@ do_inotify_read (void)
free (ret);
return NULL;
#else
- reply_with_error ("%s is not available", __func__);
- return NULL;
+ NOT_AVAILABLE (NULL);
#endif
}
@@ -371,7 +379,6 @@ do_inotify_files (void)
unlink ("/tmp/inotify");
return NULL;
#else
- reply_with_error ("%s is not available", __func__);
- return NULL;
+ NOT_AVAILABLE (NULL);
#endif
}