From patchwork Mon Sep 5 16:18:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mohan Kumar M X-Patchwork-Id: 113395 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 92E03B6F7C for ; Tue, 6 Sep 2011 02:20:17 +1000 (EST) Received: from localhost ([::1]:37265 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R0buB-00005N-31 for incoming@patchwork.ozlabs.org; Mon, 05 Sep 2011 12:20:15 -0400 Received: from eggs.gnu.org ([140.186.70.92]:54787) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R0bsm-0005c7-5Q for qemu-devel@nongnu.org; Mon, 05 Sep 2011 12:18:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R0bsl-0005FU-28 for qemu-devel@nongnu.org; Mon, 05 Sep 2011 12:18:48 -0400 Received: from e28smtp06.in.ibm.com ([122.248.162.6]:53291) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R0bsk-0005D9-Du for qemu-devel@nongnu.org; Mon, 05 Sep 2011 12:18:47 -0400 Received: from d28relay03.in.ibm.com (d28relay03.in.ibm.com [9.184.220.60]) by e28smtp06.in.ibm.com (8.14.4/8.13.1) with ESMTP id p85GIea0030450 for ; Mon, 5 Sep 2011 21:48:40 +0530 Received: from d28av05.in.ibm.com (d28av05.in.ibm.com [9.184.220.67]) by d28relay03.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p85GIewK3948564 for ; Mon, 5 Sep 2011 21:48:40 +0530 Received: from d28av05.in.ibm.com (loopback [127.0.0.1]) by d28av05.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p85GIdEd029218 for ; Tue, 6 Sep 2011 02:18:40 +1000 Received: from explorer.in.ibm.com ([9.79.187.208]) by d28av05.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p85GIbFw029092; Tue, 6 Sep 2011 02:18:39 +1000 From: "M. Mohan Kumar" To: qemu-devel@nongnu.org, Anthony Liguori , Stefan Hajnoczi Date: Mon, 5 Sep 2011 21:48:32 +0530 Message-Id: <1315239516-4451-12-git-send-email-mohan@in.ibm.com> X-Mailer: git-send-email 1.7.6 In-Reply-To: <1315239516-4451-1-git-send-email-mohan@in.ibm.com> References: <1315239516-4451-1-git-send-email-mohan@in.ibm.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 122.248.162.6 Subject: [Qemu-devel] [PATCH V12 11/15] hw/9pfs: chmod in chroot environment X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add support to do chmod operation in chroot process. Signed-off-by: M. Mohan Kumar --- hw/9pfs/virtio-9p-chroot-worker.c | 18 ++++++++++++++++++ hw/9pfs/virtio-9p-chroot.h | 1 + hw/9pfs/virtio-9p-local.c | 5 +++-- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/hw/9pfs/virtio-9p-chroot-worker.c b/hw/9pfs/virtio-9p-chroot-worker.c index 9bb94f2..d297b50 100644 --- a/hw/9pfs/virtio-9p-chroot-worker.c +++ b/hw/9pfs/virtio-9p-chroot-worker.c @@ -198,6 +198,21 @@ static int chroot_do_rename(V9fsFileObjectRequest *request) return 0; } +/* + * Change permissions of a file object + * Returns 0 on success and -errno on failure + */ +static int chroot_do_chmod(V9fsFileObjectRequest *request) +{ + int retval; + + retval = chmod(request->path.path, request->data.mode); + if (retval < 0) { + return -errno; + } + return 0; +} + static void chroot_daemonize(int chroot_sock) { sigset_t sigset; @@ -307,6 +322,9 @@ int v9fs_chroot(FsContext *fs_ctx) case T_RENAME: retval = chroot_do_rename(&request); break; + case T_CHMOD: + retval = chroot_do_chmod(&request); + break; default: retval = -1; break; diff --git a/hw/9pfs/virtio-9p-chroot.h b/hw/9pfs/virtio-9p-chroot.h index fda60af..fc7a134 100644 --- a/hw/9pfs/virtio-9p-chroot.h +++ b/hw/9pfs/virtio-9p-chroot.h @@ -11,6 +11,7 @@ #define T_LINK 6 #define T_REMOVE 7 #define T_RENAME 8 +#define T_CHMOD 9 #define V9FS_FD_VALID INT_MAX diff --git a/hw/9pfs/virtio-9p-local.c b/hw/9pfs/virtio-9p-local.c index 68551e2..50e55ed 100644 --- a/hw/9pfs/virtio-9p-local.c +++ b/hw/9pfs/virtio-9p-local.c @@ -302,9 +302,10 @@ static int local_chmod(FsContext *fs_ctx, V9fsPath *fs_path, FsCred *credp) if (fs_ctx->fs_sm == SM_MAPPED) { return local_set_xattr(rpath(fs_ctx, path, buffer), credp); - } else if ((fs_ctx->fs_sm == SM_PASSTHROUGH) || - (fs_ctx->fs_sm == SM_NONE)) { + } else if (fs_ctx->fs_sm == SM_NONE) { return chmod(rpath(fs_ctx, path, buffer), credp->fc_mode); + } else { + return passthrough_request(fs_ctx, NULL, path, 0, credp, T_CHMOD); } return -1; }