~ubuntu-branches/ubuntu/wily/glusterfs/wily

« back to all changes in this revision

Viewing changes to rpc/xdr/src/glusterfs3-xdr.h

  • Committer: Bazaar Package Importer
  • Author(s): Patrick Matthäi
  • Date: 2011-03-15 21:14:50 UTC
  • mfrom: (1.3.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20110315211450-5iekpirgkdntccne
Tags: 3.1.3-1
* New upstream release.
  - glusterfs-volgen and glusterfs-defrag have been removed.
* Suggest nfs-common with the glusterfs-server for native NFS support.
  Closes: #614988
* Migrate to dh_python2.
  Closes: #616826

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
//#include <rpc/rpc.h>
32
32
#include "xdr-common.h"
33
 
#include "iatt.h"
34
33
 
35
34
#ifdef __cplusplus
36
35
extern "C" {
37
36
#endif
38
37
 
39
38
 
40
 
#define GF_O_ACCMODE           003
41
 
#define GF_O_RDONLY             00
42
 
#define GF_O_WRONLY             01
43
 
#define GF_O_RDWR               02
44
 
#define GF_O_CREAT            0100
45
 
#define GF_O_EXCL             0200
46
 
#define GF_O_NOCTTY           0400
47
 
#define GF_O_TRUNC           01000
48
 
#define GF_O_APPEND          02000
49
 
#define GF_O_NONBLOCK        04000
50
 
#define GF_O_SYNC           010000
51
 
#define GF_O_ASYNC          020000
52
 
 
53
 
#define GF_O_DIRECT         040000
54
 
#define GF_O_DIRECTORY     0200000
55
 
#define GF_O_NOFOLLOW      0400000
56
 
#define GF_O_NOATIME      01000000
57
 
#define GF_O_CLOEXEC      02000000
58
 
 
59
 
#define GF_O_LARGEFILE     0100000
60
 
 
61
 
#define XLATE_BIT(from, to, bit)    do {                \
62
 
                if (from & bit)                         \
63
 
                        to = to | GF_##bit;             \
64
 
        } while (0)
65
 
 
66
 
#define UNXLATE_BIT(from, to, bit)  do {                \
67
 
                if (from & GF_##bit)                    \
68
 
                        to = to | bit;                  \
69
 
        } while (0)
70
 
 
71
 
#define XLATE_ACCESSMODE(from, to) do {                 \
72
 
                switch (from & O_ACCMODE) {             \
73
 
                case O_RDONLY: to |= GF_O_RDONLY;       \
74
 
                        break;                          \
75
 
                case O_WRONLY: to |= GF_O_WRONLY;       \
76
 
                        break;                          \
77
 
                case O_RDWR: to |= GF_O_RDWR;           \
78
 
                        break;                          \
79
 
                }                                       \
80
 
        } while (0)
81
 
 
82
 
#define UNXLATE_ACCESSMODE(from, to) do {               \
83
 
                switch (from & GF_O_ACCMODE) {          \
84
 
                case GF_O_RDONLY: to |= O_RDONLY;       \
85
 
                        break;                          \
86
 
                case GF_O_WRONLY: to |= O_WRONLY;       \
87
 
                        break;                          \
88
 
                case GF_O_RDWR: to |= O_RDWR;           \
89
 
                        break;                          \
90
 
                }                                       \
91
 
        } while (0)
92
 
 
93
 
static inline uint32_t
94
 
gf_flags_from_flags (uint32_t flags)
95
 
{
96
 
        uint32_t gf_flags = 0;
97
 
 
98
 
        XLATE_ACCESSMODE (flags, gf_flags);
99
 
 
100
 
        XLATE_BIT (flags, gf_flags, O_CREAT);
101
 
        XLATE_BIT (flags, gf_flags, O_EXCL);
102
 
        XLATE_BIT (flags, gf_flags, O_NOCTTY);
103
 
        XLATE_BIT (flags, gf_flags, O_TRUNC);
104
 
        XLATE_BIT (flags, gf_flags, O_APPEND);
105
 
        XLATE_BIT (flags, gf_flags, O_NONBLOCK);
106
 
        XLATE_BIT (flags, gf_flags, O_SYNC);
107
 
        XLATE_BIT (flags, gf_flags, O_ASYNC);
108
 
 
109
 
        XLATE_BIT (flags, gf_flags, O_DIRECT);
110
 
        XLATE_BIT (flags, gf_flags, O_DIRECTORY);
111
 
        XLATE_BIT (flags, gf_flags, O_NOFOLLOW);
112
 
#ifdef O_NOATIME
113
 
        XLATE_BIT (flags, gf_flags, O_NOATIME);
114
 
#endif
115
 
#ifdef O_CLOEXEC
116
 
        XLATE_BIT (flags, gf_flags, O_CLOEXEC);
117
 
#endif
118
 
        XLATE_BIT (flags, gf_flags, O_LARGEFILE);
119
 
 
120
 
        return gf_flags;
121
 
}
122
 
 
123
 
static inline uint32_t
124
 
gf_flags_to_flags (uint32_t gf_flags)
125
 
{
126
 
        uint32_t flags = 0;
127
 
 
128
 
        UNXLATE_ACCESSMODE (gf_flags, flags);
129
 
 
130
 
        UNXLATE_BIT (gf_flags, flags, O_CREAT);
131
 
        UNXLATE_BIT (gf_flags, flags, O_EXCL);
132
 
        UNXLATE_BIT (gf_flags, flags, O_NOCTTY);
133
 
        UNXLATE_BIT (gf_flags, flags, O_TRUNC);
134
 
        UNXLATE_BIT (gf_flags, flags, O_APPEND);
135
 
        UNXLATE_BIT (gf_flags, flags, O_NONBLOCK);
136
 
        UNXLATE_BIT (gf_flags, flags, O_SYNC);
137
 
        UNXLATE_BIT (gf_flags, flags, O_ASYNC);
138
 
 
139
 
        UNXLATE_BIT (gf_flags, flags, O_DIRECT);
140
 
        UNXLATE_BIT (gf_flags, flags, O_DIRECTORY);
141
 
        UNXLATE_BIT (gf_flags, flags, O_NOFOLLOW);
142
 
#ifdef O_NOATIME
143
 
        UNXLATE_BIT (gf_flags, flags, O_NOATIME);
144
 
#endif
145
 
#ifdef O_CLOEXEC
146
 
        UNXLATE_BIT (gf_flags, flags, O_CLOEXEC);
147
 
#endif
148
 
        UNXLATE_BIT (gf_flags, flags, O_LARGEFILE);
149
 
 
150
 
        return flags;
151
 
}
152
 
 
153
 
 
154
39
struct gf_statfs {
155
40
        u_quad_t bsize;
156
41
        u_quad_t frsize;
166
51
};
167
52
typedef struct gf_statfs gf_statfs;
168
53
 
169
 
static inline void
170
 
gf_statfs_to_statfs (struct gf_statfs *gf_stat, struct statvfs *stat)
171
 
{
172
 
        if (!stat || !gf_stat)
173
 
                return;
174
 
 
175
 
        stat->f_bsize   =  (gf_stat->bsize);
176
 
        stat->f_frsize  =  (gf_stat->frsize);
177
 
        stat->f_blocks  =  (gf_stat->blocks);
178
 
        stat->f_bfree   =  (gf_stat->bfree);
179
 
        stat->f_bavail  =  (gf_stat->bavail);
180
 
        stat->f_files   =  (gf_stat->files);
181
 
        stat->f_ffree   =  (gf_stat->ffree);
182
 
        stat->f_favail  =  (gf_stat->favail);
183
 
        stat->f_fsid    =  (gf_stat->fsid);
184
 
        stat->f_flag    =  (gf_stat->flag);
185
 
        stat->f_namemax =  (gf_stat->namemax);
186
 
}
187
 
 
188
 
 
189
 
static inline void
190
 
gf_statfs_from_statfs (struct gf_statfs *gf_stat, struct statvfs *stat)
191
 
{
192
 
        if (!stat || !gf_stat)
193
 
                return;
194
 
 
195
 
        gf_stat->bsize   = stat->f_bsize;
196
 
        gf_stat->frsize  = stat->f_frsize;
197
 
        gf_stat->blocks  = stat->f_blocks;
198
 
        gf_stat->bfree   = stat->f_bfree;
199
 
        gf_stat->bavail  = stat->f_bavail;
200
 
        gf_stat->files   = stat->f_files;
201
 
        gf_stat->ffree   = stat->f_ffree;
202
 
        gf_stat->favail  = stat->f_favail;
203
 
        gf_stat->fsid    = stat->f_fsid;
204
 
        gf_stat->flag    = stat->f_flag;
205
 
        gf_stat->namemax = stat->f_namemax;
206
 
}
207
 
 
208
54
struct gf_proto_flock {
209
55
        u_int type;
210
56
        u_int whence;
215
61
};
216
62
typedef struct gf_proto_flock gf_proto_flock;
217
63
 
218
 
 
219
 
static inline void
220
 
gf_proto_flock_to_flock (struct gf_proto_flock *gf_proto_flock, struct gf_flock *gf_flock)
221
 
{
222
 
        if (!gf_flock || !gf_proto_flock)
223
 
                return;
224
 
 
225
 
        gf_flock->l_type     = gf_proto_flock->type;
226
 
        gf_flock->l_whence   = gf_proto_flock->whence;
227
 
        gf_flock->l_start    = gf_proto_flock->start;
228
 
        gf_flock->l_len      = gf_proto_flock->len;
229
 
        gf_flock->l_pid      = gf_proto_flock->pid;
230
 
        gf_flock->l_owner    = gf_proto_flock->owner;
231
 
}
232
 
 
233
 
 
234
 
static inline void
235
 
gf_proto_flock_from_flock (struct gf_proto_flock *gf_proto_flock, struct gf_flock *gf_flock)
236
 
{
237
 
        if (!gf_flock || !gf_proto_flock)
238
 
                return;
239
 
 
240
 
        gf_proto_flock->type     =  (gf_flock->l_type);
241
 
        gf_proto_flock->whence   =  (gf_flock->l_whence);
242
 
        gf_proto_flock->start    =  (gf_flock->l_start);
243
 
        gf_proto_flock->len      =  (gf_flock->l_len);
244
 
        gf_proto_flock->pid      =  (gf_flock->l_pid)
245
 
;       gf_proto_flock->owner    =  (gf_flock->l_owner);
246
 
}
247
 
 
248
64
struct gf_iatt {
249
65
        char ia_gfid[16];
250
66
        u_quad_t ia_ino;
266
82
};
267
83
typedef struct gf_iatt gf_iatt;
268
84
 
269
 
 
270
 
static inline void
271
 
gf_stat_to_iatt (struct gf_iatt *gf_stat, struct iatt *iatt)
272
 
{
273
 
        if (!iatt || !gf_stat)
274
 
                return;
275
 
 
276
 
        memcpy (iatt->ia_gfid, gf_stat->ia_gfid, 16);
277
 
        iatt->ia_ino = gf_stat->ia_ino ;
278
 
        iatt->ia_dev = gf_stat->ia_dev ;
279
 
        iatt->ia_type = ia_type_from_st_mode (gf_stat->mode) ;
280
 
        iatt->ia_prot = ia_prot_from_st_mode (gf_stat->mode) ;
281
 
        iatt->ia_nlink = gf_stat->ia_nlink ;
282
 
        iatt->ia_uid = gf_stat->ia_uid ;
283
 
        iatt->ia_gid = gf_stat->ia_gid ;
284
 
        iatt->ia_rdev = gf_stat->ia_rdev ;
285
 
        iatt->ia_size = gf_stat->ia_size ;
286
 
        iatt->ia_blksize = gf_stat->ia_blksize ;
287
 
        iatt->ia_blocks = gf_stat->ia_blocks ;
288
 
        iatt->ia_atime = gf_stat->ia_atime ;
289
 
        iatt->ia_atime_nsec = gf_stat->ia_atime_nsec ;
290
 
        iatt->ia_mtime = gf_stat->ia_mtime ;
291
 
        iatt->ia_mtime_nsec = gf_stat->ia_mtime_nsec ;
292
 
        iatt->ia_ctime = gf_stat->ia_ctime ;
293
 
        iatt->ia_ctime_nsec = gf_stat->ia_ctime_nsec ;
294
 
}
295
 
 
296
 
 
297
 
static inline void
298
 
gf_stat_from_iatt (struct gf_iatt *gf_stat, struct iatt *iatt)
299
 
{
300
 
        if (!iatt || !gf_stat)
301
 
                return;
302
 
 
303
 
        memcpy (gf_stat->ia_gfid, iatt->ia_gfid, 16);
304
 
        gf_stat->ia_ino = iatt->ia_ino ;
305
 
        gf_stat->ia_dev = iatt->ia_dev ;
306
 
        gf_stat->mode   = st_mode_from_ia (iatt->ia_prot, iatt->ia_type);
307
 
        gf_stat->ia_nlink = iatt->ia_nlink ;
308
 
        gf_stat->ia_uid = iatt->ia_uid ;
309
 
        gf_stat->ia_gid = iatt->ia_gid ;
310
 
        gf_stat->ia_rdev = iatt->ia_rdev ;
311
 
        gf_stat->ia_size = iatt->ia_size ;
312
 
        gf_stat->ia_blksize = iatt->ia_blksize ;
313
 
        gf_stat->ia_blocks = iatt->ia_blocks ;
314
 
        gf_stat->ia_atime = iatt->ia_atime ;
315
 
        gf_stat->ia_atime_nsec = iatt->ia_atime_nsec ;
316
 
        gf_stat->ia_mtime = iatt->ia_mtime ;
317
 
        gf_stat->ia_mtime_nsec = iatt->ia_mtime_nsec ;
318
 
        gf_stat->ia_ctime = iatt->ia_ctime ;
319
 
        gf_stat->ia_ctime_nsec = iatt->ia_ctime_nsec ;
320
 
}
321
 
 
322
 
 
323
85
/* Gluster FS Payload structures */
324
86
struct gfs3_stat_req {
325
87
        char gfid[16];
409
171
 
410
172
struct gfs3_rmdir_req {
411
173
        char pargfid[16];
412
 
        int  flags;
 
174
        int flags;
413
175
        char *path;
414
176
        char *bname;
415
177
};