summaryrefslogtreecommitdiffstats
path: root/libglusterfsclient/src/libglusterfsclient.h
blob: 19b7ea0361ccc4be230666c82622f63b221a03e9 (plain)
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
/*
   Copyright (c) 2008 Z RESEARCH, Inc. <http://www.zresearch.com>
   This file is part of GlusterFS.

   GlusterFS is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published
   by the Free Software Foundation; either version 3 of the License,
   or (at your option) any later version.

   GlusterFS is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program.  If not, see
   <http://www.gnu.org/licenses/>.
*/

#ifndef __LIBGLUSTERFSCLIENT_H
#define __LIBGLUSTERFSCLIENT_H

#ifdef __cplusplus
extern "C" {
#endif

#include <sys/types.h>
#include <sys/stat.h>
        //#include <unistd.h>
#include <dirent.h>
#include <errno.h>
/* #include <logging.h> */

typedef struct {
        int          op_ret;
        int          op_errno;
        struct iovec *vector;
        int          count;
        void         *ref;
}glusterfs_read_buf_t;


typedef struct {
        char          *logfile;
        char          *loglevel;
        struct {
                char *specfile;
                FILE *specfp;
        }; 
        char          *volume_name;
        unsigned long lookup_timeout;
        unsigned long stat_timeout;
}glusterfs_init_ctx_t;

typedef struct libglusterfs_client_ctx *libglusterfs_handle_t;

typedef int (*glusterfs_readv_cbk_t) (glusterfs_read_buf_t *buf,
                                              void *cbk_data);

typedef int (*glusterfs_writev_cbk_t) (int op_ret, 
                                       int op_errno, 
                                       void *cbk_data);

typedef int (*glusterfs_lookup_cbk_t) (int op_ret, 
                                       int op_errno, 
                                       void *buf, 
                                       struct stat *st, 
                                       void *cbk_data);

/* Used to free the glusterfs_read_buf passed to the application from glusterfs_read_async_cbk */
void 
glusterfs_free (glusterfs_read_buf_t *buf);

/* libglusterfsclient initialization function  */
libglusterfs_handle_t 
glusterfs_init (glusterfs_init_ctx_t *ctx);

int
glusterfs_fini (libglusterfs_handle_t handle);

/* added for log related initialization for fork implementation in booster */
void 
glusterfs_reset (void);

void
glusterfs_log_lock (void);

void
glusterfs_log_unlock (void);

/* For smaller files, application can use just glusterfs_lookup/glusterfs_lookup_async to read 
 * the whole content. Limit of the file-sizes to be read in 
 * glusterfs_lookup/glusterfs_lookup_async is passed in the size argument */

/* glusterfs_lookup:
 * @handle: glusterfs handle
 * @path: path to be looked upon
 * @buf: pointer to pre-allocated buf, in which the file content is returned for files with sizes    *       less than the size argument.
 * @size: upper limit of file-sizes to be read in lookup
 * @stbuf: stat buffer 
 */

int 
glusterfs_lookup (libglusterfs_handle_t handle, 
                  const char *path, 
                  void *buf, 
                  size_t size, 
                  struct stat *stbuf);

int
glusterfs_lookup_async (libglusterfs_handle_t handle,
                        const char *path,
                        void *buf,
                        size_t size, 
                        glusterfs_lookup_cbk_t cbk,
                        void *cbk_data);

unsigned long 
glusterfs_open (libglusterfs_handle_t handle, 
                const char *path, 
                int flags, 
                mode_t mode);

unsigned long 
glusterfs_creat (libglusterfs_handle_t handle, 
                 const char *path, 
                 mode_t mode);

int 
glusterfs_close (unsigned long fd);

int  
glusterfs_stat (libglusterfs_handle_t handle, 
                const char *path, 
                struct stat *buf);

int 
glusterfs_fstat (unsigned long fd, 
                 struct stat *buf) ;

int 
glusterfs_setxattr (libglusterfs_handle_t handle, 
                    const char *path, 
                    const char *name,
                    const void *value, 
                    size_t size, 
                    int flags);

int 
glusterfs_lsetxattr (libglusterfs_handle_t handle,
                     const char *path, 
                     const char *name,
                     const void *value, 
                     size_t size, 
                     int flags);

int 
glusterfs_fsetxattr (unsigned long fd, 
                     const char *name,
                     const void *value, 
                     size_t size, 
                     int flags);

ssize_t 
glusterfs_getxattr (libglusterfs_handle_t handle, 
                    const char *path, 
                    const char *name,
                    void *value, 
                    size_t size);

ssize_t 
glusterfs_lgetxattr (libglusterfs_handle_t handle, 
                     const char *path, 
                     const char *name,
                     void *value, 
                     size_t size);

ssize_t 
glusterfs_fgetxattr (unsigned long fd,
                     const char *name,
                     void *value, 
                     size_t size);

ssize_t 
glusterfs_listxattr (libglusterfs_handle_t handle, 
                     const char *path, 
                     char *list,
                     size_t size);

ssize_t 
glusterfs_llistxattr (libglusterfs_handle_t handle, 
                      const char *path, 
                      char *list,
                      size_t size);

ssize_t 
glusterfs_flistxattr (unsigned long fd, 
                      char *list,
                      size_t size);

int 
glusterfs_removexattr (libglusterfs_handle_t handle, 
                       const char *path, 
                       const char *name);

int 
glusterfs_lremovexattr (libglusterfs_handle_t handle, 
                        const char *path, 
                        const char *name);

int 
glusterfs_fremovexattr (unsigned long fd, 
                        const char *name);

ssize_t 
glusterfs_read (unsigned long fd, 
                void *buf, 
                size_t nbytes);

ssize_t 
glusterfs_readv (unsigned long fd, 
                 const struct iovec *vec, 
                 int count);

int 
glusterfs_read_async (unsigned long fd, 
                      size_t nbytes, 
                      off_t offset,
                      glusterfs_readv_cbk_t readv_cbk,
                      void *cbk_data);

ssize_t 
glusterfs_write (unsigned long fd, 
                 const void *buf, 
                 size_t n);

ssize_t 
glusterfs_writev (unsigned long fd, 
                  const struct iovec *vector,
                  size_t count);

int
glusterfs_write_async (unsigned long fd, 
                       const void *buf, 
                       size_t nbytes, 
                       off_t offset,
                       glusterfs_writev_cbk_t writev_cbk,
                       void *cbk_data);

int
glusterfs_readdir (unsigned long fd, 
                   struct dirent *dirp, 
                   unsigned int count);

int
glusterfs_getdents (unsigned long fd,
		    struct dirent *dirp,
		    unsigned int count);

ssize_t 
glusterfs_pread (unsigned long fd, 
                 void *buf, 
                 size_t count, 
                 off_t offset);

ssize_t 
glusterfs_pwrite (unsigned long fd, 
                  const void *buf, 
                  size_t count, 
                  off_t offset);

off_t
glusterfs_lseek (unsigned long fd, off_t offset, int whence);

#ifdef __cplusplus
}
#endif

#endif