From: Christian Schoenebeck <qemu_oss@crudebyte.com>
To: qemu-devel@nongnu.org, Peter Maydell <peter.maydell@linaro.org>
Cc: Greg Kurz <groug@kaod.org>, Stefan Hajnoczi <stefanha@redhat.com>
Subject: [PULL 5/7] tests/9p: add use_dir_after_unlink test
Date: Thu, 06 Feb 2025 17:41:56 +0100 [thread overview]
Message-ID: <37c21fb972da373be101d20574309be0584dc2a3.1738860115.git.qemu_oss@crudebyte.com> (raw)
In-Reply-To: <cover.1738860115.git.qemu_oss@crudebyte.com>
After removing a directory from the filesystem, it should still be
possible to operate on the directory if the directory has been opened
before.
As a first step this new test will verify whether Tgetattr request
works on the unlinked directory.
Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com>
Message-Id: <0a9b3419356731e34b1be4a8577d6b416379d085.1736427878.git.qemu_oss@crudebyte.com>
---
tests/qtest/virtio-9p-test.c | 39 ++++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/tests/qtest/virtio-9p-test.c b/tests/qtest/virtio-9p-test.c
index 07459c5289..35c42cd0d7 100644
--- a/tests/qtest/virtio-9p-test.c
+++ b/tests/qtest/virtio-9p-test.c
@@ -737,6 +737,43 @@ static void fs_use_file_after_unlink(void *obj, void *data,
g_assert_cmpint(count, ==, write_count);
}
+static void fs_use_dir_after_unlink(void *obj, void *data,
+ QGuestAllocator *t_alloc)
+{
+ QVirtio9P *v9p = obj;
+ v9fs_set_allocator(t_alloc);
+ g_autofree char *real_dir = virtio_9p_test_path("10/doa_dir");
+ struct stat st_dir;
+ struct v9fs_attr attr;
+ uint32_t fid_dir;
+
+ tattach({ .client = v9p });
+
+ /* create a dir "10/doa_dir" and make sure it exists */
+ tmkdir({ .client = v9p, .atPath = "/", .name = "10" });
+ tmkdir({ .client = v9p, .atPath = "10", .name = "doa_dir" });
+ g_assert(stat(real_dir, &st_dir) == 0);
+ g_assert((st_dir.st_mode & S_IFMT) == S_IFDIR);
+
+ /* request a FID for that directory that we can work with next */
+ fid_dir = twalk({
+ .client = v9p, .fid = 0, .path = "10/doa_dir"
+ }).newfid;
+ g_assert(fid_dir != 0);
+
+ /* now first open the dir before ... */
+ tlopen({ .client = v9p, .fid = fid_dir, .flags = O_RDONLY });
+ /* ... removing the dir from file system */
+ tunlinkat({ .client = v9p, .atPath = "10", .name = "doa_dir",
+ .flags = AT_REMOVEDIR });
+
+ /* dir is removed, but we still have it open, so this should succeed */
+ tgetattr({
+ .client = v9p, .fid = fid_dir, .request_mask = P9_GETATTR_BASIC,
+ .rgetattr.attr = &attr
+ });
+}
+
static void cleanup_9p_local_driver(void *data)
{
/* remove previously created test dir when test is completed */
@@ -804,6 +841,8 @@ static void register_virtio_9p_test(void)
&opts);
qos_add_test("local/use_file_after_unlink", "virtio-9p",
fs_use_file_after_unlink, &opts);
+ qos_add_test("local/use_dir_after_unlink", "virtio-9p",
+ fs_use_dir_after_unlink, &opts);
}
libqos_init(register_virtio_9p_test);
--
2.30.2
next prev parent reply other threads:[~2025-02-06 16:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-06 16:41 [PULL 0/7] 9p queue 2025-02-06 Christian Schoenebeck
2025-02-06 16:41 ` [PULL 3/7] 9pfs: improve v9fs_open() tracing Christian Schoenebeck
2025-02-06 16:41 ` [PULL 2/7] 9pfs: make multidevs=remap default Christian Schoenebeck
2025-02-06 16:41 ` [PULL 1/7] 9pfs: improve v9fs_walk() tracing Christian Schoenebeck
2025-02-06 16:41 ` Christian Schoenebeck [this message]
2025-02-06 16:41 ` [PULL 4/7] tests/9p: rename test use_after_unlink -> use_file_after_unlink Christian Schoenebeck
2025-02-06 16:41 ` [PULL 6/7] tests/9p: extend use_dir_after_unlink test with Treaddir Christian Schoenebeck
2025-02-06 16:41 ` [PULL 7/7] MAINTAINERS: Mark me as reviewer only for 9pfs Christian Schoenebeck
2025-02-06 18:49 ` [PULL 0/7] 9p queue 2025-02-06 Stefan Hajnoczi
2025-02-06 19:31 ` 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=37c21fb972da373be101d20574309be0584dc2a3.1738860115.git.qemu_oss@crudebyte.com \
--to=qemu_oss@crudebyte.com \
--cc=groug@kaod.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=stefanha@redhat.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).