ctdb-vacuum: extract check for full vacuum run out of ctdb_vacuum_db_full()
[Samba.git] / source3 / modules / vfs_glusterfs.c
blobba2d8e8b57d3d3be4ffbec254c61b3687a358666
1 /*
2 Unix SMB/CIFS implementation.
4 Wrap GlusterFS GFAPI calls in vfs functions.
6 Copyright (c) 2013 Anand Avati <avati@redhat.com>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 /**
23 * @file vfs_glusterfs.c
24 * @author Anand Avati <avati@redhat.com>
25 * @date May 2013
26 * @brief Samba VFS module for glusterfs
28 * @todo
29 * - AIO support\n
30 * See, for example \c vfs_aio_linux.c in the \c sourc3/modules directory
31 * - sendfile/recvfile support
33 * A Samba VFS module for GlusterFS, based on Gluster's libgfapi.
34 * This is a "bottom" vfs module (not something to be stacked on top of
35 * another module), and translates (most) calls to the closest actions
36 * available in libgfapi.
40 #include "includes.h"
41 #include "smbd/smbd.h"
42 #include <stdio.h>
43 #include "api/glfs.h"
44 #include "lib/util/dlinklist.h"
46 #define DEFAULT_VOLFILE_SERVER "localhost"
48 /**
49 * Helper to convert struct stat to struct stat_ex.
51 static void smb_stat_ex_from_stat(struct stat_ex *dst, const struct stat *src)
53 ZERO_STRUCTP(dst);
55 dst->st_ex_dev = src->st_dev;
56 dst->st_ex_ino = src->st_ino;
57 dst->st_ex_mode = src->st_mode;
58 dst->st_ex_nlink = src->st_nlink;
59 dst->st_ex_uid = src->st_uid;
60 dst->st_ex_gid = src->st_gid;
61 dst->st_ex_rdev = src->st_rdev;
62 dst->st_ex_size = src->st_size;
63 dst->st_ex_atime.tv_sec = src->st_atime;
64 dst->st_ex_mtime.tv_sec = src->st_mtime;
65 dst->st_ex_ctime.tv_sec = src->st_ctime;
66 dst->st_ex_btime.tv_sec = src->st_mtime;
67 dst->st_ex_blksize = src->st_blksize;
68 dst->st_ex_blocks = src->st_blocks;
69 #ifdef STAT_HAVE_NSEC
70 dst->st_ex_atime.tv_nsec = src->st_atime_nsec;
71 dst->st_ex_mtime.tv_nsec = src->st_mtime_nsec;
72 dst->st_ex_ctime.tv_nsec = src->st_ctime_nsec;
73 dst->st_ex_btime.tv_nsec = src->st_mtime_nsec;
74 #endif
77 /* pre-opened glfs_t */
79 static struct glfs_preopened {
80 char *volume;
81 glfs_t *fs;
82 int ref;
83 struct glfs_preopened *next, *prev;
84 } *glfs_preopened;
87 static int glfs_set_preopened(const char *volume, glfs_t *fs)
89 struct glfs_preopened *entry = NULL;
91 entry = talloc_zero(NULL, struct glfs_preopened);
92 if (!entry) {
93 errno = ENOMEM;
94 return -1;
97 entry->volume = talloc_strdup(entry, volume);
98 if (!entry->volume) {
99 talloc_free(entry);
100 errno = ENOMEM;
101 return -1;
104 entry->fs = fs;
105 entry->ref = 1;
107 DLIST_ADD(glfs_preopened, entry);
109 return 0;
112 static glfs_t *glfs_find_preopened(const char *volume)
114 struct glfs_preopened *entry = NULL;
116 for (entry = glfs_preopened; entry; entry = entry->next) {
117 if (strcmp(entry->volume, volume) == 0) {
118 entry->ref++;
119 return entry->fs;
123 return NULL;
126 static void glfs_clear_preopened(glfs_t *fs)
128 struct glfs_preopened *entry = NULL;
130 for (entry = glfs_preopened; entry; entry = entry->next) {
131 if (entry->fs == fs) {
132 if (--entry->ref)
133 return;
135 DLIST_REMOVE(glfs_preopened, entry);
137 glfs_fini(entry->fs);
138 talloc_free(entry);
143 /* Disk Operations */
145 static int vfs_gluster_connect(struct vfs_handle_struct *handle,
146 const char *service,
147 const char *user)
149 const char *volfile_server;
150 const char *volume;
151 char *logfile;
152 int loglevel;
153 glfs_t *fs = NULL;
154 TALLOC_CTX *tmp_ctx;
155 int ret = 0;
157 tmp_ctx = talloc_new(NULL);
158 if (tmp_ctx == NULL) {
159 ret = -1;
160 goto done;
162 logfile = lp_parm_talloc_string(tmp_ctx, SNUM(handle->conn), "glusterfs",
163 "logfile", NULL);
165 loglevel = lp_parm_int(SNUM(handle->conn), "glusterfs", "loglevel", -1);
167 volfile_server = lp_parm_const_string(SNUM(handle->conn), "glusterfs",
168 "volfile_server", NULL);
169 if (volfile_server == NULL) {
170 volfile_server = DEFAULT_VOLFILE_SERVER;
173 volume = lp_parm_const_string(SNUM(handle->conn), "glusterfs", "volume",
174 NULL);
175 if (volume == NULL) {
176 volume = service;
179 fs = glfs_find_preopened(volume);
180 if (fs) {
181 goto done;
184 fs = glfs_new(volume);
185 if (fs == NULL) {
186 ret = -1;
187 goto done;
190 ret = glfs_set_volfile_server(fs, "tcp", volfile_server, 0);
191 if (ret < 0) {
192 DEBUG(0, ("Failed to set volfile_server %s\n", volfile_server));
193 goto done;
196 ret = glfs_set_xlator_option(fs, "*-md-cache", "cache-posix-acl",
197 "true");
198 if (ret < 0) {
199 DEBUG(0, ("%s: Failed to set xlator options\n", volume));
200 goto done;
203 ret = glfs_set_logging(fs, logfile, loglevel);
204 if (ret < 0) {
205 DEBUG(0, ("%s: Failed to set logfile %s loglevel %d\n",
206 volume, logfile, loglevel));
207 goto done;
210 ret = glfs_init(fs);
211 if (ret < 0) {
212 DEBUG(0, ("%s: Failed to initialize volume (%s)\n",
213 volume, strerror(errno)));
214 goto done;
217 ret = glfs_set_preopened(volume, fs);
218 if (ret < 0) {
219 DEBUG(0, ("%s: Failed to register volume (%s)\n",
220 volume, strerror(errno)));
221 goto done;
223 done:
224 talloc_free(tmp_ctx);
225 if (ret < 0) {
226 if (fs)
227 glfs_fini(fs);
228 return -1;
229 } else {
230 DEBUG(0, ("%s: Initialized volume from server %s\n",
231 volume, volfile_server));
232 handle->data = fs;
233 return 0;
237 static void vfs_gluster_disconnect(struct vfs_handle_struct *handle)
239 glfs_t *fs = NULL;
241 fs = handle->data;
243 glfs_clear_preopened(fs);
246 static uint64_t vfs_gluster_disk_free(struct vfs_handle_struct *handle,
247 const char *path, bool small_query,
248 uint64_t *bsize_p, uint64_t *dfree_p,
249 uint64_t *dsize_p)
251 struct statvfs statvfs = { 0, };
252 int ret;
254 ret = glfs_statvfs(handle->data, path, &statvfs);
255 if (ret < 0) {
256 return -1;
259 if (bsize_p != NULL) {
260 *bsize_p = (uint64_t)statvfs.f_bsize; /* Block size */
262 if (dfree_p != NULL) {
263 *dfree_p = (uint64_t)statvfs.f_bavail; /* Available Block units */
265 if (dsize_p != NULL) {
266 *dsize_p = (uint64_t)statvfs.f_blocks; /* Total Block units */
269 return (uint64_t)statvfs.f_bavail;
272 static int vfs_gluster_get_quota(struct vfs_handle_struct *handle,
273 enum SMB_QUOTA_TYPE qtype, unid_t id,
274 SMB_DISK_QUOTA *qt)
276 errno = ENOSYS;
277 return -1;
280 static int
281 vfs_gluster_set_quota(struct vfs_handle_struct *handle,
282 enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt)
284 errno = ENOSYS;
285 return -1;
288 static int vfs_gluster_statvfs(struct vfs_handle_struct *handle,
289 const char *path,
290 struct vfs_statvfs_struct *vfs_statvfs)
292 struct statvfs statvfs = { 0, };
293 int ret;
295 ret = glfs_statvfs(handle->data, path, &statvfs);
296 if (ret < 0) {
297 DEBUG(0, ("glfs_statvfs(%s) failed: %s\n",
298 path, strerror(errno)));
299 return -1;
302 ZERO_STRUCTP(vfs_statvfs);
304 vfs_statvfs->OptimalTransferSize = statvfs.f_frsize;
305 vfs_statvfs->BlockSize = statvfs.f_bsize;
306 vfs_statvfs->TotalBlocks = statvfs.f_blocks;
307 vfs_statvfs->BlocksAvail = statvfs.f_bfree;
308 vfs_statvfs->UserBlocksAvail = statvfs.f_bavail;
309 vfs_statvfs->TotalFileNodes = statvfs.f_files;
310 vfs_statvfs->FreeFileNodes = statvfs.f_ffree;
311 vfs_statvfs->FsIdentifier = statvfs.f_fsid;
312 vfs_statvfs->FsCapabilities =
313 FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES;
315 return ret;
318 static uint32_t vfs_gluster_fs_capabilities(struct vfs_handle_struct *handle,
319 enum timestamp_set_resolution *p_ts_res)
321 uint32_t caps = FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES;
323 #ifdef STAT_HAVE_NSEC
324 *p_ts_res = TIMESTAMP_SET_NT_OR_BETTER;
325 #endif
327 return caps;
330 static DIR *vfs_gluster_opendir(struct vfs_handle_struct *handle,
331 const char *path, const char *mask,
332 uint32 attributes)
334 glfs_fd_t *fd;
336 fd = glfs_opendir(handle->data, path);
337 if (fd == NULL) {
338 DEBUG(0, ("glfs_opendir(%s) failed: %s\n",
339 path, strerror(errno)));
342 return (DIR *) fd;
345 static DIR *vfs_gluster_fdopendir(struct vfs_handle_struct *handle,
346 files_struct *fsp, const char *mask,
347 uint32 attributes)
349 return (DIR *) *(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp);
352 static int vfs_gluster_closedir(struct vfs_handle_struct *handle, DIR *dirp)
354 return glfs_closedir((void *)dirp);
357 static struct dirent *vfs_gluster_readdir(struct vfs_handle_struct *handle,
358 DIR *dirp, SMB_STRUCT_STAT *sbuf)
360 static char direntbuf[512];
361 int ret;
362 struct stat stat;
363 struct dirent *dirent = 0;
365 if (sbuf != NULL) {
366 ret = glfs_readdirplus_r((void *)dirp, &stat, (void *)direntbuf,
367 &dirent);
368 } else {
369 ret = glfs_readdir_r((void *)dirp, (void *)direntbuf, &dirent);
372 if ((ret < 0) || (dirent == NULL)) {
373 return NULL;
376 if (sbuf != NULL) {
377 smb_stat_ex_from_stat(sbuf, &stat);
380 return dirent;
383 static long vfs_gluster_telldir(struct vfs_handle_struct *handle, DIR *dirp)
385 return glfs_telldir((void *)dirp);
388 static void vfs_gluster_seekdir(struct vfs_handle_struct *handle, DIR *dirp,
389 long offset)
391 glfs_seekdir((void *)dirp, offset);
394 static void vfs_gluster_rewinddir(struct vfs_handle_struct *handle, DIR *dirp)
396 glfs_seekdir((void *)dirp, 0);
399 static void vfs_gluster_init_search_op(struct vfs_handle_struct *handle,
400 DIR *dirp)
402 return;
405 static int vfs_gluster_mkdir(struct vfs_handle_struct *handle, const char *path,
406 mode_t mode)
408 return glfs_mkdir(handle->data, path, mode);
411 static int vfs_gluster_rmdir(struct vfs_handle_struct *handle, const char *path)
413 return glfs_rmdir(handle->data, path);
416 static int vfs_gluster_open(struct vfs_handle_struct *handle,
417 struct smb_filename *smb_fname, files_struct *fsp,
418 int flags, mode_t mode)
420 glfs_fd_t *glfd;
421 glfs_fd_t **p_tmp;
423 if (flags & O_DIRECTORY) {
424 glfd = glfs_opendir(handle->data, smb_fname->base_name);
425 } else if (flags & O_CREAT) {
426 glfd = glfs_creat(handle->data, smb_fname->base_name, flags,
427 mode);
428 } else {
429 glfd = glfs_open(handle->data, smb_fname->base_name, flags);
432 if (glfd == NULL) {
433 return -1;
435 p_tmp = (glfs_fd_t **)VFS_ADD_FSP_EXTENSION(handle, fsp,
436 glfs_fd_t *, NULL);
437 *p_tmp = glfd;
438 /* An arbitrary value for error reporting, so you know its us. */
439 return 13371337;
442 static int vfs_gluster_close(struct vfs_handle_struct *handle,
443 files_struct *fsp)
445 glfs_fd_t *glfd;
446 glfd = *(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp);
447 VFS_REMOVE_FSP_EXTENSION(handle, fsp);
448 return glfs_close(glfd);
451 static ssize_t vfs_gluster_read(struct vfs_handle_struct *handle,
452 files_struct *fsp, void *data, size_t n)
454 return glfs_read(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), data, n, 0);
457 static ssize_t vfs_gluster_pread(struct vfs_handle_struct *handle,
458 files_struct *fsp, void *data, size_t n,
459 off_t offset)
461 return glfs_pread(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), data, n, offset, 0);
464 static struct tevent_req *vfs_gluster_pread_send(struct vfs_handle_struct
465 *handle, TALLOC_CTX *mem_ctx,
466 struct tevent_context *ev,
467 files_struct *fsp, void *data,
468 size_t n, off_t offset)
470 errno = ENOTSUP;
471 return NULL;
474 static ssize_t vfs_gluster_pread_recv(struct tevent_req *req, int *err)
476 errno = ENOTSUP;
477 return -1;
480 static ssize_t vfs_gluster_write(struct vfs_handle_struct *handle,
481 files_struct *fsp, const void *data, size_t n)
483 return glfs_write(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), data, n, 0);
486 static ssize_t vfs_gluster_pwrite(struct vfs_handle_struct *handle,
487 files_struct *fsp, const void *data,
488 size_t n, off_t offset)
490 return glfs_pwrite(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), data, n, offset, 0);
493 static struct tevent_req *vfs_gluster_pwrite_send(struct vfs_handle_struct
494 *handle, TALLOC_CTX *mem_ctx,
495 struct tevent_context *ev,
496 files_struct *fsp,
497 const void *data, size_t n,
498 off_t offset)
500 errno = ENOTSUP;
501 return NULL;
504 static ssize_t vfs_gluster_pwrite_recv(struct tevent_req *req, int *err)
506 errno = ENOTSUP;
507 return -1;
510 static off_t vfs_gluster_lseek(struct vfs_handle_struct *handle,
511 files_struct *fsp, off_t offset, int whence)
513 return glfs_lseek(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), offset, whence);
516 static ssize_t vfs_gluster_sendfile(struct vfs_handle_struct *handle, int tofd,
517 files_struct *fromfsp,
518 const DATA_BLOB *hdr,
519 off_t offset, size_t n)
521 errno = ENOTSUP;
522 return -1;
525 static ssize_t vfs_gluster_recvfile(struct vfs_handle_struct *handle,
526 int fromfd, files_struct *tofsp,
527 off_t offset, size_t n)
529 errno = ENOTSUP;
530 return -1;
533 static int vfs_gluster_rename(struct vfs_handle_struct *handle,
534 const struct smb_filename *smb_fname_src,
535 const struct smb_filename *smb_fname_dst)
537 return glfs_rename(handle->data, smb_fname_src->base_name,
538 smb_fname_dst->base_name);
541 static int vfs_gluster_fsync(struct vfs_handle_struct *handle,
542 files_struct *fsp)
544 return glfs_fsync(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp));
547 static struct tevent_req *vfs_gluster_fsync_send(struct vfs_handle_struct
548 *handle, TALLOC_CTX *mem_ctx,
549 struct tevent_context *ev,
550 files_struct *fsp)
552 errno = ENOTSUP;
553 return NULL;
556 static int vfs_gluster_fsync_recv(struct tevent_req *req, int *err)
558 errno = ENOTSUP;
559 return -1;
562 static int vfs_gluster_stat(struct vfs_handle_struct *handle,
563 struct smb_filename *smb_fname)
565 struct stat st;
566 int ret;
568 ret = glfs_stat(handle->data, smb_fname->base_name, &st);
569 if (ret == 0) {
570 smb_stat_ex_from_stat(&smb_fname->st, &st);
572 if (ret < 0 && errno != ENOENT) {
573 DEBUG(0, ("glfs_stat(%s) failed: %s\n",
574 smb_fname->base_name, strerror(errno)));
576 return ret;
579 static int vfs_gluster_fstat(struct vfs_handle_struct *handle,
580 files_struct *fsp, SMB_STRUCT_STAT *sbuf)
582 struct stat st;
583 int ret;
585 ret = glfs_fstat(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), &st);
586 if (ret == 0) {
587 smb_stat_ex_from_stat(sbuf, &st);
589 if (ret < 0) {
590 DEBUG(0, ("glfs_fstat(%d) failed: %s\n",
591 fsp->fh->fd, strerror(errno)));
593 return ret;
596 static int vfs_gluster_lstat(struct vfs_handle_struct *handle,
597 struct smb_filename *smb_fname)
599 struct stat st;
600 int ret;
602 ret = glfs_lstat(handle->data, smb_fname->base_name, &st);
603 if (ret == 0) {
604 smb_stat_ex_from_stat(&smb_fname->st, &st);
606 if (ret < 0 && errno != ENOENT) {
607 DEBUG(0, ("glfs_lstat(%s) failed: %s\n",
608 smb_fname->base_name, strerror(errno)));
610 return ret;
613 static uint64_t vfs_gluster_get_alloc_size(struct vfs_handle_struct *handle,
614 files_struct *fsp,
615 const SMB_STRUCT_STAT *sbuf)
617 return sbuf->st_ex_blocks * 512;
620 static int vfs_gluster_unlink(struct vfs_handle_struct *handle,
621 const struct smb_filename *smb_fname)
623 return glfs_unlink(handle->data, smb_fname->base_name);
626 static int vfs_gluster_chmod(struct vfs_handle_struct *handle,
627 const char *path, mode_t mode)
629 return glfs_chmod(handle->data, path, mode);
632 static int vfs_gluster_fchmod(struct vfs_handle_struct *handle,
633 files_struct *fsp, mode_t mode)
635 return glfs_fchmod(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), mode);
638 static int vfs_gluster_chown(struct vfs_handle_struct *handle,
639 const char *path, uid_t uid, gid_t gid)
641 return glfs_chown(handle->data, path, uid, gid);
644 static int vfs_gluster_fchown(struct vfs_handle_struct *handle,
645 files_struct *fsp, uid_t uid, gid_t gid)
647 return glfs_fchown(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), uid, gid);
650 static int vfs_gluster_lchown(struct vfs_handle_struct *handle,
651 const char *path, uid_t uid, gid_t gid)
653 return glfs_lchown(handle->data, path, uid, gid);
656 static int vfs_gluster_chdir(struct vfs_handle_struct *handle, const char *path)
658 return glfs_chdir(handle->data, path);
661 static char *vfs_gluster_getwd(struct vfs_handle_struct *handle)
663 char *cwd;
664 char *ret;
666 cwd = SMB_CALLOC_ARRAY(char, PATH_MAX);
667 if (cwd == NULL) {
668 return NULL;
671 ret = glfs_getcwd(handle->data, cwd, PATH_MAX - 1);
672 if (ret == 0) {
673 free(cwd);
675 return ret;
678 static int vfs_gluster_ntimes(struct vfs_handle_struct *handle,
679 const struct smb_filename *smb_fname,
680 struct smb_file_time *ft)
682 struct timespec times[2];
684 if (null_timespec(ft->atime)) {
685 times[0].tv_sec = smb_fname->st.st_ex_atime.tv_sec;
686 times[0].tv_nsec = smb_fname->st.st_ex_atime.tv_nsec;
687 } else {
688 times[0].tv_sec = ft->atime.tv_sec;
689 times[0].tv_nsec = ft->atime.tv_nsec;
692 if (null_timespec(ft->mtime)) {
693 times[1].tv_sec = smb_fname->st.st_ex_mtime.tv_sec;
694 times[1].tv_nsec = smb_fname->st.st_ex_mtime.tv_nsec;
695 } else {
696 times[1].tv_sec = ft->mtime.tv_sec;
697 times[1].tv_nsec = ft->mtime.tv_nsec;
700 if ((timespec_compare(&times[0],
701 &smb_fname->st.st_ex_atime) == 0) &&
702 (timespec_compare(&times[1],
703 &smb_fname->st.st_ex_mtime) == 0)) {
704 return 0;
707 return glfs_utimens(handle->data, smb_fname->base_name, times);
710 static int vfs_gluster_ftruncate(struct vfs_handle_struct *handle,
711 files_struct *fsp, off_t offset)
713 return glfs_ftruncate(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), offset);
716 static int vfs_gluster_fallocate(struct vfs_handle_struct *handle,
717 struct files_struct *fsp,
718 enum vfs_fallocate_mode mode,
719 off_t offset, off_t len)
721 errno = ENOTSUP;
722 return -1;
725 static char *vfs_gluster_realpath(struct vfs_handle_struct *handle,
726 const char *path)
728 return glfs_realpath(handle->data, path, 0);
731 static bool vfs_gluster_lock(struct vfs_handle_struct *handle,
732 files_struct *fsp, int op, off_t offset,
733 off_t count, int type)
735 struct flock flock = { 0, };
736 int ret;
738 flock.l_type = type;
739 flock.l_whence = SEEK_SET;
740 flock.l_start = offset;
741 flock.l_len = count;
742 flock.l_pid = 0;
744 ret = glfs_posix_lock(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), op, &flock);
746 if (op == F_GETLK) {
747 /* lock query, true if someone else has locked */
748 if ((ret != -1) &&
749 (flock.l_type != F_UNLCK) &&
750 (flock.l_pid != 0) && (flock.l_pid != getpid()))
751 return true;
752 /* not me */
753 return false;
756 if (ret == -1) {
757 return false;
760 return true;
763 static int vfs_gluster_kernel_flock(struct vfs_handle_struct *handle,
764 files_struct *fsp, uint32 share_mode,
765 uint32_t access_mask)
767 errno = ENOSYS;
768 return -1;
771 static int vfs_gluster_linux_setlease(struct vfs_handle_struct *handle,
772 files_struct *fsp, int leasetype)
774 errno = ENOSYS;
775 return -1;
778 static bool vfs_gluster_getlock(struct vfs_handle_struct *handle,
779 files_struct *fsp, off_t *poffset,
780 off_t *pcount, int *ptype, pid_t *ppid)
782 struct flock flock = { 0, };
783 int ret;
785 flock.l_type = *ptype;
786 flock.l_whence = SEEK_SET;
787 flock.l_start = *poffset;
788 flock.l_len = *pcount;
789 flock.l_pid = 0;
791 ret = glfs_posix_lock(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), F_GETLK, &flock);
793 if (ret == -1) {
794 return false;
797 *ptype = flock.l_type;
798 *poffset = flock.l_start;
799 *pcount = flock.l_len;
800 *ppid = flock.l_pid;
802 return true;
805 static int vfs_gluster_symlink(struct vfs_handle_struct *handle,
806 const char *oldpath, const char *newpath)
808 return glfs_symlink(handle->data, oldpath, newpath);
811 static int vfs_gluster_readlink(struct vfs_handle_struct *handle,
812 const char *path, char *buf, size_t bufsiz)
814 return glfs_readlink(handle->data, path, buf, bufsiz);
817 static int vfs_gluster_link(struct vfs_handle_struct *handle,
818 const char *oldpath, const char *newpath)
820 return glfs_link(handle->data, oldpath, newpath);
823 static int vfs_gluster_mknod(struct vfs_handle_struct *handle, const char *path,
824 mode_t mode, SMB_DEV_T dev)
826 return glfs_mknod(handle->data, path, mode, dev);
829 static NTSTATUS vfs_gluster_notify_watch(struct vfs_handle_struct *handle,
830 struct sys_notify_context *ctx,
831 const char *path, uint32_t *filter,
832 uint32_t *subdir_filter,
833 void (*callback) (struct sys_notify_context *ctx,
834 void *private_data,
835 struct notify_event *ev),
836 void *private_data, void *handle_p)
838 return NT_STATUS_NOT_IMPLEMENTED;
841 static int vfs_gluster_chflags(struct vfs_handle_struct *handle,
842 const char *path, unsigned int flags)
844 errno = ENOSYS;
845 return -1;
848 static int vfs_gluster_get_real_filename(struct vfs_handle_struct *handle,
849 const char *path, const char *name,
850 TALLOC_CTX *mem_ctx, char **found_name)
852 int ret;
853 char key_buf[NAME_MAX + 64];
854 char val_buf[NAME_MAX + 1];
856 if (strlen(name) >= NAME_MAX) {
857 errno = ENAMETOOLONG;
858 return -1;
861 snprintf(key_buf, NAME_MAX + 64,
862 "user.glusterfs.get_real_filename:%s", name);
864 ret = glfs_getxattr(handle->data, path, key_buf, val_buf, NAME_MAX + 1);
865 if (ret == -1) {
866 if (errno == ENODATA) {
867 errno = EOPNOTSUPP;
869 return -1;
872 *found_name = talloc_strdup(mem_ctx, val_buf);
873 if (found_name[0] == NULL) {
874 errno = ENOMEM;
875 return -1;
877 return 0;
880 static const char *vfs_gluster_connectpath(struct vfs_handle_struct *handle,
881 const char *filename)
883 return handle->conn->connectpath;
886 /* EA Operations */
888 static ssize_t vfs_gluster_getxattr(struct vfs_handle_struct *handle,
889 const char *path, const char *name,
890 void *value, size_t size)
892 return glfs_getxattr(handle->data, path, name, value, size);
895 static ssize_t vfs_gluster_fgetxattr(struct vfs_handle_struct *handle,
896 files_struct *fsp, const char *name,
897 void *value, size_t size)
899 return glfs_fgetxattr(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), name, value, size);
902 static ssize_t vfs_gluster_listxattr(struct vfs_handle_struct *handle,
903 const char *path, char *list, size_t size)
905 return glfs_listxattr(handle->data, path, list, size);
908 static ssize_t vfs_gluster_flistxattr(struct vfs_handle_struct *handle,
909 files_struct *fsp, char *list,
910 size_t size)
912 return glfs_flistxattr(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), list, size);
915 static int vfs_gluster_removexattr(struct vfs_handle_struct *handle,
916 const char *path, const char *name)
918 return glfs_removexattr(handle->data, path, name);
921 static int vfs_gluster_fremovexattr(struct vfs_handle_struct *handle,
922 files_struct *fsp, const char *name)
924 return glfs_fremovexattr(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), name);
927 static int vfs_gluster_setxattr(struct vfs_handle_struct *handle,
928 const char *path, const char *name,
929 const void *value, size_t size, int flags)
931 return glfs_setxattr(handle->data, path, name, value, size, flags);
934 static int vfs_gluster_fsetxattr(struct vfs_handle_struct *handle,
935 files_struct *fsp, const char *name,
936 const void *value, size_t size, int flags)
938 return glfs_fsetxattr(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp), name, value, size,
939 flags);
942 /* AIO Operations */
944 static bool vfs_gluster_aio_force(struct vfs_handle_struct *handle,
945 files_struct *fsp)
947 return false;
950 /* Offline Operations */
952 static bool vfs_gluster_is_offline(struct vfs_handle_struct *handle,
953 const struct smb_filename *fname,
954 SMB_STRUCT_STAT *sbuf)
956 return false;
959 static int vfs_gluster_set_offline(struct vfs_handle_struct *handle,
960 const struct smb_filename *fname)
962 errno = ENOTSUP;
963 return -1;
967 Gluster ACL Format:
969 Size = 4 (header) + N * 8 (entry)
971 Offset Size Field (Little Endian)
972 -------------------------------------
973 0-3 4-byte Version
975 4-5 2-byte Entry-1 tag
976 6-7 2-byte Entry-1 perm
977 8-11 4-byte Entry-1 id
979 12-13 2-byte Entry-2 tag
980 14-15 2-byte Entry-2 perm
981 16-19 4-byte Entry-2 id
987 /* header version */
988 #define GLUSTER_ACL_VERSION 2
990 /* perm bits */
991 #define GLUSTER_ACL_READ 0x04
992 #define GLUSTER_ACL_WRITE 0x02
993 #define GLUSTER_ACL_EXECUTE 0x01
995 /* tag values */
996 #define GLUSTER_ACL_UNDEFINED_TAG 0x00
997 #define GLUSTER_ACL_USER_OBJ 0x01
998 #define GLUSTER_ACL_USER 0x02
999 #define GLUSTER_ACL_GROUP_OBJ 0x04
1000 #define GLUSTER_ACL_GROUP 0x08
1001 #define GLUSTER_ACL_MASK 0x10
1002 #define GLUSTER_ACL_OTHER 0x20
1004 #define GLUSTER_ACL_UNDEFINED_ID (-1)
1006 #define GLUSTER_ACL_HEADER_SIZE 4
1007 #define GLUSTER_ACL_ENTRY_SIZE 8
1009 static SMB_ACL_T gluster_to_smb_acl(const char *buf, size_t xattr_size,
1010 TALLOC_CTX *mem_ctx)
1012 int count;
1013 size_t size;
1014 struct smb_acl_entry *smb_ace;
1015 struct smb_acl_t *result;
1016 int i;
1017 int offset;
1018 uint16_t tag;
1019 uint16_t perm;
1020 uint32_t id;
1022 size = xattr_size;
1024 if (size < GLUSTER_ACL_HEADER_SIZE) {
1025 /* ACL should be at least as big as the header (4 bytes) */
1026 errno = EINVAL;
1027 return NULL;
1030 size -= GLUSTER_ACL_HEADER_SIZE; /* size of header = 4 bytes */
1032 if (size % GLUSTER_ACL_ENTRY_SIZE) {
1033 /* Size of entries must strictly be a multiple of
1034 size of an ACE (8 bytes)
1036 errno = EINVAL;
1037 return NULL;
1040 count = size / GLUSTER_ACL_ENTRY_SIZE;
1042 /* Version is the first 4 bytes of the ACL */
1043 if (IVAL(buf, 0) != GLUSTER_ACL_VERSION) {
1044 DEBUG(0, ("Unknown gluster ACL version: %d\n",
1045 IVAL(buf, 0)));
1046 return NULL;
1048 offset = GLUSTER_ACL_HEADER_SIZE;
1050 result = sys_acl_init(mem_ctx);
1051 if (!result) {
1052 errno = ENOMEM;
1053 return NULL;
1056 result->acl = talloc_array(result, struct smb_acl_entry, count);
1057 if (!result->acl) {
1058 errno = ENOMEM;
1059 talloc_free(result);
1060 return NULL;
1063 result->count = count;
1065 smb_ace = result->acl;
1067 for (i = 0; i < count; i++) {
1068 /* TAG is the first 2 bytes of an entry */
1069 tag = SVAL(buf, offset);
1070 offset += 2;
1072 /* PERM is the next 2 bytes of an entry */
1073 perm = SVAL(buf, offset);
1074 offset += 2;
1076 /* ID is the last 4 bytes of an entry */
1077 id = IVAL(buf, offset);
1078 offset += 4;
1080 switch(tag) {
1081 case GLUSTER_ACL_USER:
1082 smb_ace->a_type = SMB_ACL_USER;
1083 break;
1084 case GLUSTER_ACL_USER_OBJ:
1085 smb_ace->a_type = SMB_ACL_USER_OBJ;
1086 break;
1087 case GLUSTER_ACL_GROUP:
1088 smb_ace->a_type = SMB_ACL_GROUP;
1089 break;
1090 case GLUSTER_ACL_GROUP_OBJ:
1091 smb_ace->a_type = SMB_ACL_GROUP_OBJ;
1092 break;
1093 case GLUSTER_ACL_OTHER:
1094 smb_ace->a_type = SMB_ACL_OTHER;
1095 break;
1096 case GLUSTER_ACL_MASK:
1097 smb_ace->a_type = SMB_ACL_MASK;
1098 break;
1099 default:
1100 DEBUG(0, ("unknown tag type %d\n", (unsigned int) tag));
1101 return NULL;
1105 switch(smb_ace->a_type) {
1106 case SMB_ACL_USER:
1107 smb_ace->info.user.uid = id;
1108 break;
1109 case SMB_ACL_GROUP:
1110 smb_ace->info.group.gid = id;
1111 break;
1112 default:
1113 break;
1116 smb_ace->a_perm = 0;
1117 smb_ace->a_perm |=
1118 ((perm & GLUSTER_ACL_READ) ? SMB_ACL_READ : 0);
1119 smb_ace->a_perm |=
1120 ((perm & GLUSTER_ACL_WRITE) ? SMB_ACL_WRITE : 0);
1121 smb_ace->a_perm |=
1122 ((perm & GLUSTER_ACL_EXECUTE) ? SMB_ACL_EXECUTE : 0);
1124 smb_ace++;
1127 return result;
1131 static int gluster_ace_cmp(const void *left, const void *right)
1133 int ret = 0;
1134 uint16_t tag_left, tag_right;
1135 uint32_t id_left, id_right;
1138 Sorting precedence:
1140 - Smaller TAG values must be earlier.
1142 - Within same TAG, smaller identifiers must be earlier, E.g:
1143 UID 0 entry must be earlier than UID 200
1144 GID 17 entry must be earlier than GID 19
1147 /* TAG is the first element in the entry */
1148 tag_left = SVAL(left, 0);
1149 tag_right = SVAL(right, 0);
1151 ret = (tag_left - tag_right);
1152 if (!ret) {
1153 /* ID is the third element in the entry, after two short
1154 integers (tag and perm), i.e at offset 4.
1156 id_left = IVAL(left, 4);
1157 id_right = IVAL(right, 4);
1158 ret = id_left - id_right;
1161 return ret;
1165 static ssize_t smb_to_gluster_acl(SMB_ACL_T theacl, char *buf, size_t len)
1167 ssize_t size;
1168 struct smb_acl_entry *smb_ace;
1169 int i;
1170 int count;
1171 uint16_t tag;
1172 uint16_t perm;
1173 uint32_t id;
1174 int offset;
1176 count = theacl->count;
1178 size = GLUSTER_ACL_HEADER_SIZE + (count * GLUSTER_ACL_ENTRY_SIZE);
1179 if (!buf) {
1180 return size;
1183 if (len < size) {
1184 errno = ERANGE;
1185 return -1;
1188 smb_ace = theacl->acl;
1190 /* Version is the first 4 bytes of the ACL */
1191 SIVAL(buf, 0, GLUSTER_ACL_VERSION);
1192 offset = GLUSTER_ACL_HEADER_SIZE;
1194 for (i = 0; i < count; i++) {
1195 /* Calculate tag */
1196 switch(smb_ace->a_type) {
1197 case SMB_ACL_USER:
1198 tag = GLUSTER_ACL_USER;
1199 break;
1200 case SMB_ACL_USER_OBJ:
1201 tag = GLUSTER_ACL_USER_OBJ;
1202 break;
1203 case SMB_ACL_GROUP:
1204 tag = GLUSTER_ACL_GROUP;
1205 break;
1206 case SMB_ACL_GROUP_OBJ:
1207 tag = GLUSTER_ACL_GROUP_OBJ;
1208 break;
1209 case SMB_ACL_OTHER:
1210 tag = GLUSTER_ACL_OTHER;
1211 break;
1212 case SMB_ACL_MASK:
1213 tag = GLUSTER_ACL_MASK;
1214 break;
1215 default:
1216 DEBUG(0, ("Unknown tag value %d\n",
1217 smb_ace->a_type));
1218 errno = EINVAL;
1219 return -1;
1223 /* Calculate id */
1224 switch(smb_ace->a_type) {
1225 case SMB_ACL_USER:
1226 id = smb_ace->info.user.uid;
1227 break;
1228 case SMB_ACL_GROUP:
1229 id = smb_ace->info.group.gid;
1230 break;
1231 default:
1232 id = GLUSTER_ACL_UNDEFINED_ID;
1233 break;
1236 /* Calculate perm */
1237 perm = 0;
1239 perm |=
1240 ((smb_ace->a_perm & SMB_ACL_READ) ? GLUSTER_ACL_READ : 0);
1241 perm |=
1242 ((smb_ace->a_perm & SMB_ACL_WRITE) ? GLUSTER_ACL_WRITE : 0);
1243 perm |=
1244 ((smb_ace->a_perm & SMB_ACL_EXECUTE) ? GLUSTER_ACL_EXECUTE : 0);
1247 /* TAG is the first 2 bytes of an entry */
1248 SSVAL(buf, offset, tag);
1249 offset += 2;
1251 /* PERM is the next 2 bytes of an entry */
1252 SSVAL(buf, offset, perm);
1253 offset += 2;
1255 /* ID is the last 4 bytes of an entry */
1256 SIVAL(buf, offset, id);
1257 offset += 4;
1259 smb_ace++;
1262 /* Skip the header, sort @count number of 8-byte entries */
1263 qsort(buf+GLUSTER_ACL_HEADER_SIZE, count, GLUSTER_ACL_ENTRY_SIZE,
1264 gluster_ace_cmp);
1266 return size;
1270 static SMB_ACL_T vfs_gluster_sys_acl_get_file(struct vfs_handle_struct *handle,
1271 const char *path_p,
1272 SMB_ACL_TYPE_T type,
1273 TALLOC_CTX *mem_ctx)
1275 struct smb_acl_t *result;
1276 char *buf;
1277 const char *key;
1278 ssize_t ret;
1280 switch (type) {
1281 case SMB_ACL_TYPE_ACCESS:
1282 key = "system.posix_acl_access";
1283 break;
1284 case SMB_ACL_TYPE_DEFAULT:
1285 key = "system.posix_acl_default";
1286 break;
1287 default:
1288 errno = EINVAL;
1289 return NULL;
1292 ret = glfs_getxattr(handle->data, path_p, key, 0, 0);
1293 if (ret <= 0) {
1294 return NULL;
1297 buf = alloca(ret);
1298 ret = glfs_getxattr(handle->data, path_p, key, buf, ret);
1299 if (ret <= 0) {
1300 return NULL;
1303 result = gluster_to_smb_acl(buf, ret, mem_ctx);
1305 return result;
1308 static SMB_ACL_T vfs_gluster_sys_acl_get_fd(struct vfs_handle_struct *handle,
1309 struct files_struct *fsp,
1310 TALLOC_CTX *mem_ctx)
1312 struct smb_acl_t *result;
1313 int ret;
1314 char *buf;
1315 glfs_fd_t *glfd;
1317 glfd = *(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp);
1318 ret = glfs_fgetxattr(glfd, "system.posix_acl_access", 0, 0);
1319 if (ret <= 0) {
1320 return NULL;
1323 buf = alloca(ret);
1324 ret = glfs_fgetxattr(glfd, "system.posix_acl_access", buf, ret);
1325 if (ret <= 0) {
1326 return NULL;
1329 result = gluster_to_smb_acl(buf, ret, mem_ctx);
1331 return result;
1334 static int vfs_gluster_sys_acl_set_file(struct vfs_handle_struct *handle,
1335 const char *name,
1336 SMB_ACL_TYPE_T acltype,
1337 SMB_ACL_T theacl)
1339 int ret;
1340 const char *key;
1341 char *buf;
1342 ssize_t size;
1344 switch (acltype) {
1345 case SMB_ACL_TYPE_ACCESS:
1346 key = "system.posix_acl_access";
1347 break;
1348 case SMB_ACL_TYPE_DEFAULT:
1349 key = "system.posix_acl_default";
1350 break;
1351 default:
1352 errno = EINVAL;
1353 return -1;
1356 size = smb_to_gluster_acl(theacl, 0, 0);
1357 buf = alloca(size);
1359 size = smb_to_gluster_acl(theacl, buf, size);
1360 if (size == -1) {
1361 return -1;
1364 ret = glfs_setxattr(handle->data, name, key, buf, size, 0);
1366 return ret;
1369 static int vfs_gluster_sys_acl_set_fd(struct vfs_handle_struct *handle,
1370 struct files_struct *fsp,
1371 SMB_ACL_T theacl)
1373 int ret;
1374 char *buf;
1375 ssize_t size;
1377 size = smb_to_gluster_acl(theacl, 0, 0);
1378 buf = alloca(size);
1380 size = smb_to_gluster_acl(theacl, buf, size);
1381 if (size == -1) {
1382 return -1;
1385 ret = glfs_fsetxattr(*(glfs_fd_t **)VFS_FETCH_FSP_EXTENSION(handle, fsp),
1386 "system.posix_acl_access", buf, size, 0);
1387 return ret;
1390 static int vfs_gluster_sys_acl_delete_def_file(struct vfs_handle_struct *handle,
1391 const char *path)
1393 return glfs_removexattr(handle->data, path, "system.posix_acl_default");
1396 static struct vfs_fn_pointers glusterfs_fns = {
1398 /* Disk Operations */
1400 .connect_fn = vfs_gluster_connect,
1401 .disconnect_fn = vfs_gluster_disconnect,
1402 .disk_free_fn = vfs_gluster_disk_free,
1403 .get_quota_fn = vfs_gluster_get_quota,
1404 .set_quota_fn = vfs_gluster_set_quota,
1405 .statvfs_fn = vfs_gluster_statvfs,
1406 .fs_capabilities_fn = vfs_gluster_fs_capabilities,
1408 .get_dfs_referrals_fn = NULL,
1410 /* Directory Operations */
1412 .opendir_fn = vfs_gluster_opendir,
1413 .fdopendir_fn = vfs_gluster_fdopendir,
1414 .readdir_fn = vfs_gluster_readdir,
1415 .seekdir_fn = vfs_gluster_seekdir,
1416 .telldir_fn = vfs_gluster_telldir,
1417 .rewind_dir_fn = vfs_gluster_rewinddir,
1418 .mkdir_fn = vfs_gluster_mkdir,
1419 .rmdir_fn = vfs_gluster_rmdir,
1420 .closedir_fn = vfs_gluster_closedir,
1421 .init_search_op_fn = vfs_gluster_init_search_op,
1423 /* File Operations */
1425 .open_fn = vfs_gluster_open,
1426 .create_file_fn = NULL,
1427 .close_fn = vfs_gluster_close,
1428 .read_fn = vfs_gluster_read,
1429 .pread_fn = vfs_gluster_pread,
1430 .pread_send_fn = vfs_gluster_pread_send,
1431 .pread_recv_fn = vfs_gluster_pread_recv,
1432 .write_fn = vfs_gluster_write,
1433 .pwrite_fn = vfs_gluster_pwrite,
1434 .pwrite_send_fn = vfs_gluster_pwrite_send,
1435 .pwrite_recv_fn = vfs_gluster_pwrite_recv,
1436 .lseek_fn = vfs_gluster_lseek,
1437 .sendfile_fn = vfs_gluster_sendfile,
1438 .recvfile_fn = vfs_gluster_recvfile,
1439 .rename_fn = vfs_gluster_rename,
1440 .fsync_fn = vfs_gluster_fsync,
1441 .fsync_send_fn = vfs_gluster_fsync_send,
1442 .fsync_recv_fn = vfs_gluster_fsync_recv,
1444 .stat_fn = vfs_gluster_stat,
1445 .fstat_fn = vfs_gluster_fstat,
1446 .lstat_fn = vfs_gluster_lstat,
1447 .get_alloc_size_fn = vfs_gluster_get_alloc_size,
1448 .unlink_fn = vfs_gluster_unlink,
1450 .chmod_fn = vfs_gluster_chmod,
1451 .fchmod_fn = vfs_gluster_fchmod,
1452 .chown_fn = vfs_gluster_chown,
1453 .fchown_fn = vfs_gluster_fchown,
1454 .lchown_fn = vfs_gluster_lchown,
1455 .chdir_fn = vfs_gluster_chdir,
1456 .getwd_fn = vfs_gluster_getwd,
1457 .ntimes_fn = vfs_gluster_ntimes,
1458 .ftruncate_fn = vfs_gluster_ftruncate,
1459 .fallocate_fn = vfs_gluster_fallocate,
1460 .lock_fn = vfs_gluster_lock,
1461 .kernel_flock_fn = vfs_gluster_kernel_flock,
1462 .linux_setlease_fn = vfs_gluster_linux_setlease,
1463 .getlock_fn = vfs_gluster_getlock,
1464 .symlink_fn = vfs_gluster_symlink,
1465 .readlink_fn = vfs_gluster_readlink,
1466 .link_fn = vfs_gluster_link,
1467 .mknod_fn = vfs_gluster_mknod,
1468 .realpath_fn = vfs_gluster_realpath,
1469 .notify_watch_fn = vfs_gluster_notify_watch,
1470 .chflags_fn = vfs_gluster_chflags,
1471 .file_id_create_fn = NULL,
1472 .copy_chunk_send_fn = NULL,
1473 .copy_chunk_recv_fn = NULL,
1474 .streaminfo_fn = NULL,
1475 .get_real_filename_fn = vfs_gluster_get_real_filename,
1476 .connectpath_fn = vfs_gluster_connectpath,
1478 .brl_lock_windows_fn = NULL,
1479 .brl_unlock_windows_fn = NULL,
1480 .brl_cancel_windows_fn = NULL,
1481 .strict_lock_fn = NULL,
1482 .strict_unlock_fn = NULL,
1483 .translate_name_fn = NULL,
1484 .fsctl_fn = NULL,
1486 /* NT ACL Operations */
1487 .fget_nt_acl_fn = NULL,
1488 .get_nt_acl_fn = NULL,
1489 .fset_nt_acl_fn = NULL,
1490 .audit_file_fn = NULL,
1492 /* Posix ACL Operations */
1493 .chmod_acl_fn = NULL, /* passthrough to default */
1494 .fchmod_acl_fn = NULL, /* passthrough to default */
1495 .sys_acl_get_file_fn = vfs_gluster_sys_acl_get_file,
1496 .sys_acl_get_fd_fn = vfs_gluster_sys_acl_get_fd,
1497 .sys_acl_blob_get_file_fn = posix_sys_acl_blob_get_file,
1498 .sys_acl_blob_get_fd_fn = posix_sys_acl_blob_get_fd,
1499 .sys_acl_set_file_fn = vfs_gluster_sys_acl_set_file,
1500 .sys_acl_set_fd_fn = vfs_gluster_sys_acl_set_fd,
1501 .sys_acl_delete_def_file_fn = vfs_gluster_sys_acl_delete_def_file,
1503 /* EA Operations */
1504 .getxattr_fn = vfs_gluster_getxattr,
1505 .fgetxattr_fn = vfs_gluster_fgetxattr,
1506 .listxattr_fn = vfs_gluster_listxattr,
1507 .flistxattr_fn = vfs_gluster_flistxattr,
1508 .removexattr_fn = vfs_gluster_removexattr,
1509 .fremovexattr_fn = vfs_gluster_fremovexattr,
1510 .setxattr_fn = vfs_gluster_setxattr,
1511 .fsetxattr_fn = vfs_gluster_fsetxattr,
1513 /* AIO Operations */
1514 .aio_force_fn = vfs_gluster_aio_force,
1516 /* Offline Operations */
1517 .is_offline_fn = vfs_gluster_is_offline,
1518 .set_offline_fn = vfs_gluster_set_offline,
1520 /* Durable handle Operations */
1521 .durable_cookie_fn = NULL,
1522 .durable_disconnect_fn = NULL,
1523 .durable_reconnect_fn = NULL,
1526 NTSTATUS vfs_glusterfs_init(void);
1527 NTSTATUS vfs_glusterfs_init(void)
1529 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
1530 "glusterfs", &glusterfs_fns);