From 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 20:24:20 +0200 Subject: Adding upstream version 14.2.21. Signed-off-by: Daniel Baumann --- qa/libceph/trivial_libceph.c | 69 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 qa/libceph/trivial_libceph.c (limited to 'qa/libceph/trivial_libceph.c') diff --git a/qa/libceph/trivial_libceph.c b/qa/libceph/trivial_libceph.c new file mode 100644 index 00000000..9093e97e --- /dev/null +++ b/qa/libceph/trivial_libceph.c @@ -0,0 +1,69 @@ +#define _FILE_OFFSET_BITS 64 +#include +#include +#include +#include +#include +#include +#include +#include "../../src/include/cephfs/libcephfs.h" + +#define MB64 (1<<26) + +int main(int argc, const char **argv) +{ + struct ceph_mount_info *cmount; + int ret, fd, len; + char buf[1024]; + + if (argc < 3) { + fprintf(stderr, "usage: ./%s \n", argv[0]); + exit(1); + } + + ret = ceph_create(&cmount, NULL); + if (ret) { + fprintf(stderr, "ceph_create=%d\n", ret); + exit(1); + } + + ret = ceph_conf_read_file(cmount, argv[1]); + if (ret) { + fprintf(stderr, "ceph_conf_read_file=%d\n", ret); + exit(1); + } + + ret = ceph_conf_parse_argv(cmount, argc, argv); + if (ret) { + fprintf(stderr, "ceph_conf_parse_argv=%d\n", ret); + exit(1); + } + + ret = ceph_mount(cmount, NULL); + if (ret) { + fprintf(stderr, "ceph_mount=%d\n", ret); + exit(1); + } + + ret = ceph_chdir(cmount, "/"); + if (ret) { + fprintf(stderr, "ceph_chdir=%d\n", ret); + exit(1); + } + + fd = ceph_open(cmount, argv[2], O_CREAT|O_TRUNC|O_RDWR, 0777); + if (fd < 0) { + fprintf(stderr, "ceph_open=%d\n", fd); + exit(1); + } + + memset(buf, 'a', sizeof(buf)); + + len = ceph_write(cmount, fd, buf, sizeof(buf), 0); + + fprintf(stdout, "wrote %d bytes\n", len); + + ceph_shutdown(cmount); + + return 0; +} -- cgit v1.2.3