From nobody Sat May 18 17:34:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1603286805; cv=none; d=zohomail.com; s=zohoarc; b=nlC/dvQ6dLkFSMDIKY19iaAy2M2B4cZnVxnGMNabZMPmRm9//NxkYxvMZvoALxucSQAzaLK8jOazHMU3vPSFzp+Zng1sVA3yJAC8VnpFa74V3xP+vZ9oXWbpreNuVCFZzvsnoZcaKsvsmE2K4EDmFYFs0nb606Q+MO5thFIu9no= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603286805; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=jPv90ogvE1yLkYJEbd3gMSVSQi2C/uVPumjs570j7TA=; b=PwY+XFo9qT2As0DE+1d2JJD0ly6L/Y8mAn4P3iu/nnxYEX171MneAcNPN8P7xIabJISNqy0LZ395hvWwPRn/GsmEtKyWez5jqL2tWJYSm2KY1SnGZDRDFSg2Sa6FlzAh7ctsNMxRVdZ7hU6WLxOAKAqHCAkGOgioAKTyBdwKqAE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603286805049883.6405698966032; Wed, 21 Oct 2020 06:26:45 -0700 (PDT) Received: from localhost ([::1]:39976 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVE8a-0007Su-AQ for importer@patchew.org; Wed, 21 Oct 2020 09:26:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59822) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <4d7275b2363f122438a443ce079cbb355285e9d6@lizzy.crudebyte.com>) id 1kVE50-0002li-7n for qemu-devel@nongnu.org; Wed, 21 Oct 2020 09:23:03 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:56297) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <4d7275b2363f122438a443ce079cbb355285e9d6@lizzy.crudebyte.com>) id 1kVE4w-0003UE-TV for qemu-devel@nongnu.org; Wed, 21 Oct 2020 09:23:01 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=jPv90ogvE1yLkYJEbd3gMSVSQi2C/uVPumjs570j7TA=; b=QIIxR zdFM+boVEyJSeqc1NulY3RUlGNir0cgUUgSuzXwVVPiFtRV9XgOKSm2hrxwJL/FIxM23Oa+rnE45P glmuhuANWGQmGVuWRiqXQmOhe2hLQqWiqVp7YpqB9jliZ4ekq7fEekrnfTa0q5/eutK5WnQoeS1pm LtV5F6i4QYSXI2RUfNguy2nxIkSw8iJ0I31nNQ3r/5D9m73IUiMZxj3Enog2JiotmH6F3ddOZh3zr pjlnBCCY29iBiuAiYvq+UNhp8U84PE3h3v4F+DspJbpfFwUty0WrbFp7a9E4G6h2ajeoQWhXc6A/D IS/UovEd2PZvXCql+/m7bv7Ooux1w==; Message-Id: <4d7275b2363f122438a443ce079cbb355285e9d6.1603285620.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 21 Oct 2020 14:06:53 +0200 Subject: [PATCH v2 1/8] tests/9pfs: simplify do_mkdir() To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=4d7275b2363f122438a443ce079cbb355285e9d6@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 09:21:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Split out walking a directory path to a separate new utility function do_walk() and use that function in do_mkdir(). The code difference saved this way is not much, but we'll use that new do_walk() function in the upcoming patches, so it will avoid quite some code duplication after all. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- tests/qtest/virtio-9p-test.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 2ea555fa04..21807037df 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -583,6 +583,23 @@ static void do_version(QVirtio9P *v9p) g_free(server_version); } =20 +/* utility function: walk to requested dir and return fid for that dir */ +static uint32_t do_walk(QVirtio9P *v9p, const char *path) +{ + char **wnames; + P9Req *req; + const uint32_t fid =3D genfid(); + + int nwnames =3D split(path, "/", &wnames); + + req =3D v9fs_twalk(v9p, 0, fid, nwnames, wnames, 0); + v9fs_req_wait_for_reply(req, NULL); + v9fs_rwalk(req, NULL, NULL); + + split_free(&wnames); + return fid; +} + static void fs_version(void *obj, void *data, QGuestAllocator *t_alloc) { alloc =3D t_alloc; @@ -974,23 +991,17 @@ static void fs_flush_ignored(void *obj, void *data, Q= GuestAllocator *t_alloc) =20 static void do_mkdir(QVirtio9P *v9p, const char *path, const char *cname) { - char **wnames; char *const name =3D g_strdup(cname); + uint32_t fid; P9Req *req; - const uint32_t fid =3D genfid(); =20 - int nwnames =3D split(path, "/", &wnames); - - req =3D v9fs_twalk(v9p, 0, fid, nwnames, wnames, 0); - v9fs_req_wait_for_reply(req, NULL); - v9fs_rwalk(req, NULL, NULL); + fid =3D do_walk(v9p, path); =20 req =3D v9fs_tmkdir(v9p, fid, name, 0750, 0, 0); v9fs_req_wait_for_reply(req, NULL); v9fs_rmkdir(req, NULL); =20 g_free(name); - split_free(&wnames); } =20 static void fs_readdir_split_128(void *obj, void *data, --=20 2.20.1 From nobody Sat May 18 17:34:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1603286660; cv=none; d=zohomail.com; s=zohoarc; b=UjpQgFCxGejnBTHcFjiWrX/P5CDIuQNF7+nDkvRGUIFSXDO9WTru8rjnzKNQIIvCP8HTuTq4anfBlqKxhUy/xmU+FKfdv4rJ5Njcc2wG92YJR7AAJ5TtrmE27qwxOdt+HWq2RUZwsQPX/jiMiOHydtb/8yqG07GYKU8+v8108oc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603286660; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=+sqFbrtyOtaobi6Og+lZZDKAY/uMSaJyf2gBFTvGVcE=; b=WxiRNyZmvg/Ep7hm58yvVpr84xHui9qzPoa1WecZqU2Jslz8dybR2U513fv9CpoL8kjk3UH85UHHWBTpca0Pak3efBfeXFAL716DTrc3jyE+0+jKDvFPQPS3tjOt7gKe0WZNE2SKqgrofrhP5DFeXX/VOQ/y3S/sQlW4GLBeiao= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603286660706784.4373678916016; Wed, 21 Oct 2020 06:24:20 -0700 (PDT) Received: from localhost ([::1]:33106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVE6F-0004Rq-W2 for importer@patchew.org; Wed, 21 Oct 2020 09:24:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59848) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3c7c65b476ba44bea6afd0b378b5287e1c671a32@lizzy.crudebyte.com>) id 1kVE55-0002qq-S8 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 09:23:08 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:51943) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <3c7c65b476ba44bea6afd0b378b5287e1c671a32@lizzy.crudebyte.com>) id 1kVE53-0003Ut-Hr for qemu-devel@nongnu.org; Wed, 21 Oct 2020 09:23:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=+sqFbrtyOtaobi6Og+lZZDKAY/uMSaJyf2gBFTvGVcE=; b=n9DsV WH9tRBxfIbMZfTZnuE7XT0VbYzxmBZ/RCUf8Vozd3ILg/oMfigQvocmTmWYO8zX7FmWxcTrtBlBRh yp4KYqprdvK6xVLBI9lr5gjc9Jdp8JD8oaZombN55APA0U6QwTihZUBpKQn6BjIKHYlFXdhKULglD 7dhhVGph7PkyiUs60TzOuzU1OjyAauGcUpmlDsDUKGRe2TJzCyFg7ASdwR0sW7GofOdxsfHMJWO+H xOlymX9AbRAZ2PjVytrkNn2Q9zEEwbgUik9RqNUR+j+kSO2u4EGEEkBcigSKifPa4mE+FF06TU7Yy H6OUZ2cKtTCsg7c7J526V4o4WqYaQ==; Message-Id: <3c7c65b476ba44bea6afd0b378b5287e1c671a32.1603285620.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 21 Oct 2020 14:17:01 +0200 Subject: [PATCH v2 2/8] tests/9pfs: add local Tunlinkat directory test To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=3c7c65b476ba44bea6afd0b378b5287e1c671a32@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 09:21:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This test case uses a Tunlinkat 9p request with flag AT_REMOVEDIR (see 'man 2 unlink') to remove a directory from host's test directory. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- tests/qtest/virtio-9p-test.c | 71 ++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 21807037df..abd7e44648 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -258,6 +258,7 @@ static const char *rmessage_name(uint8_t id) id =3D=3D P9_RLOPEN ? "RLOPEN" : id =3D=3D P9_RWRITE ? "RWRITE" : id =3D=3D P9_RMKDIR ? "RMKDIR" : + id =3D=3D P9_RUNLINKAT ? "RUNLINKAT" : id =3D=3D P9_RFLUSH ? "RFLUSH" : id =3D=3D P9_RREADDIR ? "READDIR" : ""; @@ -693,6 +694,33 @@ static void v9fs_rmkdir(P9Req *req, v9fs_qid *qid) v9fs_req_free(req); } =20 +/* size[4] Tunlinkat tag[2] dirfd[4] name[s] flags[4] */ +static P9Req *v9fs_tunlinkat(QVirtio9P *v9p, uint32_t dirfd, const char *n= ame, + uint32_t flags, uint16_t tag) +{ + P9Req *req; + + uint32_t body_size =3D 4 + 4; + uint16_t string_size =3D v9fs_string_size(name); + + g_assert_cmpint(body_size, <=3D, UINT32_MAX - string_size); + body_size +=3D string_size; + + req =3D v9fs_req_init(v9p, body_size, P9_TUNLINKAT, tag); + v9fs_uint32_write(req, dirfd); + v9fs_string_write(req, name); + v9fs_uint32_write(req, flags); + v9fs_req_send(req); + return req; +} + +/* size[4] Runlinkat tag[2] */ +static void v9fs_runlinkat(P9Req *req) +{ + v9fs_req_recv(req, P9_RUNLINKAT); + v9fs_req_free(req); +} + /* basic readdir test where reply fits into a single response message */ static void fs_readdir(void *obj, void *data, QGuestAllocator *t_alloc) { @@ -1004,6 +1032,22 @@ static void do_mkdir(QVirtio9P *v9p, const char *pat= h, const char *cname) g_free(name); } =20 +static void do_unlinkat(QVirtio9P *v9p, const char *atpath, const char *rp= ath, + uint32_t flags) +{ + char *const name =3D g_strdup(rpath); + uint32_t fid; + P9Req *req; + + fid =3D do_walk(v9p, atpath); + + req =3D v9fs_tunlinkat(v9p, fid, name, flags, 0); + v9fs_req_wait_for_reply(req, NULL); + v9fs_runlinkat(req); + + g_free(name); +} + static void fs_readdir_split_128(void *obj, void *data, QGuestAllocator *t_alloc) { @@ -1050,6 +1094,32 @@ static void fs_create_dir(void *obj, void *data, QGu= estAllocator *t_alloc) g_free(root_path); } =20 +static void fs_unlinkat_dir(void *obj, void *data, QGuestAllocator *t_allo= c) +{ + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; + struct stat st; + char *root_path =3D virtio_9p_test_path(""); + char *new_dir =3D virtio_9p_test_path("02"); + + g_assert(root_path !=3D NULL); + + do_attach(v9p); + do_mkdir(v9p, "/", "02"); + + /* check if created directory really exists now ... */ + g_assert(stat(new_dir, &st) =3D=3D 0); + /* ... and is actually a directory */ + g_assert((st.st_mode & S_IFMT) =3D=3D S_IFDIR); + + do_unlinkat(v9p, "/", "02", AT_REMOVEDIR); + /* directory should be gone now */ + g_assert(stat(new_dir, &st) !=3D 0); + + g_free(new_dir); + g_free(root_path); +} + static void *assign_9p_local_driver(GString *cmd_line, void *arg) { virtio_9p_assign_local_driver(cmd_line, "security_model=3Dmapped-xattr= "); @@ -1090,6 +1160,7 @@ static void register_virtio_9p_test(void) opts.before =3D assign_9p_local_driver; qos_add_test("local/config", "virtio-9p", pci_config, &opts); qos_add_test("local/create_dir", "virtio-9p", fs_create_dir, &opts); + qos_add_test("local/unlinkat_dir", "virtio-9p", fs_unlinkat_dir, &opts= ); } =20 libqos_init(register_virtio_9p_test); --=20 2.20.1 From nobody Sat May 18 17:34:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1603286938; cv=none; d=zohomail.com; s=zohoarc; b=JZrFSWx5Du6FeEQNLJnWVw24fYXDh61gE0BUgMqt9ytaUcmPGDJ+FncJa75m+6Oh8mPncZMnI42qZnaAfCVV+YXTR8RK+Pi7GpyLM2v0DJTDsGme4dCjd7PGQ8UQB33H+zWXtciJJoDPd7LrZS3Ey1A3PxQuttev2z8n2h6zWiQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603286938; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=NHpXsqZHPtmkbVtbJwJ2brzkHthp/Oq+ATzx+WXR8DI=; b=hMPfJ41i1QZEHeEBm+TpjMQexV+MPQ+3dseWFsYtcHPy9RtyV7eJAqK6tew5zRh/sz71joLoI6oHp10gFBCCdTbkIPG04ZjXYhdm1zN6HklXdj+Nb/3RYa7pRtncT/0ELtaatbKbT69tnwFUxTQQQpBDUnybZZS4Yde9Y3JPBO0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603286938190848.7618845083554; Wed, 21 Oct 2020 06:28:58 -0700 (PDT) Received: from localhost ([::1]:46440 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVEAi-0001lU-TN for importer@patchew.org; Wed, 21 Oct 2020 09:28:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59888) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <269cae0c00af941a3a4ae78f1e319f93462a7eb4@lizzy.crudebyte.com>) id 1kVE5C-00032t-Kz for qemu-devel@nongnu.org; Wed, 21 Oct 2020 09:23:14 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:49119) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <269cae0c00af941a3a4ae78f1e319f93462a7eb4@lizzy.crudebyte.com>) id 1kVE5A-0003WZ-Nh for qemu-devel@nongnu.org; Wed, 21 Oct 2020 09:23:14 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=NHpXsqZHPtmkbVtbJwJ2brzkHthp/Oq+ATzx+WXR8DI=; b=Sjm/V TbG8zuPRUEzuvypJK5HiuCqhX4VDgN/ukP6aU+qjom3P/w1NKEYDnbxHXdfXoVnrkQafZzT5UywHS 4UY2miZyLxw5n1iaj8WQ68DlY+eBTmeo4hFVLJmV5mX4bq/u2NMSLCoevEgzHH7TkHc2ykgYlpZcR CDt43uEOg5htHsTHjrVhcRGWMmMYveXW1Ks0Qc8PpZ071TwTthaNcHvNXs4Go9nY/9KelKWTwHEZT oWKMnvHQu6I6MbEZ8IBRiEZqFM62hP0jIr61LYpNSEFjkfwlYGRfG/GXplVUG4qnNcVcEFxfnGZNF Imb/lq5DdKObgrOUjQYK7dCCvmkUw==; Message-Id: <269cae0c00af941a3a4ae78f1e319f93462a7eb4.1603285620.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 21 Oct 2020 14:25:33 +0200 Subject: [PATCH v2 3/8] tests/9pfs: add local Tlcreate test To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=269cae0c00af941a3a4ae78f1e319f93462a7eb4@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 09:21:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This test case uses a Tlcreate 9p request to create a regular file inside host's test directory. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- tests/qtest/virtio-9p-test.c | 77 ++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index abd7e44648..c030bc2a6c 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -258,6 +258,7 @@ static const char *rmessage_name(uint8_t id) id =3D=3D P9_RLOPEN ? "RLOPEN" : id =3D=3D P9_RWRITE ? "RWRITE" : id =3D=3D P9_RMKDIR ? "RMKDIR" : + id =3D=3D P9_RLCREATE ? "RLCREATE" : id =3D=3D P9_RUNLINKAT ? "RUNLINKAT" : id =3D=3D P9_RFLUSH ? "RFLUSH" : id =3D=3D P9_RREADDIR ? "READDIR" : @@ -694,6 +695,44 @@ static void v9fs_rmkdir(P9Req *req, v9fs_qid *qid) v9fs_req_free(req); } =20 +/* size[4] Tlcreate tag[2] fid[4] name[s] flags[4] mode[4] gid[4] */ +static P9Req *v9fs_tlcreate(QVirtio9P *v9p, uint32_t fid, const char *name, + uint32_t flags, uint32_t mode, uint32_t gid, + uint16_t tag) +{ + P9Req *req; + + uint32_t body_size =3D 4 + 4 + 4 + 4; + uint16_t string_size =3D v9fs_string_size(name); + + g_assert_cmpint(body_size, <=3D, UINT32_MAX - string_size); + body_size +=3D string_size; + + req =3D v9fs_req_init(v9p, body_size, P9_TLCREATE, tag); + v9fs_uint32_write(req, fid); + v9fs_string_write(req, name); + v9fs_uint32_write(req, flags); + v9fs_uint32_write(req, mode); + v9fs_uint32_write(req, gid); + v9fs_req_send(req); + return req; +} + +/* size[4] Rlcreate tag[2] qid[13] iounit[4] */ +static void v9fs_rlcreate(P9Req *req, v9fs_qid *qid, uint32_t *iounit) +{ + v9fs_req_recv(req, P9_RLCREATE); + if (qid) { + v9fs_memread(req, qid, 13); + } else { + v9fs_memskip(req, 13); + } + if (iounit) { + v9fs_uint32_read(req, iounit); + } + v9fs_req_free(req); +} + /* size[4] Tunlinkat tag[2] dirfd[4] name[s] flags[4] */ static P9Req *v9fs_tunlinkat(QVirtio9P *v9p, uint32_t dirfd, const char *n= ame, uint32_t flags, uint16_t tag) @@ -1032,6 +1071,24 @@ static void do_mkdir(QVirtio9P *v9p, const char *pat= h, const char *cname) g_free(name); } =20 +/* create a regular file with Tlcreate and return file's fid */ +static uint32_t do_lcreate(QVirtio9P *v9p, const char *path, + const char *cname) +{ + char *const name =3D g_strdup(cname); + uint32_t fid; + P9Req *req; + + fid =3D do_walk(v9p, path); + + req =3D v9fs_tlcreate(v9p, fid, name, 0, 0750, 0, 0); + v9fs_req_wait_for_reply(req, NULL); + v9fs_rlcreate(req, NULL, NULL); + + g_free(name); + return fid; +} + static void do_unlinkat(QVirtio9P *v9p, const char *atpath, const char *rp= ath, uint32_t flags) { @@ -1120,6 +1177,25 @@ static void fs_unlinkat_dir(void *obj, void *data, Q= GuestAllocator *t_alloc) g_free(root_path); } =20 +static void fs_create_file(void *obj, void *data, QGuestAllocator *t_alloc) +{ + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; + struct stat st; + char *new_file =3D virtio_9p_test_path("03/1st_file"); + + do_attach(v9p); + do_mkdir(v9p, "/", "03"); + do_lcreate(v9p, "03", "1st_file"); + + /* check if created file exists now ... */ + g_assert(stat(new_file, &st) =3D=3D 0); + /* ... and is a regular file */ + g_assert((st.st_mode & S_IFMT) =3D=3D S_IFREG); + + g_free(new_file); +} + static void *assign_9p_local_driver(GString *cmd_line, void *arg) { virtio_9p_assign_local_driver(cmd_line, "security_model=3Dmapped-xattr= "); @@ -1161,6 +1237,7 @@ static void register_virtio_9p_test(void) qos_add_test("local/config", "virtio-9p", pci_config, &opts); qos_add_test("local/create_dir", "virtio-9p", fs_create_dir, &opts); qos_add_test("local/unlinkat_dir", "virtio-9p", fs_unlinkat_dir, &opts= ); + qos_add_test("local/create_file", "virtio-9p", fs_create_file, &opts); } =20 libqos_init(register_virtio_9p_test); --=20 2.20.1 From nobody Sat May 18 17:34:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1603286686; cv=none; d=zohomail.com; s=zohoarc; b=kI3E0y1tlGl4lMlJ5sUKRMpaLLHkx3tTPVIdia0v4CIGMrDv/haYNgcBoTlH9yHZ0/CndiZE1+jNx3lTCmYCrGi6JYhsn/6D8zKZNz0l/FgZxpryzbrR7P89dVr8U2BaGnIq8qJjj0yqtsnh04lIxH6FngK5vYXjHCk76qfr5X8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603286686; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=W7iYAoERptWBWAbC1eeAwkwTLmJrWJ4gAtPJthWD3vY=; b=i1oye+y41yZMart7lvdZZrBw2MoAuNwEINxZ9LyIUqE0ze54knuh975HRrW1cIxCJsLDGTcHVTl9bpy9MtXm/7E/860PSojRjDpyRrJixw5H4taYeKf8wywtO1ARUHxlZ3gb5w+HI2YRMPb6pxT+iwOBxN5Xfrn1lTHnU8bnayM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 160328668665751.95401201431889; Wed, 21 Oct 2020 06:24:46 -0700 (PDT) Received: from localhost ([::1]:34152 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVE6f-0004tN-TB for importer@patchew.org; Wed, 21 Oct 2020 09:24:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59942) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <4eabeed7f662721dd5664cb77fe36ea0aa08b1ec@lizzy.crudebyte.com>) id 1kVE5H-0003DH-Ew for qemu-devel@nongnu.org; Wed, 21 Oct 2020 09:23:19 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:40655) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <4eabeed7f662721dd5664cb77fe36ea0aa08b1ec@lizzy.crudebyte.com>) id 1kVE5F-0003XE-Tt for qemu-devel@nongnu.org; Wed, 21 Oct 2020 09:23:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=W7iYAoERptWBWAbC1eeAwkwTLmJrWJ4gAtPJthWD3vY=; b=S0WVf Fmjubi8f+tfSPPOmzd0WeUd/PRmU1ytGmeUbJxsFhe/1denWWkpLXxiN0dpzhi9uJ4YxGnnKMCSdx kr3a70l2qsEMWeeBht5Mftgodj+izmVQADrxQ6ZJcCD2qDKflWUCzrdEB21A7MPpT/fZ3R0aD6kDK PXq0MfwdtNbOicmnI+9uyH/qINxt3TsJIaPkE3wfwtK1tqZudyKPiV+W9Lu8ua/YVyklgY8uz97fU i54mvvO8lQO5aI1fpyF6LnZkpN1MzaC+re5w7ieUtaNDpXUy4WnvOzaIGyEZzZEo3j6YCtbBrYR4x kkmsYlOkjLjRgUFl+tIHhy8Ewnfww==; Message-Id: <4eabeed7f662721dd5664cb77fe36ea0aa08b1ec.1603285620.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 21 Oct 2020 14:28:37 +0200 Subject: [PATCH v2 4/8] tests/9pfs: add local Tunlinkat file test To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=4eabeed7f662721dd5664cb77fe36ea0aa08b1ec@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 09:21:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This test case uses a Tunlinkat request to remove a regular file using the 9pfs 'local' fs driver. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- tests/qtest/virtio-9p-test.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index c030bc2a6c..6b74a1fd7e 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -1196,6 +1196,29 @@ static void fs_create_file(void *obj, void *data, QG= uestAllocator *t_alloc) g_free(new_file); } =20 +static void fs_unlinkat_file(void *obj, void *data, QGuestAllocator *t_all= oc) +{ + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; + struct stat st; + char *new_file =3D virtio_9p_test_path("04/doa_file"); + + do_attach(v9p); + do_mkdir(v9p, "/", "04"); + do_lcreate(v9p, "04", "doa_file"); + + /* check if created file exists now ... */ + g_assert(stat(new_file, &st) =3D=3D 0); + /* ... and is a regular file */ + g_assert((st.st_mode & S_IFMT) =3D=3D S_IFREG); + + do_unlinkat(v9p, "04", "doa_file", 0); + /* file should be gone now */ + g_assert(stat(new_file, &st) !=3D 0); + + g_free(new_file); +} + static void *assign_9p_local_driver(GString *cmd_line, void *arg) { virtio_9p_assign_local_driver(cmd_line, "security_model=3Dmapped-xattr= "); @@ -1238,6 +1261,7 @@ static void register_virtio_9p_test(void) qos_add_test("local/create_dir", "virtio-9p", fs_create_dir, &opts); qos_add_test("local/unlinkat_dir", "virtio-9p", fs_unlinkat_dir, &opts= ); qos_add_test("local/create_file", "virtio-9p", fs_create_file, &opts); + qos_add_test("local/unlinkat_file", "virtio-9p", fs_unlinkat_file, &op= ts); } =20 libqos_init(register_virtio_9p_test); --=20 2.20.1 From nobody Sat May 18 17:34:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1603286776; cv=none; d=zohomail.com; s=zohoarc; b=nJNpSj3ug3Iju60zF9dRjC+1InhtLWZrIbX17G+ukfjfDqQrxiF0prfzsRByn6NcugSttjTk0vjp+dpISRWccvFXjgZpcZRXPZ9eTAbq8GrSNDVaLKfqu/dMIRXy4YLFzlyAuBDQulb9DIqqFyVeYuK9UEK/Kk5LHLA0au0pQAM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603286776; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=TMZVDqWymrBNxIM0hFUQWZ6jVyyA0ixYlY/+xniKl8c=; b=dZMS2u9n9GNvidcWLXubxUU5tq8ZAE+31uG4lXDbg5rTfjQsoMMTWFiAtQV/RLaZHswS6aPAG+GK1UIiwlODN/x4u6gPjn0f5EQ90efYiCkwY+Fp8QArOUZsIIxGYe3fZTXN+N2MlShi87uDALVyEInFHJy8CXFFO8nq12pXZzQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603286776988328.4019171365004; Wed, 21 Oct 2020 06:26:16 -0700 (PDT) Received: from localhost ([::1]:38290 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVE88-0006kl-Al for importer@patchew.org; Wed, 21 Oct 2020 09:26:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59982) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <84ac76937855bf441242372cc3e62df42f0a3dc4@lizzy.crudebyte.com>) id 1kVE5N-0003Td-TK for qemu-devel@nongnu.org; Wed, 21 Oct 2020 09:23:25 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:55907) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <84ac76937855bf441242372cc3e62df42f0a3dc4@lizzy.crudebyte.com>) id 1kVE5M-0003Xf-3W for qemu-devel@nongnu.org; Wed, 21 Oct 2020 09:23:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=TMZVDqWymrBNxIM0hFUQWZ6jVyyA0ixYlY/+xniKl8c=; b=pKGHs 1rXOzho8RKyslr5EEHYzejXovJ02jciHmYaV7Oz291Nzs6pE5KxLPWuGJOYzMs6QMP60UaMoIi2OL vtcxlYaZKSEFbFlZkrc5czjLcLB21qJ8HQmSUweXMUW+NRaUa+HSlEpjRXZRT+kN1ZzhGaCmNgu+c ki7fRW3eF5WD9rRZyAk+q9UiqZVdyNPImYA52Tr2oPVFiXYmjNjnw1cZtIT1ILR7IQUDC43nsWvAd LPVcRC6/hAY68zp7yIhRadGze4QV3W3TlDWWEBJFyI1gnK1jmZhO5jg5p3v2QuDJ6BO5upbTMv3tm 6rLd2I922bZ4O4KqCKn2F0fjchFng==; Message-Id: <84ac76937855bf441242372cc3e62df42f0a3dc4.1603285620.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 21 Oct 2020 14:33:34 +0200 Subject: [PATCH v2 5/8] tests/9pfs: add local Tsymlink test To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=84ac76937855bf441242372cc3e62df42f0a3dc4@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 09:21:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This test case uses a Tsymlink 9p request to create a symbolic link using the 9pfs 'local' fs driver. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- tests/qtest/virtio-9p-test.c | 77 ++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 6b74a1fd7e..0c11417236 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -259,6 +259,7 @@ static const char *rmessage_name(uint8_t id) id =3D=3D P9_RWRITE ? "RWRITE" : id =3D=3D P9_RMKDIR ? "RMKDIR" : id =3D=3D P9_RLCREATE ? "RLCREATE" : + id =3D=3D P9_RSYMLINK ? "RSYMLINK" : id =3D=3D P9_RUNLINKAT ? "RUNLINKAT" : id =3D=3D P9_RFLUSH ? "RFLUSH" : id =3D=3D P9_RREADDIR ? "READDIR" : @@ -733,6 +734,39 @@ static void v9fs_rlcreate(P9Req *req, v9fs_qid *qid, u= int32_t *iounit) v9fs_req_free(req); } =20 +/* size[4] Tsymlink tag[2] fid[4] name[s] symtgt[s] gid[4] */ +static P9Req *v9fs_tsymlink(QVirtio9P *v9p, uint32_t fid, const char *name, + const char *symtgt, uint32_t gid, uint16_t tag) +{ + P9Req *req; + + uint32_t body_size =3D 4 + 4; + uint16_t string_size =3D v9fs_string_size(name) + v9fs_string_size(sym= tgt); + + g_assert_cmpint(body_size, <=3D, UINT32_MAX - string_size); + body_size +=3D string_size; + + req =3D v9fs_req_init(v9p, body_size, P9_TSYMLINK, tag); + v9fs_uint32_write(req, fid); + v9fs_string_write(req, name); + v9fs_string_write(req, symtgt); + v9fs_uint32_write(req, gid); + v9fs_req_send(req); + return req; +} + +/* size[4] Rsymlink tag[2] qid[13] */ +static void v9fs_rsymlink(P9Req *req, v9fs_qid *qid) +{ + v9fs_req_recv(req, P9_RSYMLINK); + if (qid) { + v9fs_memread(req, qid, 13); + } else { + v9fs_memskip(req, 13); + } + v9fs_req_free(req); +} + /* size[4] Tunlinkat tag[2] dirfd[4] name[s] flags[4] */ static P9Req *v9fs_tunlinkat(QVirtio9P *v9p, uint32_t dirfd, const char *n= ame, uint32_t flags, uint16_t tag) @@ -1089,6 +1123,25 @@ static uint32_t do_lcreate(QVirtio9P *v9p, const cha= r *path, return fid; } =20 +/* create symlink named @a clink in directory @a path pointing to @a to */ +static void do_symlink(QVirtio9P *v9p, const char *path, const char *clink, + const char *to) +{ + char *const name =3D g_strdup(clink); + char *const dst =3D g_strdup(to); + uint32_t fid; + P9Req *req; + + fid =3D do_walk(v9p, path); + + req =3D v9fs_tsymlink(v9p, fid, name, dst, 0, 0); + v9fs_req_wait_for_reply(req, NULL); + v9fs_rsymlink(req, NULL); + + g_free(dst); + g_free(name); +} + static void do_unlinkat(QVirtio9P *v9p, const char *atpath, const char *rp= ath, uint32_t flags) { @@ -1219,6 +1272,29 @@ static void fs_unlinkat_file(void *obj, void *data, = QGuestAllocator *t_alloc) g_free(new_file); } =20 +static void fs_symlink_file(void *obj, void *data, QGuestAllocator *t_allo= c) +{ + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; + struct stat st; + char *real_file =3D virtio_9p_test_path("05/real_file"); + char *symlink_file =3D virtio_9p_test_path("05/symlink_file"); + + do_attach(v9p); + do_mkdir(v9p, "/", "05"); + do_lcreate(v9p, "05", "real_file"); + g_assert(stat(real_file, &st) =3D=3D 0); + g_assert((st.st_mode & S_IFMT) =3D=3D S_IFREG); + + do_symlink(v9p, "05", "symlink_file", "real_file"); + + /* check if created link exists now */ + g_assert(stat(symlink_file, &st) =3D=3D 0); + + g_free(symlink_file); + g_free(real_file); +} + static void *assign_9p_local_driver(GString *cmd_line, void *arg) { virtio_9p_assign_local_driver(cmd_line, "security_model=3Dmapped-xattr= "); @@ -1262,6 +1338,7 @@ static void register_virtio_9p_test(void) qos_add_test("local/unlinkat_dir", "virtio-9p", fs_unlinkat_dir, &opts= ); qos_add_test("local/create_file", "virtio-9p", fs_create_file, &opts); qos_add_test("local/unlinkat_file", "virtio-9p", fs_unlinkat_file, &op= ts); + qos_add_test("local/symlink_file", "virtio-9p", fs_symlink_file, &opts= ); } =20 libqos_init(register_virtio_9p_test); --=20 2.20.1 From nobody Sat May 18 17:34:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1603287106; cv=none; d=zohomail.com; s=zohoarc; b=DAEyskPFKaRbFWjXlXNExV0/68UKU4Kc3B6mH8QI+L1bP6phuKLbVVZbcbiRwijiBaD+OV1Dts8lza2l1y6Nv2PalYytlLVZfUCC4vvkm7QPy+mAIUWtnzup7wsljRFtTFbVNf48EL/52DbqFafgJn2OmMCl9kCNIluNMB9iJYM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603287106; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=eHyx/V4HzU5fYa1gYPVKbaHux4n2KtY/i+3287SEWRM=; b=iT85nhaqCPxsxN8W5d1hktHWqi/rt7RoJfN8dxWv22jNMjAFy/GHfeoP/BgApOm+uS/3e+m9xMxNXjmkvH/A77rhNUGDz6foAe8kYZnGyi9h8kUrVrh/4mv7shltf7rqDcmEcYbC4UAoujRRKqnmcyVahvqlOJwdRAvWBcsvGZI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603287106098601.8644259396236; Wed, 21 Oct 2020 06:31:46 -0700 (PDT) Received: from localhost ([::1]:53262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVEDR-000502-5v for importer@patchew.org; Wed, 21 Oct 2020 09:31:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60028) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVE5T-0003j4-UZ for qemu-devel@nongnu.org; Wed, 21 Oct 2020 09:23:31 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:48123) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVE5S-0003YG-2C for qemu-devel@nongnu.org; Wed, 21 Oct 2020 09:23:31 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=eHyx/V4HzU5fYa1gYPVKbaHux4n2KtY/i+3287SEWRM=; b=NtvBp H+x5Vwd6BcJZDwXZ2zN1Hiz64Xac4sqE/kp3BNcZ56j4kXtyjZi+FWm1+0FFe6HGGVaG67IV+RE0/ Q4TiMdemHa5snLdzOdWeQlm+lgfJUoMh8bTQ4HHW0dgOttw+4t3HYgcoYbt5UZHqxrZYpdSCF5LDF oIvu50n5YnmJpjxuXu6ePImh4b+FsF6izugsLRAwNukLcusHOvo9bjG5HBg5x/S/Qn7nAFbUGeKAW 6cJNz6eU1UgDG0NXRvyBz65ivLgFCilZ4wfpHWFkjmAcu3ZNTnCvzlJKRNqcUL5t5OeMOj+8RhZnT bIE3aTMOrerZwgxs8kZR1oh1S4umw==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 21 Oct 2020 14:36:23 +0200 Subject: [PATCH v2 6/8] tests/9pfs: add local Tunlinkat symlink test To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=a23cd4d2ab6d8d3048addab8cbf0416fe5ead43e@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 09:21:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This test case uses a Tunlinkat request to remove a symlink using the 9pfs 'local' fs driver. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- tests/qtest/virtio-9p-test.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 0c11417236..33cba24b18 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -1295,6 +1295,32 @@ static void fs_symlink_file(void *obj, void *data, Q= GuestAllocator *t_alloc) g_free(real_file); } =20 +static void fs_unlinkat_symlink(void *obj, void *data, + QGuestAllocator *t_alloc) +{ + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; + struct stat st; + char *real_file =3D virtio_9p_test_path("06/real_file"); + char *symlink_file =3D virtio_9p_test_path("06/symlink_file"); + + do_attach(v9p); + do_mkdir(v9p, "/", "06"); + do_lcreate(v9p, "06", "real_file"); + g_assert(stat(real_file, &st) =3D=3D 0); + g_assert((st.st_mode & S_IFMT) =3D=3D S_IFREG); + + do_symlink(v9p, "06", "symlink_file", "real_file"); + g_assert(stat(symlink_file, &st) =3D=3D 0); + + do_unlinkat(v9p, "06", "symlink_file", 0); + /* symlink should be gone now */ + g_assert(stat(symlink_file, &st) !=3D 0); + + g_free(symlink_file); + g_free(real_file); +} + static void *assign_9p_local_driver(GString *cmd_line, void *arg) { virtio_9p_assign_local_driver(cmd_line, "security_model=3Dmapped-xattr= "); @@ -1339,6 +1365,8 @@ static void register_virtio_9p_test(void) qos_add_test("local/create_file", "virtio-9p", fs_create_file, &opts); qos_add_test("local/unlinkat_file", "virtio-9p", fs_unlinkat_file, &op= ts); qos_add_test("local/symlink_file", "virtio-9p", fs_symlink_file, &opts= ); + qos_add_test("local/unlinkat_symlink", "virtio-9p", fs_unlinkat_symlin= k, + &opts); } =20 libqos_init(register_virtio_9p_test); --=20 2.20.1 From nobody Sat May 18 17:34:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1603286958; cv=none; d=zohomail.com; s=zohoarc; b=gf1BaIVWIW8Yrqgy04S8e+ghOU0iPAg1mEiVW05lcyH2am+NAMAOf4kJQ3FpoTZ5ZWWi8P8mKOvyMWmS+l2H9BFug6s4pAY4qCwhZdBo7AQclcz//46NCKq/7R/q1TCXjsd3m8C+wNnzVXmWkWLm3S0gG+At5mVeg+pKA/AFXqs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603286958; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=DmxaprmQliFXt3vNWXf9vmVSfTGO0c81/rVQ3TXHq94=; b=bndaASUZr/ct/XOCkXOfxsZnX9VuyD9st6/ZbRBMk7OMLyVHpvhPWj4cmoZfziANVtKxxbN6VFHRpooXM0fHGE28pkYr8kTi2gB5C4xBVMooaxKHn0kBfMJ3SD3StEye7Q3CA12mS1iDIdATIk/kSoiZ+4EYVWnWqUUlqob5t+M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603286958914371.467722485659; Wed, 21 Oct 2020 06:29:18 -0700 (PDT) Received: from localhost ([::1]:47218 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVEB3-0002FC-T9 for importer@patchew.org; Wed, 21 Oct 2020 09:29:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60128) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVE5b-00040e-59 for qemu-devel@nongnu.org; Wed, 21 Oct 2020 09:23:39 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:50157) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kVE5Z-0003YZ-9s for qemu-devel@nongnu.org; Wed, 21 Oct 2020 09:23:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=DmxaprmQliFXt3vNWXf9vmVSfTGO0c81/rVQ3TXHq94=; b=Xbc+C xuxoo5zkJaA38aMX5F6PrlIAHVarYzwqo1S7Tn5WmcC76Pe0BHVMmiEjYvw3ggUTz0qa3uCMfVI3T VtAP7hNralWFXZdM21xEO4UdXj/gZnC4LnxqSNTOq4MithSydNKTOwdIT/Id4cSZ+xZlcmqMxttb4 Y0Pp/8KhngNateKDrIdAkCQ7ubMuoDPICXkmR7FZmnNqueflYzNQvFWxdOAz++O/2vXdE+/Mr6jrP /1/ctkHQrvEjVmi2+JIw/SfBpXb2n1yENp8XP1pVsj2CAVM1QeijiOb3YJ+88Og7rxYDVoYeuuw4P JEyHKqdNXKxNEqT5iaMJwEgh+zR8Q==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 21 Oct 2020 14:51:09 +0200 Subject: [PATCH v2 7/8] tests/9pfs: add local Tlink test To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=f0d869770ad23ee5ce10f7da90fdb742cadcad72@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 09:21:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This test case uses a Tlink request to create a hard link to a regular file using the 9pfs 'local' fs driver. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- tests/qtest/virtio-9p-test.c | 71 ++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 33cba24b18..460fa49fe3 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -260,6 +260,7 @@ static const char *rmessage_name(uint8_t id) id =3D=3D P9_RMKDIR ? "RMKDIR" : id =3D=3D P9_RLCREATE ? "RLCREATE" : id =3D=3D P9_RSYMLINK ? "RSYMLINK" : + id =3D=3D P9_RLINK ? "RLINK" : id =3D=3D P9_RUNLINKAT ? "RUNLINKAT" : id =3D=3D P9_RFLUSH ? "RFLUSH" : id =3D=3D P9_RREADDIR ? "READDIR" : @@ -767,6 +768,33 @@ static void v9fs_rsymlink(P9Req *req, v9fs_qid *qid) v9fs_req_free(req); } =20 +/* size[4] Tlink tag[2] dfid[4] fid[4] name[s] */ +static P9Req *v9fs_tlink(QVirtio9P *v9p, uint32_t dfid, uint32_t fid, + const char *name, uint16_t tag) +{ + P9Req *req; + + uint32_t body_size =3D 4 + 4; + uint16_t string_size =3D v9fs_string_size(name); + + g_assert_cmpint(body_size, <=3D, UINT32_MAX - string_size); + body_size +=3D string_size; + + req =3D v9fs_req_init(v9p, body_size, P9_TLINK, tag); + v9fs_uint32_write(req, dfid); + v9fs_uint32_write(req, fid); + v9fs_string_write(req, name); + v9fs_req_send(req); + return req; +} + +/* size[4] Rlink tag[2] */ +static void v9fs_rlink(P9Req *req) +{ + v9fs_req_recv(req, P9_RLINK); + v9fs_req_free(req); +} + /* size[4] Tunlinkat tag[2] dirfd[4] name[s] flags[4] */ static P9Req *v9fs_tunlinkat(QVirtio9P *v9p, uint32_t dirfd, const char *n= ame, uint32_t flags, uint16_t tag) @@ -1142,6 +1170,21 @@ static void do_symlink(QVirtio9P *v9p, const char *p= ath, const char *clink, g_free(name); } =20 +/* create a hard link named @a clink in directory @a path pointing to @a t= o */ +static void do_hardlink(QVirtio9P *v9p, const char *path, const char *clin= k, + const char *to) +{ + uint32_t dfid, fid; + P9Req *req; + + dfid =3D do_walk(v9p, path); + fid =3D do_walk(v9p, to); + + req =3D v9fs_tlink(v9p, dfid, fid, clink, 0); + v9fs_req_wait_for_reply(req, NULL); + v9fs_rlink(req); +} + static void do_unlinkat(QVirtio9P *v9p, const char *atpath, const char *rp= ath, uint32_t flags) { @@ -1321,6 +1364,33 @@ static void fs_unlinkat_symlink(void *obj, void *dat= a, g_free(real_file); } =20 +static void fs_hardlink_file(void *obj, void *data, QGuestAllocator *t_all= oc) +{ + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; + struct stat st_real, st_link; + char *real_file =3D virtio_9p_test_path("07/real_file"); + char *hardlink_file =3D virtio_9p_test_path("07/hardlink_file"); + + do_attach(v9p); + do_mkdir(v9p, "/", "07"); + do_lcreate(v9p, "07", "real_file"); + g_assert(stat(real_file, &st_real) =3D=3D 0); + g_assert((st_real.st_mode & S_IFMT) =3D=3D S_IFREG); + + do_hardlink(v9p, "07", "hardlink_file", "07/real_file"); + + /* check if link exists now ... */ + g_assert(stat(hardlink_file, &st_link) =3D=3D 0); + /* ... and it's a hard link, right? */ + g_assert((st_link.st_mode & S_IFMT) =3D=3D S_IFREG); + g_assert(st_link.st_dev =3D=3D st_real.st_dev); + g_assert(st_link.st_ino =3D=3D st_real.st_ino); + + g_free(hardlink_file); + g_free(real_file); +} + static void *assign_9p_local_driver(GString *cmd_line, void *arg) { virtio_9p_assign_local_driver(cmd_line, "security_model=3Dmapped-xattr= "); @@ -1367,6 +1437,7 @@ static void register_virtio_9p_test(void) qos_add_test("local/symlink_file", "virtio-9p", fs_symlink_file, &opts= ); qos_add_test("local/unlinkat_symlink", "virtio-9p", fs_unlinkat_symlin= k, &opts); + qos_add_test("local/hardlink_file", "virtio-9p", fs_hardlink_file, &op= ts); } =20 libqos_init(register_virtio_9p_test); --=20 2.20.1 From nobody Sat May 18 17:34:40 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1603287121; cv=none; d=zohomail.com; s=zohoarc; b=T5gqZZFzOnSIIHWzC9Eg/DEPoHpedR82K06C1QbWfl1RLEzFiNTEp4POJJeZE47o2SRMti/gELz0wDcn1htc49PsD889Sq2iCb+CTcaZ+Bq8fVXec7WmmasCn+3L0QqgzUkskXWbQ7xjq1wD8R8adrOtTU02V2/5To5czWZzfTM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603287121; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=Akr9UuK1L3lZF7Xsio4Ln5H3B2b/JHGraEuk31vJZJw=; b=I+05wf5gBq5wDQdK0sUoyA855qB4eKgYP2HJyPfGVtv1Y7TVpkJUWIStF9soE9v/NYttRP5fcYZfagTPcUog2GKP0/ucVAfcpv+RY28nL2F37Uuhi9EFPw5Uk1Yq//2Fy1pEKBqMxmo4ktG7Bx8315TDFYftjYObocaApgz/K8w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603287121006149.47050061988216; Wed, 21 Oct 2020 06:32:01 -0700 (PDT) Received: from localhost ([::1]:53978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kVEDg-0005Jp-60 for importer@patchew.org; Wed, 21 Oct 2020 09:32:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:60182) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <9bec33a7d8f006ef8f80517985d0d6ac48650d53@lizzy.crudebyte.com>) id 1kVE5g-0004DS-Cp for qemu-devel@nongnu.org; Wed, 21 Oct 2020 09:23:44 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:47749) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <9bec33a7d8f006ef8f80517985d0d6ac48650d53@lizzy.crudebyte.com>) id 1kVE5e-0003Z0-NJ for qemu-devel@nongnu.org; Wed, 21 Oct 2020 09:23:44 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=Akr9UuK1L3lZF7Xsio4Ln5H3B2b/JHGraEuk31vJZJw=; b=QY17O RFPmIPvL7OCpaydWsKOCfUdarMtH3Icmf3GFi/8ElOP6vbmNCWyyvgqYjZJrp8z6KBDOzQwgK9tjz Gj1x6lc4XewN2NNaeYykAwQoJ6td9xoSXuiUtCsYfD67Su6nuU7B7Fp3O7Uk3HngTDS9dmsew0eOH 8xCDftr8dooj+v1REmHLqvS4UErkkDcf4MQW1iRURdIH3h/mtIzTIejxqtz7PaKanByiMr0QmejGx dWChq6npqhxt3Pn4VutQ/4LDWwWmPBS7AAonC7THHxDd0Tk7dN/lBUQuI74kATnQR/oHYbniAZIAK jTRkgboXdI2mnh+49XaP8Yms8GWjQ==; Message-Id: <9bec33a7d8f006ef8f80517985d0d6ac48650d53.1603285620.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Wed, 21 Oct 2020 14:55:46 +0200 Subject: [PATCH v2 8/8] tests/9pfs: add local Tunlinkat hard link test To: qemu-devel@nongnu.org Cc: Greg Kurz Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=91.194.90.13; envelope-from=9bec33a7d8f006ef8f80517985d0d6ac48650d53@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/21 09:21:52 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This test case uses a Tunlinkat request to remove a previously hard linked file by using the 9pfs 'local' fs driver. Signed-off-by: Christian Schoenebeck Reviewed-by: Greg Kurz --- tests/qtest/virtio-9p-test.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 460fa49fe3..23433913bb 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -1391,6 +1391,34 @@ static void fs_hardlink_file(void *obj, void *data, = QGuestAllocator *t_alloc) g_free(real_file); } =20 +static void fs_unlinkat_hardlink(void *obj, void *data, + QGuestAllocator *t_alloc) +{ + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; + struct stat st_real, st_link; + char *real_file =3D virtio_9p_test_path("08/real_file"); + char *hardlink_file =3D virtio_9p_test_path("08/hardlink_file"); + + do_attach(v9p); + do_mkdir(v9p, "/", "08"); + do_lcreate(v9p, "08", "real_file"); + g_assert(stat(real_file, &st_real) =3D=3D 0); + g_assert((st_real.st_mode & S_IFMT) =3D=3D S_IFREG); + + do_hardlink(v9p, "08", "hardlink_file", "08/real_file"); + g_assert(stat(hardlink_file, &st_link) =3D=3D 0); + + do_unlinkat(v9p, "08", "hardlink_file", 0); + /* symlink should be gone now */ + g_assert(stat(hardlink_file, &st_link) !=3D 0); + /* and old file should still exist */ + g_assert(stat(real_file, &st_real) =3D=3D 0); + + g_free(hardlink_file); + g_free(real_file); +} + static void *assign_9p_local_driver(GString *cmd_line, void *arg) { virtio_9p_assign_local_driver(cmd_line, "security_model=3Dmapped-xattr= "); @@ -1438,6 +1466,8 @@ static void register_virtio_9p_test(void) qos_add_test("local/unlinkat_symlink", "virtio-9p", fs_unlinkat_symlin= k, &opts); qos_add_test("local/hardlink_file", "virtio-9p", fs_hardlink_file, &op= ts); + qos_add_test("local/unlinkat_hardlink", "virtio-9p", fs_unlinkat_hardl= ink, + &opts); } =20 libqos_init(register_virtio_9p_test); --=20 2.20.1