inotify: Make this optional on platforms that don't have this interface.
mknod, mkfifo etc.: Make these optional on non-Unix platforms.
readdir: If d_type field is missing on the platform, set the corresponding
field to 'u'.
stat: st_blocks and st_blksize are missing on non-Unix platforms, so
set these fields to -1 in the corresponding structures.
dnl Check support for 64 bit file offsets.
AC_SYS_LARGEFILE
+dnl Check if dirent (readdir) supports d_type member.
+AC_STRUCT_DIRENT_D_TYPE
+
+dnl Check if stat has the required fields.
+AC_STRUCT_ST_BLOCKS
+AC_CHECK_MEMBER([struct stat.st_blksize],[
+ AC_DEFINE([HAVE_STRUCT_STAT_ST_BLKSIZE],[1],[Define to 1 if 'st_blksize' is a member of 'struct stat'])])
+
dnl Check for Augeas (now optional).
AC_CHECK_LIB([augeas],[aug_match],[
LIBS="-laugeas $LIBS"
])
dnl Functions which may not be available in older distributions.
-AC_CHECK_FUNCS([futimens listxattr llistxattr getxattr lgetxattr setxattr lsetxattr removexattr lremovexattr inotify_init1])
+AC_CHECK_FUNCS([\
+ futimens \
+ getxattr \
+ inotify_init1 \
+ lgetxattr \
+ listxattr \
+ llistxattr \
+ lsetxattr \
+ lremovexattr \
+ mknod \
+ removexattr \
+ setxattr])
+
+dnl Headers.
+AC_CHECK_HEADERS([\
+ attr/xattr.h \
+ netdb.h \
+ printf.h \
+ sys/inotify.h \
+ sys/select.h \
+ sys/wait.h \
+ sys/xattr.h])
dnl For modified printf, we need glibc either (old-style)
dnl register_printf_function or (new-style) register_printf_specifier.
This means you either have a very old glibc (pre-2.0) or you
are using some other libc where this is not supported.])])])
-dnl Headers.
-AC_CHECK_HEADERS([attr/xattr.h sys/xattr.h])
-
dnl Produce output files.
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile lib/Makefile tests/Makefile])
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
+
+#ifdef HAVE_SYS_INOTIFY_H
#include <sys/inotify.h>
+#endif
#include "../src/guestfs_protocol.h"
#include "daemon.h"
#include "actions.h"
+#ifdef HAVE_SYS_INOTIFY_H
/* Currently open inotify handle, or -1 if not opened. */
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;
+#endif
/* Because inotify_init does NEED_ROOT, NEED_INOTIFY implies NEED_ROOT. */
#define NEED_INOTIFY(errcode) \
int
do_inotify_init (int max_events)
{
+#ifdef HAVE_SYS_INOTIFY_H
FILE *fp;
NEED_ROOT (return -1);
#endif
return 0;
+#else
+ reply_with_error ("%s is not available", __func__);
+ return -1;
+#endif
}
int
do_inotify_close (void)
{
+#ifdef HAVE_SYS_INOTIFY_H
NEED_INOTIFY (-1);
if (inotify_fd == -1) {
inotify_posn = 0;
return 0;
+#else
+ reply_with_error ("%s is not available", __func__);
+ return -1;
+#endif
}
int64_t
do_inotify_add_watch (const char *path, int mask)
{
+#ifdef HAVE_SYS_INOTIFY_H
int64_t r;
char *buf;
}
return r;
+#else
+ reply_with_error ("%s is not available", __func__);
+ return -1;
+#endif
}
int
do_inotify_rm_watch (int wd)
{
+#ifdef HAVE_SYS_INOTIFY_H
NEED_INOTIFY (-1);
if (inotify_rm_watch (inotify_fd, wd) == -1) {
}
return 0;
+#else
+ reply_with_error ("%s is not available", __func__);
+ return -1;
+#endif
}
guestfs_int_inotify_event_list *
do_inotify_read (void)
{
+#ifdef HAVE_SYS_INOTIFY_H
int space;
guestfs_int_inotify_event_list *ret;
xdr_free ((xdrproc_t) xdr_guestfs_int_inotify_event_list, (char *) ret);
free (ret);
return NULL;
+#else
+ reply_with_error ("%s is not available", __func__);
+ return NULL;
+#endif
}
char **
do_inotify_files (void)
{
+#ifdef HAVE_SYS_INOTIFY_H
char **ret = NULL;
int size = 0, alloc = 0;
unsigned int i;
error:
unlink ("/tmp/inotify");
return NULL;
+#else
+ reply_with_error ("%s is not available", __func__);
+ return NULL;
+#endif
}
int
do_mknod (int mode, int devmajor, int devminor, const char *path)
{
+#ifdef HAVE_MKNOD
int r;
CHROOT_IN;
}
return 0;
+#else
+ reply_with_error ("%s is not available", __func__);
+ return -1;
+#endif
}
int
ret->guestfs_int_dirent_list_val = p;
v.ino = d->d_ino;
+#ifdef HAVE_STRUCT_DIRENT_D_TYPE
switch (d->d_type) {
case DT_BLK: v.ftyp = 'b'; break;
case DT_CHR: v.ftyp = 'c'; break;
case DT_UNKNOWN: v.ftyp = 'u'; break;
default: v.ftyp = '?'; break;
}
+#else
+ v.ftyp = 'u';
+#endif
ret->guestfs_int_dirent_list_val[i] = v;
ret->gid = statbuf.st_gid;
ret->rdev = statbuf.st_rdev;
ret->size = statbuf.st_size;
+#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
ret->blksize = statbuf.st_blksize;
+#else
+ ret->blksize = -1;
+#endif
+#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
ret->blocks = statbuf.st_blocks;
+#else
+ ret->blocks = -1;
+#endif
ret->atime = statbuf.st_atime;
ret->mtime = statbuf.st_mtime;
ret->ctime = statbuf.st_ctime;
ret->gid = statbuf.st_gid;
ret->rdev = statbuf.st_rdev;
ret->size = statbuf.st_size;
+#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
ret->blksize = statbuf.st_blksize;
+#else
+ ret->blksize = -1;
+#endif
+#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
ret->blocks = statbuf.st_blocks;
+#else
+ ret->blocks = -1;
+#endif
ret->atime = statbuf.st_atime;
ret->mtime = statbuf.st_mtime;
ret->ctime = statbuf.st_ctime;
ret->guestfs_int_stat_list_val[i].gid = statbuf.st_gid;
ret->guestfs_int_stat_list_val[i].rdev = statbuf.st_rdev;
ret->guestfs_int_stat_list_val[i].size = statbuf.st_size;
+#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
ret->guestfs_int_stat_list_val[i].blksize = statbuf.st_blksize;
+#else
+ ret->guestfs_int_stat_list_val[i].blksize = -1;
+#endif
+#ifdef HAVE_STRUCT_STAT_ST_BLOCKS
ret->guestfs_int_stat_list_val[i].blocks = statbuf.st_blocks;
+#else
+ ret->guestfs_int_stat_list_val[i].blocks = -1;
+#endif
ret->guestfs_int_stat_list_val[i].atime = statbuf.st_atime;
ret->guestfs_int_stat_list_val[i].mtime = statbuf.st_mtime;
ret->guestfs_int_stat_list_val[i].ctime = statbuf.st_ctime;