|
#define _FILE_OFFSET_BITS (64)
|
|
#define _GNU_SOURCE 1
|
|
#include <stdio.h>
|
|
#include <cephfs/libcephfs.h>
|
|
#include <string.h>
|
|
#include <limits.h>
|
|
|
|
#define BUFSZ (16 * 1024)
|
|
#define NUMFILES 256
|
|
|
|
int
|
|
main(void) {
|
|
char pathname[PATH_MAX];
|
|
struct ceph_mount_info *cmount;
|
|
char buf[BUFSZ];
|
|
int i, ret, fd;
|
|
|
|
ret = ceph_create(&cmount, NULL);
|
|
if (ret) {
|
|
fprintf(stderr, "mount info create: %d\n", ret);
|
|
return 1;
|
|
}
|
|
|
|
ret = ceph_conf_read_file(cmount, NULL);
|
|
if (ret) {
|
|
fprintf(stderr, "read conf file: %d\n", ret);
|
|
return 1;
|
|
}
|
|
|
|
ret = ceph_conf_parse_env(cmount, NULL);
|
|
if (ret) {
|
|
fprintf(stderr, "parse env: %d\n", ret);
|
|
return 1;
|
|
}
|
|
|
|
ret = ceph_mount(cmount, "/");
|
|
if (ret) {
|
|
fprintf(stderr, "mount: %d\n", ret);
|
|
return 1;
|
|
}
|
|
|
|
memset(buf, 0x7c, BUFSZ);
|
|
|
|
for (i = 0; i < NUMFILES; ++i) {
|
|
ret = sprintf(pathname, "/testfile%x", i);
|
|
fd = ceph_open(cmount, pathname, O_WRONLY|O_CREAT|O_TRUNC, 0644);
|
|
if (fd < 0) {
|
|
fprintf(stderr, "open: %d\n", fd);
|
|
return fd;
|
|
}
|
|
|
|
ret = ceph_write(cmount, fd, buf, BUFSZ, 0);
|
|
if (ret < 0) {
|
|
fprintf(stderr, "write: %d\n", ret);
|
|
return ret;
|
|
}
|
|
|
|
ret = ceph_fsync(cmount, fd, false);
|
|
if (ret < 0) {
|
|
fprintf(stderr, "fsync: %d\n", ret);
|
|
return ret;
|
|
}
|
|
|
|
ret = ceph_close(cmount, fd);
|
|
if (ret < 0) {
|
|
fprintf(stderr, "close: %d\n", ret);
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
return 0;
|
|
}
|