1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
|
#include <glusterfs/api/glfs.h>
#include <stdio.h>
#include <errno.h>
#include <string.h>
#include <stdlib.h>
#define TOTAL_ARGS 4
int
main(int argc, char *argv[])
{
char *cwd = (char *)malloc(PATH_MAX * sizeof(char *));
char *resolved = NULL;
char *result = NULL;
char *buf = NULL;
struct stat st;
char *path = NULL;
int ret;
if (argc != TOTAL_ARGS) {
printf(
"Please give all required command line args.\n"
"Format : <volname> <server_ip> <path_name>\n");
goto out;
}
glfs_t *fs = glfs_new(argv[1]);
if (fs == NULL) {
printf("glfs_new: %s\n", strerror(errno));
/* No need to fail the test for this error */
ret = 0;
goto out;
}
ret = glfs_set_volfile_server(fs, "tcp", argv[2], 24007);
if (ret) {
printf("glfs_set_volfile_server: %s\n", strerror(errno));
/* No need to fail the test for this error */
ret = 0;
goto out;
}
path = argv[3];
ret = glfs_set_logging(fs, "/tmp/gfapi.log", 7);
if (ret) {
printf("glfs_set_logging: %s\n", strerror(errno));
/* No need to fail the test for this error */
ret = 0;
goto out;
}
ret = glfs_init(fs);
if (ret) {
printf("glfs_init: %s\n", strerror(errno));
/* No need to fail the test for this error */
ret = 0;
goto out;
}
sleep(1);
ret = glfs_chdir(fs, path);
if (ret) {
printf("glfs_chdir: %s\n", strerror(errno));
goto out;
}
buf = glfs_getcwd(fs, cwd, PATH_MAX);
if (cwd == NULL) {
printf("glfs_getcwd: %s\n", strerror(errno));
goto out;
}
printf("\ncwd = %s\n\n", cwd);
result = glfs_realpath(fs, path, resolved);
if (result == NULL) {
printf("glfs_realpath: %s\n", strerror(errno));
goto out;
}
ret = glfs_stat(fs, path, &st);
if (ret) {
printf("glfs_stat: %s\n", strerror(errno));
goto out;
}
if (cwd)
free(cwd);
result = glfs_realpath(fs, path, resolved);
if (result == NULL) {
printf("glfs_realpath: %s\n", strerror(errno));
goto out;
}
ret = glfs_fini(fs);
if (ret) {
printf("glfs_fini: %s\n", strerror(errno));
/* No need to fail the test for this error */
ret = 0;
goto out;
}
printf("\n");
out:
return ret;
}
|