45e84a0
From f03969b952bc2aaf9f4445b6da28aebb0a9abde5 Mon Sep 17 00:00:00 2001
45e84a0
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
45e84a0
Date: Sun, 4 Dec 2011 22:35:27 +0530
45e84a0
Subject: [PATCH 03/25] hw/9pfs: Improve portability to older systems
45e84a0
45e84a0
handle fs driver require a set of newly added syscalls. Don't
45e84a0
Compile handle FS driver if those syscalls are not available.
45e84a0
Instead of adding #ifdef for all those syscalls we check for
45e84a0
open by handle syscall. If that is available then rest of the
45e84a0
syscalls used by the driver should be available.
45e84a0
45e84a0
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
45e84a0
---
45e84a0
 Makefile.objs              |    4 ++--
45e84a0
 fsdev/qemu-fsdev.c         |    2 ++
45e84a0
 hw/9pfs/virtio-9p-handle.c |   33 ---------------------------------
45e84a0
 3 files changed, 4 insertions(+), 35 deletions(-)
45e84a0
45e84a0
diff --git a/Makefile.objs b/Makefile.objs
45e84a0
index d7a6539..3a699ee 100644
45e84a0
--- a/Makefile.objs
45e84a0
+++ b/Makefile.objs
45e84a0
@@ -310,8 +310,8 @@ hw-obj-$(CONFIG_SOUND) += $(sound-obj-y)
45e84a0
 9pfs-nested-$(CONFIG_VIRTFS) += virtio-9p-local.o virtio-9p-xattr.o
45e84a0
 9pfs-nested-$(CONFIG_VIRTFS) += virtio-9p-xattr-user.o virtio-9p-posix-acl.o
45e84a0
 9pfs-nested-$(CONFIG_VIRTFS) += virtio-9p-coth.o cofs.o codir.o cofile.o
45e84a0
-9pfs-nested-$(CONFIG_VIRTFS) += coxattr.o virtio-9p-handle.o
45e84a0
-9pfs-nested-$(CONFIG_VIRTFS) += virtio-9p-synth.o
45e84a0
+9pfs-nested-$(CONFIG_VIRTFS) += coxattr.o virtio-9p-synth.o
45e84a0
+9pfs-nested-$(CONFIG_OPEN_BY_HANDLE) +=  virtio-9p-handle.o
45e84a0
45e84a0
 hw-obj-$(CONFIG_REALLY_VIRTFS) += $(addprefix 9pfs/, $(9pfs-nested-y))
45e84a0
 $(addprefix 9pfs/, $(9pfs-nested-y)): QEMU_CFLAGS+=$(GLIB_CFLAGS)
45e84a0
diff --git a/fsdev/qemu-fsdev.c b/fsdev/qemu-fsdev.c
45e84a0
index 7fd2aa7..6684f7e 100644
45e84a0
--- a/fsdev/qemu-fsdev.c
45e84a0
+++ b/fsdev/qemu-fsdev.c
45e84a0
@@ -23,7 +23,9 @@ static QTAILQ_HEAD(FsDriverEntry_head, FsDriverListEntry) fsdriver_entries =
45e84a0
45e84a0
 static FsDriverTable FsDrivers[] = {
45e84a0
     { .name = "local", .ops = &local_ops},
45e84a0
+#ifdef CONFIG_OPEN_BY_HANDLE
45e84a0
     { .name = "handle", .ops = &handle_ops},
45e84a0
+#endif
45e84a0
     { .name = "synth", .ops = &synth_ops},
45e84a0
 };
45e84a0
45e84a0
diff --git a/hw/9pfs/virtio-9p-handle.c b/hw/9pfs/virtio-9p-handle.c
45e84a0
index 7644ae5..a62f690 100644
45e84a0
--- a/hw/9pfs/virtio-9p-handle.c
45e84a0
+++ b/hw/9pfs/virtio-9p-handle.c
45e84a0
@@ -45,7 +45,6 @@ struct handle_data {
45e84a0
     int handle_bytes;
45e84a0
 };
45e84a0
45e84a0
-#ifdef CONFIG_OPEN_BY_HANDLE
45e84a0
 static inline int name_to_handle(int dirfd, const char *name,
45e84a0
                                  struct file_handle *fh, int *mnt_id, int flags)
45e84a0
 {
45e84a0
@@ -56,38 +55,6 @@ static inline int open_by_handle(int mountfd, const char *fh, int flags)
45e84a0
 {
45e84a0
     return open_by_handle_at(mountfd, (struct file_handle *)fh, flags);
45e84a0
 }
45e84a0
-#else
45e84a0
-
45e84a0
-struct rpl_file_handle {
45e84a0
-    unsigned int handle_bytes;
45e84a0
-    int handle_type;
45e84a0
-    unsigned char handle[0];
45e84a0
-};
45e84a0
-#define file_handle rpl_file_handle
45e84a0
-
45e84a0
-#ifndef AT_REMOVEDIR
45e84a0
-#define AT_REMOVEDIR    0x200
45e84a0
-#endif
45e84a0
-#ifndef AT_EMPTY_PATH
45e84a0
-#define AT_EMPTY_PATH   0x1000  /* Allow empty relative pathname */
45e84a0
-#endif
45e84a0
-#ifndef O_PATH
45e84a0
-#define O_PATH    010000000
45e84a0
-#endif
45e84a0
-
45e84a0
-static inline int name_to_handle(int dirfd, const char *name,
45e84a0
-                                 struct file_handle *fh, int *mnt_id, int flags)
45e84a0
-{
45e84a0
-    errno = ENOSYS;
45e84a0
-    return -1;
45e84a0
-}
45e84a0
-
45e84a0
-static inline int open_by_handle(int mountfd, const char *fh, int flags)
45e84a0
-{
45e84a0
-    errno = ENOSYS;
45e84a0
-    return -1;
45e84a0
-}
45e84a0
-#endif
45e84a0
45e84a0
 static int handle_update_file_cred(int dirfd, const char *name, FsCred *credp)
45e84a0
 {
45e84a0
-- 
45e84a0
1.7.7.5
45e84a0