* [Qemu-devel] [PATCH 1.0 0/2] Fix compilation of 9pfs on old systems
@ 2011-11-18 16:35 Paolo Bonzini
2011-11-18 16:35 ` [Qemu-devel] [PATCH 1.0 1/2] 9p: allow compiling the dummy virtio-9p-handle.c code on Linux Paolo Bonzini
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Paolo Bonzini @ 2011-11-18 16:35 UTC (permalink / raw)
To: qemu-devel; +Cc: erik.rull
Old systems do not have AT_REMOVEDIR, and 9pfs fails to compile
on them. Patch 2 fixes that, patch 1 actually let me test it
on Linux. :)
Probably the same push-down should be done also for open(2) flags,
for consistency. For example, some systems may not have O_DIRECTORY.
However, this would be a much larger work, so I'm sticking with the
easy bits for now.
Paolo Bonzini (2):
9p: allow compiling the dummy virtio-9p-handle.c code on Linux
9p: pass dotl flags to the unlinkat method
hw/9pfs/virtio-9p-handle.c | 15 +++++++++++++--
hw/9pfs/virtio-9p.c | 10 ----------
2 files changed, 13 insertions(+), 12 deletions(-)
--
1.7.7.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH 1.0 1/2] 9p: allow compiling the dummy virtio-9p-handle.c code on Linux
2011-11-18 16:35 [Qemu-devel] [PATCH 1.0 0/2] Fix compilation of 9pfs on old systems Paolo Bonzini
@ 2011-11-18 16:35 ` Paolo Bonzini
2011-11-18 16:35 ` [Qemu-devel] [PATCH 1.0 2/2] 9p: pass dotl flags to the unlinkat method Paolo Bonzini
2011-11-22 0:21 ` [Qemu-devel] [PATCH 1.0 0/2] Fix compilation of 9pfs on old systems Anthony Liguori
2 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2011-11-18 16:35 UTC (permalink / raw)
To: qemu-devel; +Cc: erik.rull
Avoid a conflict on the definition of struct file_handle by
using a replacement name.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/9pfs/virtio-9p-handle.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/hw/9pfs/virtio-9p-handle.c b/hw/9pfs/virtio-9p-handle.c
index 0a778b4..27889d8 100644
--- a/hw/9pfs/virtio-9p-handle.c
+++ b/hw/9pfs/virtio-9p-handle.c
@@ -58,11 +58,12 @@ static inline int open_by_handle(int mountfd, const char *fh, int flags)
}
#else
-struct file_handle {
+struct rpl_file_handle {
unsigned int handle_bytes;
int handle_type;
unsigned char handle[0];
};
+#define file_handle rpl_file_handle
#ifndef AT_EMPTY_PATH
#define AT_EMPTY_PATH 0x1000 /* Allow empty relative pathname */
--
1.7.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH 1.0 2/2] 9p: pass dotl flags to the unlinkat method
2011-11-18 16:35 [Qemu-devel] [PATCH 1.0 0/2] Fix compilation of 9pfs on old systems Paolo Bonzini
2011-11-18 16:35 ` [Qemu-devel] [PATCH 1.0 1/2] 9p: allow compiling the dummy virtio-9p-handle.c code on Linux Paolo Bonzini
@ 2011-11-18 16:35 ` Paolo Bonzini
2011-11-22 0:21 ` [Qemu-devel] [PATCH 1.0 0/2] Fix compilation of 9pfs on old systems Anthony Liguori
2 siblings, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2011-11-18 16:35 UTC (permalink / raw)
To: qemu-devel; +Cc: erik.rull
AT_REMOVEDIR is not defined on all systems. Pass the raw flags from the
9p protocol, which are always there.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/9pfs/virtio-9p-handle.c | 12 +++++++++++-
hw/9pfs/virtio-9p.c | 10 ----------
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/hw/9pfs/virtio-9p-handle.c b/hw/9pfs/virtio-9p-handle.c
index 27889d8..7644ae5 100644
--- a/hw/9pfs/virtio-9p-handle.c
+++ b/hw/9pfs/virtio-9p-handle.c
@@ -65,6 +65,9 @@ struct rpl_file_handle {
};
#define file_handle rpl_file_handle
+#ifndef AT_REMOVEDIR
+#define AT_REMOVEDIR 0x200
+#endif
#ifndef AT_EMPTY_PATH
#define AT_EMPTY_PATH 0x1000 /* Allow empty relative pathname */
#endif
@@ -575,13 +578,20 @@ static int handle_unlinkat(FsContext *ctx, V9fsPath *dir,
{
int dirfd, ret;
struct handle_data *data = (struct handle_data *)ctx->private;
+ int rflags;
dirfd = open_by_handle(data->mountfd, dir->data, O_PATH);
if (dirfd < 0) {
return dirfd;
}
- ret = unlinkat(dirfd, name, flags);
+ rflags = 0;
+ if (flags & P9_DOTL_AT_REMOVEDIR) {
+ rflags |= AT_REMOVEDIR;
+ }
+
+ ret = unlinkat(dirfd, name, rflags);
+
close(dirfd);
return ret;
}
diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c
index 01cf337..1b2fc5d 100644
--- a/hw/9pfs/virtio-9p.c
+++ b/hw/9pfs/virtio-9p.c
@@ -74,15 +74,6 @@ static int omode_to_uflags(int8_t mode)
return ret;
}
-static int dotl_to_at_flags(int flags)
-{
- int rflags = 0;
- if (flags & P9_DOTL_AT_REMOVEDIR) {
- rflags |= AT_REMOVEDIR;
- }
- return rflags;
-}
-
struct dotl_openflag_map {
int dotl_flag;
int open_flag;
@@ -2444,7 +2435,6 @@ static void v9fs_unlinkat(void *opaque)
V9fsPDU *pdu = opaque;
pdu_unmarshal(pdu, offset, "dsd", &dfid, &name, &flags);
- flags = dotl_to_at_flags(flags);
dfidp = get_fid(pdu, dfid);
if (dfidp == NULL) {
--
1.7.7.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH 1.0 0/2] Fix compilation of 9pfs on old systems
2011-11-18 16:35 [Qemu-devel] [PATCH 1.0 0/2] Fix compilation of 9pfs on old systems Paolo Bonzini
2011-11-18 16:35 ` [Qemu-devel] [PATCH 1.0 1/2] 9p: allow compiling the dummy virtio-9p-handle.c code on Linux Paolo Bonzini
2011-11-18 16:35 ` [Qemu-devel] [PATCH 1.0 2/2] 9p: pass dotl flags to the unlinkat method Paolo Bonzini
@ 2011-11-22 0:21 ` Anthony Liguori
2 siblings, 0 replies; 4+ messages in thread
From: Anthony Liguori @ 2011-11-22 0:21 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: erik.rull, qemu-devel
On 11/18/2011 10:35 AM, Paolo Bonzini wrote:
> Old systems do not have AT_REMOVEDIR, and 9pfs fails to compile
> on them. Patch 2 fixes that, patch 1 actually let me test it
> on Linux. :)
>
> Probably the same push-down should be done also for open(2) flags,
> for consistency. For example, some systems may not have O_DIRECTORY.
> However, this would be a much larger work, so I'm sticking with the
> easy bits for now.
Applied. Thanks.
Regards,
Anthony Liguori
>
> Paolo Bonzini (2):
> 9p: allow compiling the dummy virtio-9p-handle.c code on Linux
> 9p: pass dotl flags to the unlinkat method
>
> hw/9pfs/virtio-9p-handle.c | 15 +++++++++++++--
> hw/9pfs/virtio-9p.c | 10 ----------
> 2 files changed, 13 insertions(+), 12 deletions(-)
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-11-22 0:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-18 16:35 [Qemu-devel] [PATCH 1.0 0/2] Fix compilation of 9pfs on old systems Paolo Bonzini
2011-11-18 16:35 ` [Qemu-devel] [PATCH 1.0 1/2] 9p: allow compiling the dummy virtio-9p-handle.c code on Linux Paolo Bonzini
2011-11-18 16:35 ` [Qemu-devel] [PATCH 1.0 2/2] 9p: pass dotl flags to the unlinkat method Paolo Bonzini
2011-11-22 0:21 ` [Qemu-devel] [PATCH 1.0 0/2] Fix compilation of 9pfs on old systems Anthony Liguori
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).