From: Greg Kurz <groug@kaod.org>
To: Christian Schoenebeck <qemu_oss@crudebyte.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH v2 1/8] tests/9pfs: simplify do_mkdir()
Date: Thu, 22 Oct 2020 10:24:30 +0200 [thread overview]
Message-ID: <20201022102430.3631ca23@bahia.lan> (raw)
In-Reply-To: <4d7275b2363f122438a443ce079cbb355285e9d6.1603285620.git.qemu_oss@crudebyte.com>
On Wed, 21 Oct 2020 14:06:53 +0200
Christian Schoenebeck <qemu_oss@crudebyte.com> wrote:
> 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 <qemu_oss@crudebyte.com>
> ---
Reviewed-by: Greg Kurz <groug@kaod.org>
> 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);
> }
>
> +/* 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 = genfid();
> +
> + int nwnames = split(path, "/", &wnames);
> +
> + req = 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 = t_alloc;
> @@ -974,23 +991,17 @@ static void fs_flush_ignored(void *obj, void *data, QGuestAllocator *t_alloc)
>
> static void do_mkdir(QVirtio9P *v9p, const char *path, const char *cname)
> {
> - char **wnames;
> char *const name = g_strdup(cname);
> + uint32_t fid;
> P9Req *req;
> - const uint32_t fid = genfid();
>
> - int nwnames = split(path, "/", &wnames);
> -
> - req = v9fs_twalk(v9p, 0, fid, nwnames, wnames, 0);
> - v9fs_req_wait_for_reply(req, NULL);
> - v9fs_rwalk(req, NULL, NULL);
> + fid = do_walk(v9p, 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,
next prev parent reply other threads:[~2020-10-22 8:25 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-21 13:07 [PATCH v2 0/8] 9pfs: more local tests Christian Schoenebeck
2020-10-21 12:06 ` [PATCH v2 1/8] tests/9pfs: simplify do_mkdir() Christian Schoenebeck
2020-10-22 8:24 ` Greg Kurz [this message]
2020-10-21 12:17 ` [PATCH v2 2/8] tests/9pfs: add local Tunlinkat directory test Christian Schoenebeck
2020-10-22 8:37 ` Greg Kurz
2020-10-21 12:25 ` [PATCH v2 3/8] tests/9pfs: add local Tlcreate test Christian Schoenebeck
2020-10-22 8:51 ` Greg Kurz
2020-10-22 10:34 ` Christian Schoenebeck
2020-10-21 12:28 ` [PATCH v2 4/8] tests/9pfs: add local Tunlinkat file test Christian Schoenebeck
2020-10-22 8:54 ` Greg Kurz
2020-10-21 12:33 ` [PATCH v2 5/8] tests/9pfs: add local Tsymlink test Christian Schoenebeck
2020-10-22 9:00 ` Greg Kurz
2020-10-21 12:36 ` [PATCH v2 6/8] tests/9pfs: add local Tunlinkat symlink test Christian Schoenebeck
2020-10-22 9:01 ` Greg Kurz
2020-10-21 12:51 ` [PATCH v2 7/8] tests/9pfs: add local Tlink test Christian Schoenebeck
2020-10-21 18:20 ` Christian Schoenebeck
2020-10-22 9:07 ` Greg Kurz
2020-10-22 13:09 ` Christian Schoenebeck
2020-10-22 9:02 ` Greg Kurz
2020-10-21 12:55 ` [PATCH v2 8/8] tests/9pfs: add local Tunlinkat hard link test Christian Schoenebeck
2020-10-22 9:08 ` Greg Kurz
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=20201022102430.3631ca23@bahia.lan \
--to=groug@kaod.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu_oss@crudebyte.com \
/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).