From nobody Sat May 18 19:12:41 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=1603150844; cv=none; d=zohomail.com; s=zohoarc; b=PkHYCFBOg/Flei7VT6sTgSVywnMJvDT3o22bWoTxOLTMOfXzzCjto+lUoIqZC79xOZyLKOQszkA1e9CGlTXxcBn/IiSbhcvd1PSvyBN6+74BoHDG0nzmzUNNaOhYOxEUEY+Yl13CTD76WuXUCXU7XBY2pUfMSTWP51cfVYayFg4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603150844; 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=cnu0mo5+5Umg2MICUQzzLjXUPHcM5xBEoZQ/ZXahtCs=; b=R2qRLWSze7NmYZ3RNzPByGD4H44i+16Aoo8sbNA08XK4Kz7WpO3Mv9YaAHnl497cRsHjOQ+oQ4f9hzCWEWiqTq1rdJh+O73bLtyZawmWAiuoG0qv8ecEUtnNvIo7S7Dt0KPj2mMRUyluBLn69vEATYjPfN1CEjFP06D4UswELR8= 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 1603150843874361.77671695728895; Mon, 19 Oct 2020 16:40:43 -0700 (PDT) Received: from localhost ([::1]:39106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUele-00083h-Kn for importer@patchew.org; Mon, 19 Oct 2020 19:40:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47642) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <03b427019be98d12761924f1e6132eefc82c80ec@lizzy.crudebyte.com>) id 1kUejd-0006f0-LD for qemu-devel@nongnu.org; Mon, 19 Oct 2020 19:38:39 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:46091) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <03b427019be98d12761924f1e6132eefc82c80ec@lizzy.crudebyte.com>) id 1kUejY-0002Oq-Co for qemu-devel@nongnu.org; Mon, 19 Oct 2020 19:38:37 -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=cnu0mo5+5Umg2MICUQzzLjXUPHcM5xBEoZQ/ZXahtCs=; b=L1VB/ 3/34mTBmMzzVfnJuoCMUT7tJ1lBewxwkczffWoTxs55pFGJMe10kLP8TEvdMKBzgAGi6A+db/zzxx ofkPi1MU9EKMkc7Jb6B3PmAweKdvUX7tZ3q+ajIQ+S+y0xtm4nq8MhoV9AkF4kQp/nXAb4A3XuWWN qSbpqT6MiAyJu7O1b5pB6KIZtAQhmWyEADU3u0+O55vOHcZ6hV3iC7yVF9QzdgNjQYe+aNkZ1viZc Fp6TmzZ34fKs3Nvdxw13bakSe8ED1xptfOS3IetfphILgvqRYrUVSqd+KKHYWOnS+/s9s2Caccb/E dTXNGWENTqxi0RG7aLWVqAgu8Ibfw==; Message-Id: <03b427019be98d12761924f1e6132eefc82c80ec.1603149434.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 20 Oct 2020 01:13:23 +0200 Subject: [PATCH 1/8] tests/9pfs: simplify fs_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=03b427019be98d12761924f1e6132eefc82c80ec@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/19 19:37:26 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 fs_walk_fid() and use that function in fs_mkdir(). The code difference saved this way is not much, but we'll use that new fs_walk_fid() function in the upcoming patches, so it will avoid quite some code duplication after all. Signed-off-by: Christian Schoenebeck --- tests/qtest/virtio-9p-test.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index c15908f27b..dc724bbb1e 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -967,13 +967,12 @@ static void fs_flush_ignored(void *obj, void *data, Q= GuestAllocator *t_alloc) g_free(wnames[0]); } =20 -static void fs_mkdir(void *obj, void *data, QGuestAllocator *t_alloc, - const char *path, const char *cname) +/* utility function: walk to requested dir and return fid for that dir */ +static uint32_t fs_walk_fid(void *obj, void *data, QGuestAllocator *t_allo= c, + const char *path) { QVirtio9P *v9p =3D obj; - alloc =3D t_alloc; char **wnames; - char *const name =3D g_strdup(cname); P9Req *req; const uint32_t fid =3D genfid(); =20 @@ -983,12 +982,26 @@ static void fs_mkdir(void *obj, void *data, QGuestAll= ocator *t_alloc, v9fs_req_wait_for_reply(req, NULL); v9fs_rwalk(req, NULL, NULL); =20 + split_free(&wnames); + return fid; +} + +static void fs_mkdir(void *obj, void *data, QGuestAllocator *t_alloc, + const char *path, const char *cname) +{ + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; + char *const name =3D g_strdup(cname); + uint32_t fid; + P9Req *req; + + fid =3D fs_walk_fid(v9p, data, t_alloc, path); + 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 19:12:41 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=1603150845; cv=none; d=zohomail.com; s=zohoarc; b=CNwlBheYcZz7bhHpz+GbU76D78O+f8i4oMH5bYZlmyYeEmH6oXG5AKppoquJBX3yZ+H/CfsnA9jXlovaP+DaodQFKz5LuU72RN8Ul7dfJvGLfPnkmzSUSL94HSfZQ72dJ4jpNoFC3w6Nbi+igEVFsWIXBPSHoEUSBWEzGnDuT5Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603150845; 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=H3glx/McXEtcE4BZrJ1LIdOSYG5JKITjfdQJ79RoGRk=; b=Caei4NhM/w4CnHVPgsWrE26Cx3dnvVP69NWtGOcGLO8xmUsGgv7zO+nYXDN+IDfL9iUv2WyBXQ1Q+v8Lb2lkG44XHF/64X5TlQGCXcvYcVwIBdL5rnKsRg1e2OIdCJe1PMGH4BHqcOz6f4dHKp2uYxgR3x+sH77UzAoug76LUfw= 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 1603150845049774.622800338971; Mon, 19 Oct 2020 16:40:45 -0700 (PDT) Received: from localhost ([::1]:39226 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUelf-00086Z-Uf for importer@patchew.org; Mon, 19 Oct 2020 19:40:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47682) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUejf-0006fK-Jh for qemu-devel@nongnu.org; Mon, 19 Oct 2020 19:38:40 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:59157) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUejd-0002Pe-NM for qemu-devel@nongnu.org; Mon, 19 Oct 2020 19:38:39 -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=H3glx/McXEtcE4BZrJ1LIdOSYG5JKITjfdQJ79RoGRk=; b=aNLDa ItpfZnCkWeHR3ZCa4uuHZCFsqektzZFjz0gbGixVkW7Sv8OxdGkTWYsJgsuDO+LkNIIcsn544p8sQ QWFwvwqbVQRJ0Plqfdy/yj9dqpC5Y3+l8xPMkCStdYz6kRJuA3yxqY009F9iBMHCVGWyLR6HTT1lV u2MME24U7TgdI/JNi9uOMwOSORZu/KjXNFh1I7o79EJE+4HG6mC8rdx0jUZYmcMha1uDjQWGbBRFn yX32qn/rTJPRKEgESYE/EahHdvvcRrLQUq6bm/wFZfsAlIE52GxFee0mFarrwXD1u6YE6Eb7h6lVM YA+Xex24AFnBZtCIhCaQi+T58dJ1A==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 20 Oct 2020 01:13:23 +0200 Subject: [PATCH 2/8] tests/9pfs: add local unlinkat 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=a42df8544e913b8c0bf1702d0788724d79103110@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/19 19:37:26 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 --- tests/qtest/virtio-9p-test.c | 72 ++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index dc724bbb1e..990d074d33 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" : ""; @@ -668,6 +669,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,24 @@ static void fs_mkdir(void *obj, void *data, QGuestAl= locator *t_alloc, g_free(name); } =20 +static void fs_unlinkat(void *obj, void *data, QGuestAllocator *t_alloc, + const char *atpath, const char *rpath, uint32_t fl= ags) +{ + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; + char *const name =3D g_strdup(rpath); + uint32_t fid; + P9Req *req; + + fid =3D fs_walk_fid(v9p, data, t_alloc, 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) { @@ -1046,6 +1092,31 @@ 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; + 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); + + fs_attach(v9p, NULL, t_alloc); + fs_mkdir(v9p, data, t_alloc, "/", "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); + + fs_unlinkat(v9p, data, t_alloc, "/", "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= "); @@ -1086,6 +1157,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 19:12:41 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=1603151031; cv=none; d=zohomail.com; s=zohoarc; b=ch9ORuAtz1RgC5YLyIBbxK0LThsh8GrDL8FuqjQylST57vC80K/brUFInQtqFaXAV2ThnFWvYEmaq13dVQoMUE4qFu/OBaR6soZP17BX5DlGNYF+pdcxdygp9KIb3vXfppUBGhoLyLTkXhykPBMPmtq/XAmNL7DZliXhgJc+1c4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603151031; 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=in3U1t/MFXBXTZQt4whAHkL0n/tjx73g1jNlbMqKveU=; b=amqxXYdpipxY1XUfzNsDD9pHqMY27tzkxsbBBSnGkeBh97vqYwU8xQikoSlVlbaicpG+OT6eH8tnafGoUyynd8OgMATw4+NGhGE9wSPNQjuQwKRpML9kHnbFz4nQOb5FwJ24JoGS3wRu0/xlA5V0Nf4wMQK+ParateZ+h2m6dUw= 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 1603151031977798.5406584507093; Mon, 19 Oct 2020 16:43:51 -0700 (PDT) Received: from localhost ([::1]:45748 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUeog-0002nj-U3 for importer@patchew.org; Mon, 19 Oct 2020 19:43:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47758) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUejm-0006ky-HH for qemu-devel@nongnu.org; Mon, 19 Oct 2020 19:38:46 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:41423) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUejk-0002Q9-Mt for qemu-devel@nongnu.org; Mon, 19 Oct 2020 19:38:46 -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=in3U1t/MFXBXTZQt4whAHkL0n/tjx73g1jNlbMqKveU=; b=nSuC/ f+wmCl5xAizLG4weEv0jBFBzH7j1aZvy9yI5+kNz4zSm+V2RglI7Ni5bReL2Re8XFI8zVJu/XrP5s aZP5tQQNbWJvkyuYt7BmaXKmoN6piAXJidOiRbOD8UieNxGmtNFHjURZkXqmpFyhmrYsL/7nwwnUL AdvgFcYregvLEp82vc9sU5gUPntfKjYho0WRaNARXU8GvxYFnYkzX/B9GDXYEWykESQvnCGI8Eo+R y9XK63IwGb86/90uR27DYuGAbZTDvguECWTLTDtiIigrnkwrEerBXYKUI72c6tpUvueTTRu+NtAt2 1B/Ddk6WJDs4VCRm5+nZ5vcZmwzIg==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 20 Oct 2020 01:13:24 +0200 Subject: [PATCH 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=fe723557735b19282e3c12f304a69a898d0a4819@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/19 19:37:26 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 --- tests/qtest/virtio-9p-test.c | 78 ++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 990d074d33..1b133f52bd 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" : @@ -669,6 +670,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,26 @@ static void fs_mkdir(void *obj, void *data, QGuestAl= locator *t_alloc, g_free(name); } =20 +/* create a regular file with Tlcreate and return file's fid */ +static uint32_t fs_lcreate(void *obj, void *data, QGuestAllocator *t_alloc, + const char *path, const char *cname) +{ + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; + char *const name =3D g_strdup(cname); + uint32_t fid; + P9Req *req; + + fid =3D fs_walk_fid(v9p, data, t_alloc, 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 fs_unlinkat(void *obj, void *data, QGuestAllocator *t_alloc, const char *atpath, const char *rpath, uint32_t fl= ags) { @@ -1117,6 +1176,24 @@ 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; + struct stat st; + char *new_file =3D virtio_9p_test_path("03/1st_file"); + + fs_attach(v9p, NULL, t_alloc); + fs_mkdir(v9p, data, t_alloc, "/", "03"); + fs_lcreate(v9p, data, t_alloc, "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= "); @@ -1158,6 +1235,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 19:12:41 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=1603151124; cv=none; d=zohomail.com; s=zohoarc; b=blcjJP3NySgCNLo/x1Qu191FdAEz/AkcRghUCxHuJtGWIzLa0p/zAF1A/Q0AY6/L4FB3t/vxAos3Zjp7hbOKZCKNgKxBPzloA7TM9Yod3hJwOm5mG/CUdA/dR99ocQBrXTkhOsDL1lDAo4NSpDSZWJHFelZpDrwr8/GWC5qVxUA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603151124; 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=6n/i/C1rDejh9fjH3REhKBGgVYhUsuDkA5GQDhv4UI0=; b=BNceUwCw8VqKWsO/GuOzI1OYatgnl/zi8pcUO5+SWvqX5MYZ+h8y2Rte1U8yNiTPpnxdTnb4llaYZj5P0wKJUTIFQrRZUlUb6TInB2RKl+xomSiONl7rXg1yZd15PZDYxtGPkt6qM+aQLxLQQiGE9PTldutSTp9f9pe8I1w2B7M= 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 1603151124766173.90254395596662; Mon, 19 Oct 2020 16:45:24 -0700 (PDT) Received: from localhost ([::1]:51252 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUeqB-0005An-6X for importer@patchew.org; Mon, 19 Oct 2020 19:45:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47820) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUejs-0006u2-Uu for qemu-devel@nongnu.org; Mon, 19 Oct 2020 19:38:52 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:39643) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUejr-0002QN-Dp for qemu-devel@nongnu.org; Mon, 19 Oct 2020 19:38:52 -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=6n/i/C1rDejh9fjH3REhKBGgVYhUsuDkA5GQDhv4UI0=; b=jRl4S oWPYaSBOfeJL5Lt00O+Vs8lAyFBfsHP2NlX/tC0AqpaZkGC9ViqodBbHje4KaMdWInhYnrviB/HA9 lcFznYPBkqHsJ/KeU5DC9DIUZuo3tX406+wqoZn1Bcbzlgo48qBSVDakk4bs6x6bLyhQtICgVwO6f scK3JxeWxDaHZNWuYecPfi1+zFCZ06zkKhHb/ydBwKpC2apCcLbCiLUHRHyfum7NQm7qtSK+TbGWG cC2XqPBurdyqnzNq7olqknCHuEq2QipJwaT0vy22rvPfSmEx0kurAsXEZYQmLdlf2VwD3uLKXBLH8 Yhf2C3NIFd2GhRZzUsg7M0EKeS0FA==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 20 Oct 2020 01:13:24 +0200 Subject: [PATCH 4/8] tests/9pfs: add local unlinkat 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=a4e89602a5afdfa882257ffb6490b8eaab1dfe66@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/19 19:37:26 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 --- tests/qtest/virtio-9p-test.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 1b133f52bd..06a9f10d34 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -1194,6 +1194,28 @@ 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; + struct stat st; + char *new_file =3D virtio_9p_test_path("04/doa_file"); + + fs_attach(v9p, NULL, t_alloc); + fs_mkdir(v9p, data, t_alloc, "/", "04"); + fs_lcreate(v9p, data, t_alloc, "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); + + fs_unlinkat(v9p, data, t_alloc, "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= "); @@ -1236,6 +1258,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 19:12:41 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=1603150855; cv=none; d=zohomail.com; s=zohoarc; b=XEWU5a3tCNt+q3S6gPOAycGb87toWjtmJYmxbDKT1LE51iSherc5IsMO1NG6X6v/axXYlXMoG75V5nT347oT2aRS4loL+focFhjKU/Z6JfM7+AdeTG+oTmRxfgkKnHaMMegfPqxbSsWqLw8iLwdZEyCS4ECows29EYMXXk5pDO8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603150855; 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=lWdkIddxkv3MEeZPJP/gDDmRIzmN1mXi+uEoCPz9hCU=; b=j3xnC8+O7DrVIPNurqnPhhL8ptNTTYOOP8TXE2cddruwAtHApvdI+/jbO5X5BwFki3WcrYbwlQ/NctcSB8U5Q3JCzT8W9fB+FwS70kSxXJ2qMxlpF0CkhoQAdEsHmYVgyXXPvNToxyuebGpCuGQNsRcFRiTALO3RuyYQ6xn+sx4= 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 1603150855705167.88081431235594; Mon, 19 Oct 2020 16:40:55 -0700 (PDT) Received: from localhost ([::1]:40092 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUelq-0008Th-L7 for importer@patchew.org; Mon, 19 Oct 2020 19:40:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47878) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUek0-0006xQ-5j for qemu-devel@nongnu.org; Mon, 19 Oct 2020 19:39:00 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:50695) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUejx-0002Qh-4Z for qemu-devel@nongnu.org; Mon, 19 Oct 2020 19:38:59 -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=lWdkIddxkv3MEeZPJP/gDDmRIzmN1mXi+uEoCPz9hCU=; b=er6Ua b8fd9yw2ui0XwgOJydXg3FeWKQw70j6yH3q9iYMMr2ytd+7R1NN4G+lRF3fxOEExYsOFdZqZsfwUs HxyTf1JK2tRUqmO0tIKnuyHguENPVKAMeEJPQlwub1ccvLTC5u/KyBKaF7aHNe5IU9NFhkvu3hDGf nvsd1/MLyHfTE1HhgO4CKMu1CHXtHI8ypEi+OipUK5/Yz4UGJgi3PoY2chys8loOySHW6rLIz0oGk axfTqXTZ7ouZVyBVL4mYZYUxXs+p3qHacpylu6r7aG90nOUVKP9+G2F3I3eo2DxJvTHLBpn+xdLtm ofLP5ONoQpx8erjX3qmEp6IsDNMyg==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 20 Oct 2020 01:13:24 +0200 Subject: [PATCH 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=a55f25360474fa2ad5a45803bc8952e4d9eef49b@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/19 19:37:26 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 --- tests/qtest/virtio-9p-test.c | 78 ++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 06a9f10d34..78f4ed7e5f 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" : @@ -708,6 +709,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) @@ -1091,6 +1125,27 @@ static uint32_t fs_lcreate(void *obj, void *data, QG= uestAllocator *t_alloc, return fid; } =20 +/* create symlink named @a clink in directory @a path pointing to @a to */ +static void fs_symlink(void *obj, void *data, QGuestAllocator *t_alloc, + const char *path, const char *clink, const char *to) +{ + QVirtio9P *v9p =3D obj; + alloc =3D t_alloc; + char *const name =3D g_strdup(clink); + char *const dst =3D g_strdup(to); + uint32_t fid; + P9Req *req; + + fid =3D fs_walk_fid(v9p, data, t_alloc, 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 fs_unlinkat(void *obj, void *data, QGuestAllocator *t_alloc, const char *atpath, const char *rpath, uint32_t fl= ags) { @@ -1216,6 +1271,28 @@ 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; + 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"); + + fs_attach(v9p, NULL, t_alloc); + fs_mkdir(v9p, data, t_alloc, "/", "05"); + fs_lcreate(v9p, data, t_alloc, "05", "real_file"); + g_assert(stat(real_file, &st) =3D=3D 0); + g_assert((st.st_mode & S_IFMT) =3D=3D S_IFREG); + + fs_symlink(v9p, data, t_alloc, "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= "); @@ -1259,6 +1336,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 19:12:41 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=1603151125; cv=none; d=zohomail.com; s=zohoarc; b=FuVXajk4kOo1WWiXFKC+g6Ru0nTYkrNVuBvgUP9xgfChlTP+OG6LJt7EP5bH7ewvYJwld2btHNHyGkTzy7VYCcWEG8mDmjgfC+fBKWy7YkPZljVBJbKNTiCHxlTqFQ7983848P8lfQ2WLJSPc8NxirHkLqxN8DAXx84O5kEC7Bo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603151125; 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=r/iJwChibh2f/TaLqYdY0eeLo2OoiLI8PniUVxzhabk=; b=b5N0HZCclVEbTxJCwXKfmHy2C/18NaT+wOeHY4OguSHodNIhzs5PFkwG4/aEiDYywjo+KSvpuy01ALof2Jt0EN5iP5+21WPydFa+XTiU9kLyC9Dh9cZHMgBg+3GABcU7yJJ4hfRiL2m/AkNjG6/Xbv8zxv7nZyHfCDVcIQkngMQ= 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 1603151125549501.41074617413074; Mon, 19 Oct 2020 16:45:25 -0700 (PDT) Received: from localhost ([::1]:51316 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUeqC-0005CQ-FD for importer@patchew.org; Mon, 19 Oct 2020 19:45:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47926) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUek6-0006zX-0j for qemu-devel@nongnu.org; Mon, 19 Oct 2020 19:39:06 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:44551) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUek3-0002SU-2F for qemu-devel@nongnu.org; Mon, 19 Oct 2020 19:39:05 -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=r/iJwChibh2f/TaLqYdY0eeLo2OoiLI8PniUVxzhabk=; b=C4J6V DAFKWRZ7hHdHhKRT3jE3c1sKNQOHM5RPFTaz5gIsmday8CrZUDKx+hIp0RBiTkNJ2jVSuPCw6cNE0 jy+T7KddU4tWWIK/v1yl0jYt89M7jpLvmxyQIcVJ/8Ds2aZXQudrMPDUWlF9AziUjskBSkFJSdJGs Cymj1TfuyzjfqwRPGU33BoaeUxjizwUn/6pg+YiU/9Axtt/lkVroGNVszIE5NXc0guCQDXMvi9jWp Uf69kpKuDV4sv37Cco67YFn+xS4geoihhQn0zuqHXK2+xeUaDMQh1PkaqhE89FdxntXatjSC+Tw9W m5/jm60HpkK3PPVrd+PZh6RXX3aXw==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 20 Oct 2020 01:13:24 +0200 Subject: [PATCH 6/8] tests/9pfs: add local unlinkat 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=edbf7a206a22138ee6f52c47c4a83b4d0b9fc3ea@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/19 19:37:26 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 --- tests/qtest/virtio-9p-test.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 78f4ed7e5f..f7d18f6274 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -1293,6 +1293,31 @@ 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; + 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"); + + fs_attach(v9p, NULL, t_alloc); + fs_mkdir(v9p, data, t_alloc, "/", "06"); + fs_lcreate(v9p, data, t_alloc, "06", "real_file"); + g_assert(stat(real_file, &st) =3D=3D 0); + g_assert((st.st_mode & S_IFMT) =3D=3D S_IFREG); + + fs_symlink(v9p, data, t_alloc, "06", "symlink_file", "real_file"); + g_assert(stat(symlink_file, &st) =3D=3D 0); + + fs_unlinkat(v9p, data, t_alloc, "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= "); @@ -1337,6 +1362,7 @@ 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 19:12:41 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=1603151248; cv=none; d=zohomail.com; s=zohoarc; b=Y850VTK83Yv3H/Y+qyCmF10U7S3drJgKbdd2nDcZ6Z9OnG5Frh3ZgKz1lfqBBpju2hR7mPw9HgNnKj7rgfkNEOIgFR2h1yXAYegK16x1MKRuwOMm0bBV8lc32J9FCvezK6WOk+bsnmkFkKJ83DbbKuM9oYo1WYsbzlyi7btlLLQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603151248; 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=vA3i8SPVfAVvIXbvf5MMFPnqoVqWzTlxfDM9uLSyPg4=; b=LtOlGzQs6haKErRGo5B2oCW+AUBnrMFTxfp+5UAZVN9lL9AXSeYtVPStRFB4GXdT7eq400fWCTb7YBrv6Wp9xrUhR4uQ1y4/6HvbDauL0Xa155C8UldYtd37h7K8IoQIa0h6/2Zu5b4lzuN7kBV9BSXHClo44TwxLZeA19AxG3o= 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 1603151248992839.2849401221221; Mon, 19 Oct 2020 16:47:28 -0700 (PDT) Received: from localhost ([::1]:54678 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUesC-0006oS-0M for importer@patchew.org; Mon, 19 Oct 2020 19:47:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47950) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUekA-00075h-FY for qemu-devel@nongnu.org; Mon, 19 Oct 2020 19:39:10 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:56165) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kUek8-0002T8-P4 for qemu-devel@nongnu.org; Mon, 19 Oct 2020 19:39:10 -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=vA3i8SPVfAVvIXbvf5MMFPnqoVqWzTlxfDM9uLSyPg4=; b=YvfBn elb92ps34Lj7d7G4bK6adeNhWk1MIWmt1UoIwlpjsiUXErdmxPgpCj4h79xyKDqtpG5kfAQszBGfZ zXmfiV62VK4KLTEqWk3bTGpNt3mLnalWlhgwbdipD9r8ds15sI1rtB4fOfdkXD3AVIpcPEkVUTH2u J/YO7Avv6A9ZzDRHfV7B6KgzDTGsoL7KRQgWQlqysEAUzUm3z1kNvIcZ+9WvbDfet/eT5ykl7dx7H EmXygE1T1zKFTu6wOxeFVutAOf6ihNeQ5u+oxiFmbcYPMY8e3RqEBi1G+c0I+ffPYsC+vNdQw1DVE h55LRIUmkak3wxcU84XVKgDAbMCnA==; Message-Id: In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 20 Oct 2020 01:13:24 +0200 Subject: [PATCH 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=ee6d9e1147d05bcf0b51b02ef6757f4b4691ba2d@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/19 19:37:26 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 --- tests/qtest/virtio-9p-test.c | 61 ++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index f7d18f6274..447d8e3344 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" : @@ -742,6 +743,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) @@ -1318,6 +1346,38 @@ 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; + P9Req *req; + uint32_t dfid, fid; + 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"); + + fs_attach(v9p, NULL, t_alloc); + fs_mkdir(v9p, data, t_alloc, "/", "07"); + fid =3D fs_lcreate(v9p, data, t_alloc, "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); + + dfid =3D fs_walk_fid(v9p, data, t_alloc, "07"); + + req =3D v9fs_tlink(v9p, dfid, fid, "hardlink_file", 0); + v9fs_req_wait_for_reply(req, NULL); + v9fs_rlink(req); + + /* 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= "); @@ -1363,6 +1423,7 @@ static void register_virtio_9p_test(void) 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); + 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 19:12:41 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=1603151379; cv=none; d=zohomail.com; s=zohoarc; b=cZGIdrEH04kqwu9UiCavn41L7LyaGPYpT2E/vur+YWFroibs9CEWftEsnhje5Eab4+QJIT6LIRTq9+4bWE2BKanGED2AwgW2ZRICpuQT6AYPSQ8oXbxs0UI9qFObejHRES5xGL1dud+WkjFFHZZtKCTfwFeJpOmPhwR6rnm6bxc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603151379; 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=Vr1PjD7KFp1uXG16reokhh/83DBLWQIiNOAMtOR6Lqk=; b=WmKxHZNJus0NEoSrcKbTPf17jkkMJc62vYRPd1V5Ywd+AZKA6C1dlFhBvZkYvm1dL5rWOEhjdNqYo00VlvEPvPMrJcsq8IOkXa4HrKssy2F4B1MllOtSzkXIc2xFVHNRyYtwH0lbBs+HMuIyu7ucK7VUcCypFvK3WyqZWSVji34= 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 1603151379558351.1865320472617; Mon, 19 Oct 2020 16:49:39 -0700 (PDT) Received: from localhost ([::1]:57578 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kUeuH-00089A-Sp for importer@patchew.org; Mon, 19 Oct 2020 19:49:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <63a6783a516398a55a8e91dd678d3926abb7e138@lizzy.crudebyte.com>) id 1kUekG-0007Jd-Ni for qemu-devel@nongnu.org; Mon, 19 Oct 2020 19:39:18 -0400 Received: from lizzy.crudebyte.com ([91.194.90.13]:39773) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <63a6783a516398a55a8e91dd678d3926abb7e138@lizzy.crudebyte.com>) id 1kUekF-0002TY-2k for qemu-devel@nongnu.org; Mon, 19 Oct 2020 19:39:16 -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=Vr1PjD7KFp1uXG16reokhh/83DBLWQIiNOAMtOR6Lqk=; b=F40rI l4ek2Nh+vNnqHzQSuNT9VrbTLcWbGVGWZ5c9p4ks3iQLPYhVkfwGeUaVMts8MiI8JlEADBwcAB8EA +xm1wfdR+cZzZz0ahhAEVHYJnXH7NqH5Olpb5mDf6wHI/WvRjmsEB2lGStCAKFd3e+Ziq+jcJ/iZv LMLo02V8QwxH+IuJDlsRd5RaOWZbNhpBi4PJY4tA40yy5qjczpRoXVKIsyUDNrD46iK+N34S/g3sB rB3RAsfPbDS6P1WkIHSoBz1pUtSiQru4OSoVarIMoQRuvfciu3XMCWOxinFm2IMTNTvhMn7NGovQ7 8wQlQbubpW+g6Pbuq+XK+5hTXypYA==; Message-Id: <63a6783a516398a55a8e91dd678d3926abb7e138.1603149434.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Tue, 20 Oct 2020 01:13:24 +0200 Subject: [PATCH 8/8] tests/9pfs: add local unlinkat 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=63a6783a516398a55a8e91dd678d3926abb7e138@lizzy.crudebyte.com; helo=lizzy.crudebyte.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/19 19:37:26 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 --- tests/qtest/virtio-9p-test.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c index 447d8e3344..2e50445745 100644 --- a/tests/qtest/virtio-9p-test.c +++ b/tests/qtest/virtio-9p-test.c @@ -1378,6 +1378,39 @@ 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; + P9Req *req; + uint32_t dfid, fid; + 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"); + + fs_attach(v9p, NULL, t_alloc); + fs_mkdir(v9p, data, t_alloc, "/", "08"); + fid =3D fs_lcreate(v9p, data, t_alloc, "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); + + dfid =3D fs_walk_fid(v9p, data, t_alloc, "08"); + + req =3D v9fs_tlink(v9p, dfid, fid, "hardlink_file", 0); + v9fs_req_wait_for_reply(req, NULL); + v9fs_rlink(req); + g_assert(stat(hardlink_file, &st_link) =3D=3D 0); + + fs_unlinkat(v9p, data, t_alloc, "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= "); @@ -1424,6 +1457,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); + qos_add_test("local/unlinkat_hardlink", "virtio-9p", fs_unlinkat_hardl= ink, &opts); } =20 libqos_init(register_virtio_9p_test); --=20 2.20.1