ceph_submount.c
1 |
#define _FILE_OFFSET_BITS 64 |
---|---|
2 |
#define _GNU_SOURCE 1 |
3 |
#include <cephfs/libcephfs.h> |
4 |
#include <stdio.h> |
5 |
#include <string.h> |
6 |
#include <limits.h> |
7 |
#include <fcntl.h> |
8 |
|
9 |
#define USERID "alice" |
10 |
#define PATHNAME "/export" |
11 |
#define KEY "AQBsm1FYRAxvCxAARfvnAdU+KzjxGBV7+YTkZQ==" |
12 |
|
13 |
int
|
14 |
main(void) {
|
15 |
struct ceph_mount_info *cmount;
|
16 |
int ret;
|
17 |
|
18 |
ret = ceph_create(&cmount, USERID); |
19 |
if (ret) {
|
20 |
fprintf(stderr, "mount info create: %d\n", ret);
|
21 |
return 1; |
22 |
} |
23 |
|
24 |
ret = ceph_conf_read_file(cmount, NULL);
|
25 |
if (ret) {
|
26 |
fprintf(stderr, "read conf file: %d\n", ret);
|
27 |
return 1; |
28 |
} |
29 |
|
30 |
ret = ceph_conf_set(cmount, "key", KEY);
|
31 |
if (ret) {
|
32 |
fprintf(stderr, "set key option: %d\n", ret);
|
33 |
return 1; |
34 |
} |
35 |
|
36 |
ret = ceph_mount(cmount, PATHNAME); |
37 |
if (ret) {
|
38 |
fprintf(stderr, "mount: %d\n", ret);
|
39 |
return 1; |
40 |
} |
41 |
|
42 |
printf("Mounting successful!\n");
|
43 |
|
44 |
ceph_unmount(cmount); |
45 |
ceph_release(cmount); |
46 |
return 0; |
47 |
} |