[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 7/7] tests: virtio-9p: TLCREATE should fail if pathn
From: |
Greg Kurz |
Subject: |
[Qemu-devel] [PATCH 7/7] tests: virtio-9p: TLCREATE should fail if pathname exists |
Date: |
Tue, 10 Jan 2017 15:32:53 +0100 |
User-agent: |
StGit/0.17.1-20-gc0b1b-dirty |
As specified in the http://man.cat-v.org/plan_9/5/open :
"An attempt to create a file in a directory where the given
name already exists will be rejected"
Signed-off-by: Greg Kurz <address@hidden>
---
tests/virtio-9p-test.c | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/tests/virtio-9p-test.c b/tests/virtio-9p-test.c
index 7f2ee41ca0f0..2ba321b990d3 100644
--- a/tests/virtio-9p-test.c
+++ b/tests/virtio-9p-test.c
@@ -621,6 +621,35 @@ static void fs_lcreate(QVirtIO9P *v9p)
g_free(wnames[0]);
}
+static void fs_lcreate_exclusive(QVirtIO9P *v9p)
+{
+ char *const wnames[] = { g_strdup(__func__) };
+ char *path = g_strdup_printf("%s/%s", v9p->test_share, wnames[0]);
+ int fd;
+ uint32_t err;
+ P9Req *req;
+
+ fd = creat(path, 0600);
+ g_assert(fd >= 0);
+ close(fd);
+
+ fs_attach(v9p);
+ /* Clone the root directory fid and open it */
+ req = v9fs_twalk(v9p, 0, 1, 0, NULL);
+ v9fs_rwalk(req, NULL, NULL);
+ req = v9fs_tlopen(v9p, 1, O_RDWR);
+ v9fs_rlopen(req, NULL, NULL);
+
+ req = v9fs_tlcreate(v9p, 1, wnames[0], O_RDONLY, 0600, getgid());
+ v9fs_rlerror(req, &err);
+
+ g_assert_cmpint(err, ==, EEXIST);
+
+ unlink(path);
+ g_free(path);
+ g_free(wnames[0]);
+}
+
typedef void (*v9fs_test_fn)(QVirtIO9P *v9p);
static void v9fs_run_pci_test(gconstpointer data)
@@ -654,6 +683,8 @@ int main(int argc, char **argv)
v9fs_qtest_pci_add("/virtio/9p/pci/fs/lopen/fifo_not_allowed",
fs_lopen_fifo_not_allowed);
v9fs_qtest_pci_add("/virtio/9p/pci/fs/lcreate/basic", fs_lcreate);
+ v9fs_qtest_pci_add("/virtio/9p/pci/fs/lcreate/exclusive",
+ fs_lcreate_exclusive);
return g_test_run();
}
- [Qemu-devel] [PATCH 0/7] fix potential hangs in 9pfs, Greg Kurz, 2017/01/10
- [Qemu-devel] [PATCH 1/7] 9pfs: restrict open to regular files and directories, Greg Kurz, 2017/01/10
- [Qemu-devel] [PATCH 2/7] tests: virtio-9p: improve error reporting, Greg Kurz, 2017/01/10
- [Qemu-devel] [PATCH 3/7] tests: virtio-9p: add LOPEN operation test, Greg Kurz, 2017/01/10
- [Qemu-devel] [PATCH 4/7] tests: virtio-9p: TLOPEN should fail to open a FIFO, Greg Kurz, 2017/01/10
- [Qemu-devel] [PATCH 5/7] 9pfs: don't create files if pathname already exists, Greg Kurz, 2017/01/10
- [Qemu-devel] [PATCH 6/7] tests: virtio-9p: add LCREATE operation test, Greg Kurz, 2017/01/10
- [Qemu-devel] [PATCH 7/7] tests: virtio-9p: TLCREATE should fail if pathname exists,
Greg Kurz <=