From patchwork Mon Jun 27 09:41:53 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 9200227 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4716D60752 for ; Mon, 27 Jun 2016 09:50:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3688927BFC for ; Mon, 27 Jun 2016 09:50:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2AF601FF10; Mon, 27 Jun 2016 09:50:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 90CF61FF10 for ; Mon, 27 Jun 2016 09:50:56 +0000 (UTC) Received: from localhost ([::1]:57539 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHTBv-0003P6-M3 for patchwork-qemu-devel@patchwork.kernel.org; Mon, 27 Jun 2016 05:50:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33489) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHT3N-0008P6-0s for qemu-devel@nongnu.org; Mon, 27 Jun 2016 05:42:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHT3J-000544-QB for qemu-devel@nongnu.org; Mon, 27 Jun 2016 05:42:04 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:15951) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHT3J-00053t-Hk for qemu-devel@nongnu.org; Mon, 27 Jun 2016 05:42:01 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u5R9dJ1s018586 for ; Mon, 27 Jun 2016 05:42:01 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0a-001b2d01.pphosted.com with ESMTP id 23sp1ne21m-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 27 Jun 2016 05:42:00 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 27 Jun 2016 03:42:00 -0600 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 27 Jun 2016 03:41:58 -0600 X-IBM-Helo: d03dlp03.boulder.ibm.com X-IBM-MailFrom: groug@kaod.org Received: from b03cxnp08025.gho.boulder.ibm.com (b03cxnp08025.gho.boulder.ibm.com [9.17.130.17]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id 9C32619D801C; Mon, 27 Jun 2016 03:41:35 -0600 (MDT) Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u5R9fvTa46137482; Mon, 27 Jun 2016 02:41:57 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 542ACC6037; Mon, 27 Jun 2016 03:41:57 -0600 (MDT) Received: from bahia.lan (unknown [9.164.189.130]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP id 7089EC6042; Mon, 27 Jun 2016 03:41:55 -0600 (MDT) From: Greg Kurz To: qemu-devel@nongnu.org Date: Mon, 27 Jun 2016 11:41:53 +0200 In-Reply-To: <146702045511.5764.17551224268217330628.stgit@bahia.lan> References: <146702045511.5764.17551224268217330628.stgit@bahia.lan> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16062709-0004-0000-0000-00000FC7145D X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16062709-0005-0000-0000-000076897D41 Message-Id: <146702051386.5764.5880031092636948315.stgit@bahia.lan> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-06-27_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1606270110 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 07/13] 9p: introduce futimens file op X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eric Van Hensbergen , v9fs-developer@lists.sourceforge.net, "Aneesh Kumar K.V" , Greg Kurz Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP This allows futimens() in the guest to stay functional even if the file was unlinked. Signed-off-by: Greg Kurz --- fsdev/file-op-9p.h | 2 ++ hw/9pfs/9p-handle.c | 10 ++++++++++ hw/9pfs/9p-local.c | 10 ++++++++++ hw/9pfs/9p-proxy.c | 10 ++++++++++ hw/9pfs/9p-synth.c | 8 ++++++++ hw/9pfs/9p.c | 18 ++++++++++++++++-- hw/9pfs/cofs.c | 18 ++++++++++++++++++ hw/9pfs/coth.h | 1 + 8 files changed, 75 insertions(+), 2 deletions(-) diff --git a/fsdev/file-op-9p.h b/fsdev/file-op-9p.h index 930bcc623f8b..811ca234cf86 100644 --- a/fsdev/file-op-9p.h +++ b/fsdev/file-op-9p.h @@ -141,6 +141,8 @@ struct FileOperations V9fsPath *newdir, const char *new_name); int (*unlinkat)(FsContext *ctx, V9fsPath *dir, const char *name, int flags); int (*ftruncate)(FsContext *, int, V9fsFidOpenState *, off_t); + int (*futimens)(FsContext *, int, V9fsFidOpenState *, + const struct timespec *); void *opaque; }; diff --git a/hw/9pfs/9p-handle.c b/hw/9pfs/9p-handle.c index 197c2c7efbb5..382b4d57927a 100644 --- a/hw/9pfs/9p-handle.c +++ b/hw/9pfs/9p-handle.c @@ -400,6 +400,15 @@ static int handle_utimensat(FsContext *ctx, V9fsPath *fs_path, return ret; } +static int handle_futimens(FsContext *s, int fid_type, V9fsFidOpenState *fs, + const struct timespec *buf) +{ + int fd; + + fd = v9fs_get_fd_fid(fid_type, fs); + return qemu_futimens(fd, buf); +} + static int handle_remove(FsContext *ctx, const char *path) { errno = EOPNOTSUPP; @@ -706,4 +715,5 @@ FileOperations handle_ops = { .renameat = handle_renameat, .unlinkat = handle_unlinkat, .ftruncate = handle_ftruncate, + .futimens = handle_futimens, }; diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index b4c31c49da69..46ac7aab7c47 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -953,6 +953,15 @@ static int local_utimensat(FsContext *s, V9fsPath *fs_path, return ret; } +static int local_futimens(FsContext *s, int fid_type, V9fsFidOpenState *fs, + const struct timespec *buf) +{ + int fd; + + fd = v9fs_get_fd_fid(fid_type, fs); + return qemu_futimens(fd, buf); +} + static int local_remove(FsContext *ctx, const char *path) { int err; @@ -1290,4 +1299,5 @@ FileOperations local_ops = { .renameat = local_renameat, .unlinkat = local_unlinkat, .ftruncate = local_ftruncate, + .futimens = local_futimens, }; diff --git a/hw/9pfs/9p-proxy.c b/hw/9pfs/9p-proxy.c index 9abcc201bd67..cbc94b645852 100644 --- a/hw/9pfs/9p-proxy.c +++ b/hw/9pfs/9p-proxy.c @@ -923,6 +923,15 @@ static int proxy_utimensat(FsContext *s, V9fsPath *fs_path, return retval; } +static int proxy_futimens(FsContext *s, int fid_type, V9fsFidOpenState *fs, + const struct timespec *buf) +{ + int fd; + + fd = v9fs_get_fd_fid(fid_type, fs); + return qemu_futimens(fd, buf); +} + static int proxy_remove(FsContext *ctx, const char *path) { int retval; @@ -1221,4 +1230,5 @@ FileOperations proxy_ops = { .renameat = proxy_renameat, .unlinkat = proxy_unlinkat, .ftruncate = proxy_ftruncate, + .futimens = proxy_futimens, }; diff --git a/hw/9pfs/9p-synth.c b/hw/9pfs/9p-synth.c index 70c71ce305c9..c4770792a79f 100644 --- a/hw/9pfs/9p-synth.c +++ b/hw/9pfs/9p-synth.c @@ -412,6 +412,13 @@ static int synth_utimensat(FsContext *fs_ctx, V9fsPath *path, return 0; } +static int synth_futimens(FsContext *fs_ctx, int fid_type, V9fsFidOpenState *fs, + const struct timespec *buf) +{ + errno = EPERM; + return -1; +} + static int synth_remove(FsContext *ctx, const char *path) { errno = EPERM; @@ -574,4 +581,5 @@ FileOperations synth_ops = { .renameat = synth_renameat, .unlinkat = synth_unlinkat, .ftruncate = synth_ftruncate, + .futimens = synth_futimens, }; diff --git a/hw/9pfs/9p.c b/hw/9pfs/9p.c index 3aa4c8e22ed9..97dba6190809 100644 --- a/hw/9pfs/9p.c +++ b/hw/9pfs/9p.c @@ -1194,6 +1194,20 @@ static int v9fs_do_truncate(V9fsPDU *pdu, V9fsFidState *fidp, off_t size) return err; } +static int v9fs_do_utimens(V9fsPDU *pdu, V9fsFidState *fidp, + struct timespec times[2]) +{ + int err; + + if (fid_has_file(fidp)) { + err = v9fs_co_futimens(pdu, fidp, times); + } else { + err = v9fs_co_utimensat(pdu, &fidp->path, times); + } + + return err; +} + /* Attribute flags */ #define P9_ATTR_MODE (1 << 0) #define P9_ATTR_UID (1 << 1) @@ -1254,7 +1268,7 @@ static void v9fs_setattr(void *opaque) } else { times[1].tv_nsec = UTIME_OMIT; } - err = v9fs_co_utimensat(pdu, &fidp->path, times); + err = v9fs_do_utimens(pdu, fidp, times); if (err < 0) { goto out; } @@ -2749,7 +2763,7 @@ static void v9fs_wstat(void *opaque) } else { times[1].tv_nsec = UTIME_OMIT; } - err = v9fs_co_utimensat(pdu, &fidp->path, times); + err = v9fs_do_utimens(pdu, fidp, times); if (err < 0) { goto out; } diff --git a/hw/9pfs/cofs.c b/hw/9pfs/cofs.c index 969c24730cb0..1ed9c298f98d 100644 --- a/hw/9pfs/cofs.c +++ b/hw/9pfs/cofs.c @@ -133,6 +133,24 @@ int v9fs_co_utimensat(V9fsPDU *pdu, V9fsPath *path, return err; } +int v9fs_co_futimens(V9fsPDU *pdu, V9fsFidState *fidp, struct timespec times[2]) +{ + int err; + V9fsState *s = pdu->s; + + if (v9fs_request_cancelled(pdu)) { + return -EINTR; + } + v9fs_co_run_in_worker( + { + err = s->ops->futimens(&s->ctx, fidp->fid_type, &fidp->fs, times); + if (err < 0) { + err = -errno; + } + }); + return err; +} + int v9fs_co_chown(V9fsPDU *pdu, V9fsPath *path, uid_t uid, gid_t gid) { int err; diff --git a/hw/9pfs/coth.h b/hw/9pfs/coth.h index 4f493ad29ec4..c4e90059f00c 100644 --- a/hw/9pfs/coth.h +++ b/hw/9pfs/coth.h @@ -95,5 +95,6 @@ extern int v9fs_co_name_to_path(V9fsPDU *, V9fsPath *, extern int v9fs_co_st_gen(V9fsPDU *pdu, V9fsPath *path, mode_t, V9fsStatDotl *v9stat); extern int v9fs_co_ftruncate(V9fsPDU *, V9fsFidState *, off_t); +extern int v9fs_co_futimens(V9fsPDU *, V9fsFidState *, struct timespec [2]); #endif