summaryrefslogtreecommitdiffstats
path: root/xlators/nfs/server/src/nfs-generics.c
blob: eb6dc580be203b8ab31803beb41eddbed724b127 (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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
/*
  Copyright (c) 2010 Gluster, Inc. <http://www.gluster.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 Affero 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
  Affero General Public License for more details.

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

#ifndef _CONFIG_H
#define _CONFIG_H
#include "config.h"
#endif


#include "string.h"

#include "inode.h"
#include "nfs.h"
#include "nfs-fops.h"
#include "nfs-inodes.h"
#include "nfs-generics.h"
#include "xlator.h"


int
nfs_fstat (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, fd_t *fd,
           fop_stat_cbk_t cbk, void *local)
{
        int             ret = -EFAULT;

        if ((!nfsx) || (!xl) || (!fd) || (!nfu))
                return ret;

        ret = nfs_fop_fstat (nfsx, xl, nfu, fd, cbk, local);
        return ret;
}


int
nfs_stat (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *pathloc,
          fop_stat_cbk_t cbk, void *local)
{
        int             ret = -EFAULT;

        if ((!nfsx) || (!xl) || (!pathloc) || (!nfu))
                return ret;

        ret = nfs_fop_stat (nfsx, xl, nfu, pathloc, cbk, local);

        return ret;
}


int
nfs_readdirp (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, fd_t *dirfd,
              size_t bufsize, off_t offset, fop_readdir_cbk_t cbk, void *local)
{
        if ((!nfsx) || (!xl) || (!dirfd) || (!nfu))
                return -EFAULT;

        return nfs_fop_readdirp (nfsx, xl, nfu, dirfd, bufsize, offset, cbk,
                                 local);
}


int
nfs_lookup (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *pathloc,
            fop_lookup_cbk_t cbk, void *local)
{
        int             ret = -EFAULT;

        if ((!nfsx) || (!xl) || (!pathloc) || (!nfu))
                return ret;

        ret = nfs_inode_lookup (nfsx, xl, nfu, pathloc, cbk, local);

        return ret;
}

int
nfs_create (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *pathloc,
            int flags, mode_t mode, fop_create_cbk_t cbk, void *local)
{
        int                     ret = -EFAULT;

        if ((!nfsx) || (!xl) || (!pathloc) || (!nfu))
                return ret;

        ret = nfs_inode_create (nfsx, xl, nfu, pathloc, flags, mode, cbk,local);
        return ret;
}


int
nfs_flush (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, fd_t *fd,
           fop_flush_cbk_t cbk, void *local)
{
        return nfs_fop_flush (nfsx, xl, nfu, fd, cbk, local);
}



int
nfs_mkdir (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *pathloc,
           mode_t mode, fop_mkdir_cbk_t cbk, void *local)
{
        int                     ret = -EFAULT;

        if ((!nfsx) || (!xl) || (!pathloc) || (!nfu))
                return ret;

        ret = nfs_inode_mkdir (nfsx, xl, nfu, pathloc, mode, cbk, local);
        return ret;
}



int
nfs_truncate (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *pathloc,
              off_t offset, fop_truncate_cbk_t cbk, void *local)
{
        int     ret = -EFAULT;

        if ((!xl) || (!pathloc) || (!nfu))
                return ret;

        ret = nfs_fop_truncate (nfsx, xl, nfu, pathloc, offset, cbk, local);
        return ret;
}


int
nfs_read (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, fd_t *fd, size_t size,
          off_t offset, fop_readv_cbk_t cbk, void *local)
{
        return nfs_fop_read (nfsx, xl, nfu, fd, size, offset, cbk, local);
}


int
nfs_fsync (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, fd_t *fd,
           int32_t datasync, fop_fsync_cbk_t cbk, void *local)
{
        return nfs_fop_fsync (nfsx, xl, nfu, fd, datasync, cbk, local);
}


int
nfs_write (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, fd_t *fd,
           struct iobuf *srciob, struct iovec *vector, int32_t count,
           off_t offset, fop_writev_cbk_t cbk, void *local)
{
        return nfs_fop_write (nfsx, xl, nfu, fd, srciob, vector, count, offset,
                              cbk, local);
}


int
nfs_open (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *pathloc,
          int32_t flags, fop_open_cbk_t cbk, void *local)
{
        int             ret = -EFAULT;

        if ((!nfsx) || (!xl) || (!pathloc) || (!nfu))
                return ret;

        ret = nfs_inode_open (nfsx, xl, nfu, pathloc, flags, GF_OPEN_NOWB, cbk,
                              local);
        return ret;
}


int
nfs_rename (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *oldloc,
            loc_t *newloc, fop_rename_cbk_t cbk, void *local)
{
        int                     ret = -EFAULT;

        if ((!nfsx) || (!xl) || (!oldloc) || (!newloc) || (!nfu))
                return ret;

        ret = nfs_inode_rename (nfsx, xl, nfu, oldloc, newloc, cbk, local);
        return ret;
}


int
nfs_link (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *oldloc,
          loc_t *newloc, fop_link_cbk_t cbk, void *local)
{
        int                     ret = -EFAULT;

        if ((!nfsx) || (!xl) || (!oldloc) || (!newloc) || (!nfu))
                return ret;

        ret = nfs_inode_link (nfsx, xl, nfu, oldloc, newloc, cbk, local);
        return ret;
}


int
nfs_unlink (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *pathloc,
            fop_unlink_cbk_t cbk, void *local)
{
        int                     ret = -EFAULT;

        if ((!xl) || (!pathloc) || (!nfu))
                return ret;

        ret = nfs_inode_unlink (nfsx, xl, nfu, pathloc, cbk, local);
        return ret;
}


int
nfs_rmdir (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *path,
           fop_rmdir_cbk_t cbk, void *local)
{
        int                     ret = -EFAULT;

        if ((!nfsx) || (!xl) || (!path) || (!nfu))
                return ret;

        ret = nfs_inode_rmdir (nfsx, xl, nfu, path, cbk, local);
        return ret;
}


int
nfs_mknod (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *pathloc,
           mode_t mode, dev_t dev, fop_mknod_cbk_t cbk, void *local)
{
        int                     ret = -EFAULT;

        if ((!nfsx) || (!xl) || (!pathloc) || (!nfu))
                return ret;

        ret = nfs_inode_mknod (nfsx, xl, nfu, pathloc, mode, dev, cbk, local);
        return ret;
}


int
nfs_readlink (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *linkloc,
              fop_readlink_cbk_t cbk, void *local)
{
        int                     ret = -EFAULT;

        if ((!nfsx) || (!xl) || (!linkloc) || (!nfu))
                return ret;

        ret = nfs_fop_readlink (nfsx, xl, nfu, linkloc, NFS_PATH_MAX, cbk,
                                local);
        return ret;
}


int
nfs_symlink (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, char *target,
             loc_t *linkloc, fop_symlink_cbk_t cbk, void *local)
{
        int                     ret = -EFAULT;

        if ((!nfsx) || (!xl) || (!linkloc) || (!target) || (!nfu))
                return ret;

        ret = nfs_inode_symlink (nfsx, xl, nfu, target, linkloc, cbk, local);
        return ret;
}



int
nfs_setattr (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *pathloc,
             struct iatt *buf, int32_t valid, fop_setattr_cbk_t cbk,
             void *local)
{
        int     ret = -EFAULT;

        if ((!nfsx) || (!xl) || (!pathloc) || (!nfu))
                return ret;

        ret = nfs_fop_setattr (nfsx, xl, nfu, pathloc, buf, valid, cbk, local);
        return ret;
}


int
nfs_statfs (xlator_t *nfsx, xlator_t *xl, nfs_user_t *nfu, loc_t *pathloc,
            fop_statfs_cbk_t cbk, void *local)
{
        int     ret = -EFAULT;

        if ((!nfsx) || (!xl) || (!pathloc) || (!nfu))
                return ret;

        ret = nfs_fop_statfs (nfsx, xl, nfu, pathloc, cbk, local);
        return ret;
}

int
nfs_opendir (xlator_t *nfsx, xlator_t *fopxl, nfs_user_t *nfu, loc_t *pathloc,
             fop_opendir_cbk_t cbk, void *local)
{
        if ((!nfsx) || (!fopxl) || (!pathloc) || (!nfu))
                return -EFAULT;

        return nfs_inode_opendir (nfsx, fopxl, nfu, pathloc, cbk, local);
}