From: Christian Schoenebeck <qemu_oss@crudebyte.com>
To: qemu-devel@nongnu.org
Cc: Greg Kurz <groug@kaod.org>
Subject: [PATCH 1/8] tests/9pfs: simplify fs_mkdir()
Date: Tue, 20 Oct 2020 01:13:23 +0200 [thread overview]
Message-ID: <03b427019be98d12761924f1e6132eefc82c80ec.1603149434.git.qemu_oss@crudebyte.com> (raw)
In-Reply-To: <cover.1603149434.git.qemu_oss@crudebyte.com>
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 <qemu_oss@crudebyte.com>
---
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, QGuestAllocator *t_alloc)
g_free(wnames[0]);
}
-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_alloc,
+ const char *path)
{
QVirtio9P *v9p = obj;
- alloc = t_alloc;
char **wnames;
- char *const name = g_strdup(cname);
P9Req *req;
const uint32_t fid = genfid();
@@ -983,12 +982,26 @@ static void fs_mkdir(void *obj, void *data, QGuestAllocator *t_alloc,
v9fs_req_wait_for_reply(req, NULL);
v9fs_rwalk(req, NULL, NULL);
+ split_free(&wnames);
+ return fid;
+}
+
+static void fs_mkdir(void *obj, void *data, QGuestAllocator *t_alloc,
+ const char *path, const char *cname)
+{
+ QVirtio9P *v9p = obj;
+ alloc = t_alloc;
+ char *const name = g_strdup(cname);
+ uint32_t fid;
+ P9Req *req;
+
+ fid = fs_walk_fid(v9p, data, t_alloc, path);
+
req = v9fs_tmkdir(v9p, fid, name, 0750, 0, 0);
v9fs_req_wait_for_reply(req, NULL);
v9fs_rmkdir(req, NULL);
g_free(name);
- split_free(&wnames);
}
static void fs_readdir_split_128(void *obj, void *data,
--
2.20.1
next prev parent reply other threads:[~2020-10-19 23:40 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-19 23:17 [PATCH 0/8] 9pfs: more local tests Christian Schoenebeck
2020-10-19 23:13 ` [PATCH 2/8] tests/9pfs: add local unlinkat directory test Christian Schoenebeck
2020-10-19 23:13 ` Christian Schoenebeck [this message]
2020-10-20 13:35 ` [PATCH 1/8] tests/9pfs: simplify fs_mkdir() Greg Kurz
2020-10-20 13:43 ` Christian Schoenebeck
2020-10-20 13:59 ` Greg Kurz
2020-10-20 18:03 ` Greg Kurz
2020-10-20 18:26 ` Christian Schoenebeck
2020-10-19 23:13 ` [PATCH 8/8] tests/9pfs: add local unlinkat hard link test Christian Schoenebeck
2020-10-19 23:13 ` [PATCH 7/8] tests/9pfs: add local Tlink test Christian Schoenebeck
2020-10-20 0:01 ` Christian Schoenebeck
2020-10-19 23:13 ` [PATCH 3/8] tests/9pfs: add local Tlcreate test Christian Schoenebeck
2020-10-19 23:13 ` [PATCH 5/8] tests/9pfs: add local Tsymlink test Christian Schoenebeck
2020-10-19 23:13 ` [PATCH 4/8] tests/9pfs: add local unlinkat file test Christian Schoenebeck
2020-10-19 23:13 ` [PATCH 6/8] tests/9pfs: add local unlinkat symlink test Christian Schoenebeck
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=03b427019be98d12761924f1e6132eefc82c80ec.1603149434.git.qemu_oss@crudebyte.com \
--to=qemu_oss@crudebyte.com \
--cc=groug@kaod.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).