From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: qemu-devel@nongnu.org
Cc: aliguori@us.ibm.com,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Subject: [Qemu-devel] [PATCH -V2 04/13] hw/9pfs: Fix build error on platform that don't support futimens
Date: Tue, 11 Oct 2011 16:11:36 +0530 [thread overview]
Message-ID: <1318329705-3179-5-git-send-email-aneesh.kumar@linux.vnet.ibm.com> (raw)
In-Reply-To: <1318329705-3179-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
Also don't do glibc version check to find handle support. Instead
do handle syscall support in configure.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
configure | 16 +++++++++++++
hw/9pfs/virtio-9p-handle.c | 52 ++++++++++++++++++++-----------------------
2 files changed, 40 insertions(+), 28 deletions(-)
diff --git a/configure b/configure
index 24b8df4..0216c53 100755
--- a/configure
+++ b/configure
@@ -2551,6 +2551,18 @@ EOF
fi
##########################################
+# check if we have open_by_handle_at
+
+open_by_hande_at=no
+cat > $TMPC << EOF
+#include <fcntl.h>
+int main(void) { struct file_handle *fh; open_by_handle_at(0, fh, 0); }
+EOF
+if compile_prog "" "" ; then
+ open_by_handle_at=yes
+fi
+
+##########################################
# End of CC checks
# After here, no more $cc or $ld runs
@@ -3029,6 +3041,10 @@ if test "$ucontext_coroutine" = "yes" ; then
echo "CONFIG_UCONTEXT_COROUTINE=y" >> $config_host_mak
fi
+if test "$open_by_handle_at" = "yes" ; then
+ echo "CONFIG_OPEN_BY_HANDLE=y" >> $config_host_mak
+fi
+
# USB host support
case "$usb" in
linux)
diff --git a/hw/9pfs/virtio-9p-handle.c b/hw/9pfs/virtio-9p-handle.c
index 441a37f..fbe3e62 100644
--- a/hw/9pfs/virtio-9p-handle.c
+++ b/hw/9pfs/virtio-9p-handle.c
@@ -27,13 +27,24 @@ struct handle_data {
int handle_bytes;
};
-#if __GLIBC__ <= 2 && __GLIBC_MINOR__ < 14
+#ifdef CONFIG_OPEN_BY_HANDLE
+static inline int name_to_handle(int dirfd, const char *name,
+ struct file_handle *fh, int *mnt_id, int flags)
+{
+ return name_to_handle_at(dirfd, name, fh, mnt_id, flags);
+}
+
+static inline int open_by_handle(int mountfd, const char *fh, int flags)
+{
+ return open_by_handle_at(mountfd, (struct file_handle *)fh, flags);
+}
+#else
+
struct file_handle {
- unsigned int handle_bytes;
- int handle_type;
- unsigned char handle[0];
+ unsigned int handle_bytes;
+ int handle_type;
+ unsigned char handle[0];
};
-#endif
#ifndef AT_EMPTY_PATH
#define AT_EMPTY_PATH 0x1000 /* Allow empty relative pathname */
@@ -42,28 +53,6 @@ struct file_handle {
#define O_PATH 010000000
#endif
-#ifndef __NR_name_to_handle_at
-#if defined(__i386__)
-#define __NR_name_to_handle_at 341
-#define __NR_open_by_handle_at 342
-#elif defined(__x86_64__)
-#define __NR_name_to_handle_at 303
-#define __NR_open_by_handle_at 304
-#endif
-#endif
-
-#ifdef __NR_name_to_handle_at
-static inline int name_to_handle(int dirfd, const char *name,
- struct file_handle *fh, int *mnt_id, int flags)
-{
- return syscall(__NR_name_to_handle_at, dirfd, name, fh, mnt_id, flags);
-}
-
-static inline int open_by_handle(int mountfd, const char *fh, int flags)
-{
- return syscall(__NR_open_by_handle_at, mountfd, fh, flags);
-}
-#else
static inline int name_to_handle(int dirfd, const char *name,
struct file_handle *fh, int *mnt_id, int flags)
{
@@ -376,7 +365,9 @@ static int handle_chown(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp)
static int handle_utimensat(FsContext *ctx, V9fsPath *fs_path,
const struct timespec *buf)
{
- int fd, ret;
+ int ret;
+#ifdef CONFIG_UTIMENSAT
+ int fd;
struct handle_data *data = (struct handle_data *)ctx->private;
fd = open_by_handle(data->mountfd, fs_path->data, O_NONBLOCK);
@@ -385,6 +376,10 @@ static int handle_utimensat(FsContext *ctx, V9fsPath *fs_path,
}
ret = futimens(fd, buf);
close(fd);
+#else
+ ret = -1;
+ errno = ENOSYS;
+#endif
return ret;
}
@@ -560,6 +555,7 @@ static int handle_init(FsContext *ctx)
int ret, mnt_id;
struct file_handle fh;
struct handle_data *data = g_malloc(sizeof(struct handle_data));
+
data->mountfd = open(ctx->fs_root, O_DIRECTORY);
if (data->mountfd < 0) {
ret = data->mountfd;
--
1.7.5.4
next prev parent reply other threads:[~2011-10-11 10:42 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-11 10:41 [Qemu-devel] [PATCH V2 00/13] VirtFS update Aneesh Kumar K.V
2011-10-11 10:41 ` [Qemu-devel] [PATCH -V2 01/13] hw/9pfs: Use ioeventfd for 9p Aneesh Kumar K.V
2011-10-11 10:41 ` [Qemu-devel] [PATCH -V2 02/13] hw/9pfs: Add new virtfs option cache=writethrough to skip host page cache Aneesh Kumar K.V
2011-10-11 10:41 ` [Qemu-devel] [PATCH -V2 03/13] qemu-options.hx: Update virtfs command documentation Aneesh Kumar K.V
2011-10-11 10:41 ` Aneesh Kumar K.V [this message]
2011-10-11 10:41 ` [Qemu-devel] [PATCH -V2 05/13] virtio-9p: Use 9P specific Lock constants Aneesh Kumar K.V
2011-10-11 10:41 ` [Qemu-devel] [PATCH -V2 06/13] hw/9pfs: Ensure an error is reported to user if 9pfs mount tag is too long Aneesh Kumar K.V
2011-10-11 10:41 ` [Qemu-devel] [PATCH -V2 07/13] hw/9pfs: Add open flag mapping Aneesh Kumar K.V
2011-10-11 10:41 ` [Qemu-devel] [PATCH -V2 08/13] hw/9pfs: Add st_gen support in getattr reply Aneesh Kumar K.V
2011-10-11 10:41 ` [Qemu-devel] [PATCH -V2 09/13] hw/9pfs: Add st_gen support for handle based fs driver Aneesh Kumar K.V
2011-10-11 10:41 ` [Qemu-devel] [PATCH -V2 10/13] hw/9pfs: Introduce tracing for 9p pdu handlers Aneesh Kumar K.V
2011-10-11 10:41 ` [Qemu-devel] [PATCH -V2 11/13] hw/9pfs: Remove virtio-9p-debug.* infra to be replaced by Qemu Tracing Aneesh Kumar K.V
2011-10-11 10:41 ` [Qemu-devel] [PATCH -V2 12/13] scripts: Simpletrace log analysis script for pretty-printing 9p log Aneesh Kumar K.V
2011-10-11 10:41 ` [Qemu-devel] [PATCH -V2 13/13] hw/9pfs: Use fs driver specific lstat Aneesh Kumar K.V
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1318329705-3179-5-git-send-email-aneesh.kumar@linux.vnet.ibm.com \
--to=aneesh.kumar@linux.vnet.ibm.com \
--cc=aliguori@us.ibm.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).