From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:52978) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RRRPw-0004xk-7A for qemu-devel@nongnu.org; Fri, 18 Nov 2011 11:35:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RRRPv-0002b8-1D for qemu-devel@nongnu.org; Fri, 18 Nov 2011 11:35:56 -0500 Received: from mail-vw0-f45.google.com ([209.85.212.45]:53218) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RRRPu-0002aw-UZ for qemu-devel@nongnu.org; Fri, 18 Nov 2011 11:35:54 -0500 Received: by vbbfr13 with SMTP id fr13so326888vbb.4 for ; Fri, 18 Nov 2011 08:35:54 -0800 (PST) Sender: Paolo Bonzini From: Paolo Bonzini Date: Fri, 18 Nov 2011 17:35:38 +0100 Message-Id: <1321634138-24687-3-git-send-email-pbonzini@redhat.com> In-Reply-To: <1321634138-24687-1-git-send-email-pbonzini@redhat.com> References: <1321634138-24687-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH 1.0 2/2] 9p: pass dotl flags to the unlinkat method List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: erik.rull@rdsoftware.de 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 --- 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