|
#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) {
|
|
struct ceph_mount_info *cmount;
|
|
int ret;
|
|
struct ceph_statx stx;
|
|
UserPerm *perm1, *perm2;
|
|
Inode *root, *dir1, *dir2;
|
|
|
|
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;
|
|
}
|
|
|
|
perm1 = ceph_userperm_new(10000, 10000, 0, NULL);
|
|
if (!perm1) {
|
|
fprintf(stderr, "perm1: Out of memory\n");
|
|
return 1;
|
|
}
|
|
|
|
perm2 = ceph_userperm_new(10001, 10001, 0, NULL);
|
|
if (!perm2) {
|
|
fprintf(stderr, "perm2: Out of memory\n");
|
|
return 1;
|
|
}
|
|
|
|
ret = ceph_ll_lookup_root(cmount, &root);
|
|
if (ret) {
|
|
fprintf(stderr, "lookup root: %d\n", ret);
|
|
return 1;
|
|
}
|
|
|
|
ret = ceph_ll_mkdir(cmount, root, "dir1", 0700, &dir1,
|
|
&stx, 0, 0, perm1);
|
|
if (ret) {
|
|
fprintf(stderr, "mkdir1: %d\n", ret);
|
|
return 1;
|
|
}
|
|
|
|
ret = ceph_ll_mkdir(cmount, dir1, "dir2", 0700, &dir2,
|
|
&stx, 0, 0, perm2);
|
|
if (ret) {
|
|
fprintf(stderr, "mkdir2: %d\n", ret);
|
|
return 1;
|
|
}
|
|
|
|
|
|
return 0;
|
|
}
|