vfs_glusterfs: smb_stat_ex_from_stat commenting and cleanup.
[Samba.git] / source3 / modules / vfs_glusterfs.c
blob6807df7c4ae6b3c2e12b5e4346d430596ed60c67
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 /* Helpers to provide 'integer' fds */
50 /* This is global. gfapi's FD operations do not
51 require filesystem context.
54 static glfs_fd_t **glfd_fd;
55 static int glfd_fd_size;
56 static int glfd_fd_used;
58 static int glfd_fd_store(glfs_fd_t *glfd)
60 int i;
61 void *tmp;
63 if (glfd_fd_size == glfd_fd_used) {
64 if (glfd_fd_size >= INT_MAX - 1) {
65 errno = ENOMEM;
66 return -1;
69 tmp = talloc_realloc(glfd_fd, glfd_fd, glfs_fd_t *,
70 glfd_fd_size + 1);
71 if (tmp == NULL) {
72 errno = ENOMEM;
73 return -1;
76 glfd_fd = tmp;
77 glfd_fd[glfd_fd_size] = 0;
78 glfd_fd_size++;
81 for (i = 0; i < glfd_fd_size; i++) {
82 if (glfd_fd[i] == NULL) {
83 break;
86 glfd_fd_used++;
87 glfd_fd[i] = glfd;
88 return i;
91 static glfs_fd_t *glfd_fd_get(int i)
93 if (i < 0 || i >= glfd_fd_size) {
94 return NULL;
96 return glfd_fd[i];
99 static glfs_fd_t *glfd_fd_clear(int i)
101 glfs_fd_t *glfd = NULL;
103 if (i < 0 || i >= glfd_fd_size) {
104 return NULL;
107 glfd = glfd_fd[i];
109 glfd_fd[i] = 0;
110 glfd_fd_used--;
111 return glfd;
115 * Helper to convert struct stat to struct stat_ex.
117 static void smb_stat_ex_from_stat(struct stat_ex *dst, const struct stat *src)
119 ZERO_STRUCTP(dst);
121 dst->st_ex_dev = src->st_dev;
122 dst->st_ex_ino = src->st_ino;
123 dst->st_ex_mode = src->st_mode;
124 dst->st_ex_nlink = src->st_nlink;
125 dst->st_ex_uid = src->st_uid;
126 dst->st_ex_gid = src->st_gid;
127 dst->st_ex_rdev = src->st_rdev;
128 dst->st_ex_size = src->st_size;
129 dst->st_ex_atime.tv_sec = src->st_atime;
130 dst->st_ex_mtime.tv_sec = src->st_mtime;
131 dst->st_ex_ctime.tv_sec = src->st_ctime;
132 dst->st_ex_btime.tv_sec = src->st_mtime;
133 dst->st_ex_blksize = src->st_blksize;
134 dst->st_ex_blocks = src->st_blocks;
135 #ifdef STAT_HAVE_NSEC
136 dst->st_ex_atime.tv_nsec = src->st_atime_nsec;
137 dst->st_ex_mtime.tv_nsec = src->st_mtime_nsec;
138 dst->st_ex_ctime.tv_nsec = src->st_ctime_nsec;
139 dst->st_ex_btime.tv_nsec = src->st_mtime_nsec;
140 #endif
143 /* pre-opened glfs_t */
145 static struct glfs_preopened {
146 char *volume;
147 glfs_t *fs;
148 int ref;
149 struct glfs_preopened *next, *prev;
150 } *glfs_preopened;
153 static int glfs_set_preopened(const char *volume, glfs_t *fs)
155 struct glfs_preopened *entry = NULL;
157 entry = talloc_zero(NULL, struct glfs_preopened);
158 if (!entry) {
159 errno = ENOMEM;
160 return -1;
163 entry->volume = talloc_strdup(entry, volume);
164 if (!entry->volume) {
165 talloc_free(entry);
166 errno = ENOMEM;
167 return -1;
170 entry->fs = fs;
171 entry->ref = 1;
173 DLIST_ADD(glfs_preopened, entry);
175 return 0;
178 static glfs_t *glfs_find_preopened(const char *volume)
180 struct glfs_preopened *entry = NULL;
182 for (entry = glfs_preopened; entry; entry = entry->next) {
183 if (strcmp(entry->volume, volume) == 0) {
184 entry->ref++;
185 return entry->fs;
189 return NULL;
192 static void glfs_clear_preopened(glfs_t *fs)
194 struct glfs_preopened *entry = NULL;
196 for (entry = glfs_preopened; entry; entry = entry->next) {
197 if (entry->fs == fs) {
198 if (--entry->ref)
199 return;
201 DLIST_REMOVE(glfs_preopened, entry);
203 glfs_fini(entry->fs);
204 talloc_free(entry);
209 /* Disk Operations */
211 static int vfs_gluster_connect(struct vfs_handle_struct *handle,
212 const char *service,
213 const char *user)
215 const char *volfile_server;
216 const char *volume;
217 char *logfile;
218 int loglevel;
219 glfs_t *fs = NULL;
220 TALLOC_CTX *tmp_ctx;
221 int ret = 0;
223 tmp_ctx = talloc_new(NULL);
224 if (tmp_ctx == NULL) {
225 ret = -1;
226 goto done;
228 logfile = lp_parm_talloc_string(tmp_ctx, SNUM(handle->conn), "glusterfs",
229 "logfile", NULL);
231 loglevel = lp_parm_int(SNUM(handle->conn), "glusterfs", "loglevel", -1);
233 volfile_server = lp_parm_const_string(SNUM(handle->conn), "glusterfs",
234 "volfile_server", NULL);
235 if (volfile_server == NULL) {
236 volfile_server = DEFAULT_VOLFILE_SERVER;
239 volume = lp_parm_const_string(SNUM(handle->conn), "glusterfs", "volume",
240 NULL);
241 if (volume == NULL) {
242 volume = service;
245 fs = glfs_find_preopened(volume);
246 if (fs) {
247 goto done;
250 fs = glfs_new(volume);
251 if (fs == NULL) {
252 ret = -1;
253 goto done;
256 ret = glfs_set_volfile_server(fs, "tcp", volfile_server, 0);
257 if (ret < 0) {
258 DEBUG(0, ("Failed to set volfile_server %s\n", volfile_server));
259 goto done;
262 ret = glfs_set_xlator_option(fs, "*-md-cache", "cache-posix-acl",
263 "true");
264 if (ret < 0) {
265 DEBUG(0, ("%s: Failed to set xlator options\n", volume));
266 goto done;
269 ret = glfs_set_logging(fs, logfile, loglevel);
270 if (ret < 0) {
271 DEBUG(0, ("%s: Failed to set logfile %s loglevel %d\n",
272 volume, logfile, loglevel));
273 goto done;
276 ret = glfs_init(fs);
277 if (ret < 0) {
278 DEBUG(0, ("%s: Failed to initialize volume (%s)\n",
279 volume, strerror(errno)));
280 goto done;
283 ret = glfs_set_preopened(volume, fs);
284 if (ret < 0) {
285 DEBUG(0, ("%s: Failed to register volume (%s)\n",
286 volume, strerror(errno)));
287 goto done;
289 done:
290 talloc_free(tmp_ctx);
291 if (ret < 0) {
292 if (fs)
293 glfs_fini(fs);
294 return -1;
295 } else {
296 DEBUG(0, ("%s: Initialized volume from server %s\n",
297 volume, volfile_server));
298 handle->data = fs;
299 return 0;
303 static void vfs_gluster_disconnect(struct vfs_handle_struct *handle)
305 glfs_t *fs = NULL;
307 fs = handle->data;
309 glfs_clear_preopened(fs);
312 static uint64_t vfs_gluster_disk_free(struct vfs_handle_struct *handle,
313 const char *path, bool small_query,
314 uint64_t *bsize_p, uint64_t *dfree_p,
315 uint64_t *dsize_p)
317 struct statvfs statvfs = { 0, };
318 int ret;
320 ret = glfs_statvfs(handle->data, path, &statvfs);
321 if (ret < 0) {
322 return -1;
325 if (bsize_p != NULL) {
326 *bsize_p = (uint64_t)statvfs.f_bsize; /* Block size */
328 if (dfree_p != NULL) {
329 *dfree_p = (uint64_t)statvfs.f_bavail; /* Available Block units */
331 if (dsize_p != NULL) {
332 *dsize_p = (uint64_t)statvfs.f_blocks; /* Total Block units */
335 return (uint64_t)statvfs.f_bavail;
338 static int vfs_gluster_get_quota(struct vfs_handle_struct *handle,
339 enum SMB_QUOTA_TYPE qtype, unid_t id,
340 SMB_DISK_QUOTA *qt)
342 errno = ENOSYS;
343 return -1;
346 static int
347 vfs_gluster_set_quota(struct vfs_handle_struct *handle,
348 enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *qt)
350 errno = ENOSYS;
351 return -1;
354 static int vfs_gluster_statvfs(struct vfs_handle_struct *handle,
355 const char *path,
356 struct vfs_statvfs_struct *vfs_statvfs)
358 struct statvfs statvfs = { 0, };
359 int ret;
361 ret = glfs_statvfs(handle->data, path, &statvfs);
362 if (ret < 0) {
363 DEBUG(0, ("glfs_statvfs(%s) failed: %s\n",
364 path, strerror(errno)));
365 return -1;
368 ZERO_STRUCTP(vfs_statvfs);
370 vfs_statvfs->OptimalTransferSize = statvfs.f_frsize;
371 vfs_statvfs->BlockSize = statvfs.f_bsize;
372 vfs_statvfs->TotalBlocks = statvfs.f_blocks;
373 vfs_statvfs->BlocksAvail = statvfs.f_bfree;
374 vfs_statvfs->UserBlocksAvail = statvfs.f_bavail;
375 vfs_statvfs->TotalFileNodes = statvfs.f_files;
376 vfs_statvfs->FreeFileNodes = statvfs.f_ffree;
377 vfs_statvfs->FsIdentifier = statvfs.f_fsid;
378 vfs_statvfs->FsCapabilities =
379 FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES;
381 return ret;
384 static uint32_t vfs_gluster_fs_capabilities(struct vfs_handle_struct *handle,
385 enum timestamp_set_resolution *p_ts_res)
387 uint32_t caps = FILE_CASE_SENSITIVE_SEARCH | FILE_CASE_PRESERVED_NAMES;
389 #ifdef STAT_HAVE_NSEC
390 *p_ts_res = TIMESTAMP_SET_NT_OR_BETTER;
391 #endif
393 return caps;
396 static DIR *vfs_gluster_opendir(struct vfs_handle_struct *handle,
397 const char *path, const char *mask,
398 uint32 attributes)
400 glfs_fd_t *fd;
402 fd = glfs_opendir(handle->data, path);
403 if (fd == NULL) {
404 DEBUG(0, ("glfs_opendir(%s) failed: %s\n",
405 path, strerror(errno)));
408 return (DIR *) fd;
411 static DIR *vfs_gluster_fdopendir(struct vfs_handle_struct *handle,
412 files_struct *fsp, const char *mask,
413 uint32 attributes)
415 return (DIR *) glfd_fd_get(fsp->fh->fd);
418 static int vfs_gluster_closedir(struct vfs_handle_struct *handle, DIR *dirp)
420 return glfs_closedir((void *)dirp);
423 static struct dirent *vfs_gluster_readdir(struct vfs_handle_struct *handle,
424 DIR *dirp, SMB_STRUCT_STAT *sbuf)
426 static char direntbuf[512];
427 int ret;
428 struct stat stat;
429 struct dirent *dirent = 0;
431 if (sbuf != NULL) {
432 ret = glfs_readdirplus_r((void *)dirp, &stat, (void *)direntbuf,
433 &dirent);
434 } else {
435 ret = glfs_readdir_r((void *)dirp, (void *)direntbuf, &dirent);
438 if ((ret < 0) || (dirent == NULL)) {
439 return NULL;
442 if (sbuf != NULL) {
443 smb_stat_ex_from_stat(sbuf, &stat);
446 return dirent;
449 static long vfs_gluster_telldir(struct vfs_handle_struct *handle, DIR *dirp)
451 return glfs_telldir((void *)dirp);
454 static void vfs_gluster_seekdir(struct vfs_handle_struct *handle, DIR *dirp,
455 long offset)
457 glfs_seekdir((void *)dirp, offset);
460 static void vfs_gluster_rewinddir(struct vfs_handle_struct *handle, DIR *dirp)
462 glfs_seekdir((void *)dirp, 0);
465 static void vfs_gluster_init_search_op(struct vfs_handle_struct *handle,
466 DIR *dirp)
468 return;
471 static int vfs_gluster_mkdir(struct vfs_handle_struct *handle, const char *path,
472 mode_t mode)
474 return glfs_mkdir(handle->data, path, mode);
477 static int vfs_gluster_rmdir(struct vfs_handle_struct *handle, const char *path)
479 return glfs_rmdir(handle->data, path);
482 static int vfs_gluster_open(struct vfs_handle_struct *handle,
483 struct smb_filename *smb_fname, files_struct *fsp,
484 int flags, mode_t mode)
486 glfs_fd_t *glfd;
488 if (flags & O_DIRECTORY) {
489 glfd = glfs_opendir(handle->data, smb_fname->base_name);
490 } else if (flags & O_CREAT) {
491 glfd = glfs_creat(handle->data, smb_fname->base_name, flags,
492 mode);
493 } else {
494 glfd = glfs_open(handle->data, smb_fname->base_name, flags);
497 if (glfd == NULL) {
498 return -1;
500 return glfd_fd_store(glfd);
503 static int vfs_gluster_close(struct vfs_handle_struct *handle,
504 files_struct *fsp)
506 return glfs_close(glfd_fd_clear(fsp->fh->fd));
509 static ssize_t vfs_gluster_read(struct vfs_handle_struct *handle,
510 files_struct *fsp, void *data, size_t n)
512 return glfs_read(glfd_fd_get(fsp->fh->fd), data, n, 0);
515 static ssize_t vfs_gluster_pread(struct vfs_handle_struct *handle,
516 files_struct *fsp, void *data, size_t n,
517 off_t offset)
519 return glfs_pread(glfd_fd_get(fsp->fh->fd), data, n, offset, 0);
522 static struct tevent_req *vfs_gluster_pread_send(struct vfs_handle_struct
523 *handle, TALLOC_CTX *mem_ctx,
524 struct tevent_context *ev,
525 files_struct *fsp, void *data,
526 size_t n, off_t offset)
528 errno = ENOTSUP;
529 return NULL;
532 static ssize_t vfs_gluster_pread_recv(struct tevent_req *req, int *err)
534 errno = ENOTSUP;
535 return -1;
538 static ssize_t vfs_gluster_write(struct vfs_handle_struct *handle,
539 files_struct *fsp, const void *data, size_t n)
541 return glfs_write(glfd_fd_get(fsp->fh->fd), data, n, 0);
544 static ssize_t vfs_gluster_pwrite(struct vfs_handle_struct *handle,
545 files_struct *fsp, const void *data,
546 size_t n, off_t offset)
548 return glfs_pwrite(glfd_fd_get(fsp->fh->fd), data, n, offset, 0);
551 static struct tevent_req *vfs_gluster_pwrite_send(struct vfs_handle_struct
552 *handle, TALLOC_CTX *mem_ctx,
553 struct tevent_context *ev,
554 files_struct *fsp,
555 const void *data, size_t n,
556 off_t offset)
558 errno = ENOTSUP;
559 return NULL;
562 static ssize_t vfs_gluster_pwrite_recv(struct tevent_req *req, int *err)
564 errno = ENOTSUP;
565 return -1;
568 static off_t vfs_gluster_lseek(struct vfs_handle_struct *handle,
569 files_struct *fsp, off_t offset, int whence)
571 return glfs_lseek(glfd_fd_get(fsp->fh->fd), offset, whence);
574 static ssize_t vfs_gluster_sendfile(struct vfs_handle_struct *handle, int tofd,
575 files_struct *fromfsp,
576 const DATA_BLOB *hdr,
577 off_t offset, size_t n)
579 errno = ENOTSUP;
580 return -1;
583 static ssize_t vfs_gluster_recvfile(struct vfs_handle_struct *handle,
584 int fromfd, files_struct *tofsp,
585 off_t offset, size_t n)
587 errno = ENOTSUP;
588 return -1;
591 static int vfs_gluster_rename(struct vfs_handle_struct *handle,
592 const struct smb_filename *smb_fname_src,
593 const struct smb_filename *smb_fname_dst)
595 return glfs_rename(handle->data, smb_fname_src->base_name,
596 smb_fname_dst->base_name);
599 static int vfs_gluster_fsync(struct vfs_handle_struct *handle,
600 files_struct *fsp)
602 return glfs_fsync(glfd_fd_get(fsp->fh->fd));
605 static struct tevent_req *vfs_gluster_fsync_send(struct vfs_handle_struct
606 *handle, TALLOC_CTX *mem_ctx,
607 struct tevent_context *ev,
608 files_struct *fsp)
610 errno = ENOTSUP;
611 return NULL;
614 static int vfs_gluster_fsync_recv(struct tevent_req *req, int *err)
616 errno = ENOTSUP;
617 return -1;
620 static int vfs_gluster_stat(struct vfs_handle_struct *handle,
621 struct smb_filename *smb_fname)
623 struct stat st;
624 int ret;
626 ret = glfs_stat(handle->data, smb_fname->base_name, &st);
627 if (ret == 0) {
628 smb_stat_ex_from_stat(&smb_fname->st, &st);
630 if (ret < 0 && errno != ENOENT) {
631 DEBUG(0, ("glfs_stat(%s) failed: %s\n",
632 smb_fname->base_name, strerror(errno)));
634 return ret;
637 static int vfs_gluster_fstat(struct vfs_handle_struct *handle,
638 files_struct *fsp, SMB_STRUCT_STAT *sbuf)
640 struct stat st;
641 int ret;
643 ret = glfs_fstat(glfd_fd_get(fsp->fh->fd), &st);
644 if (ret == 0) {
645 smb_stat_ex_from_stat(sbuf, &st);
647 if (ret < 0) {
648 DEBUG(0, ("glfs_fstat(%d) failed: %s\n",
649 fsp->fh->fd, strerror(errno)));
651 return ret;
654 static int vfs_gluster_lstat(struct vfs_handle_struct *handle,
655 struct smb_filename *smb_fname)
657 struct stat st;
658 int ret;
660 ret = glfs_lstat(handle->data, smb_fname->base_name, &st);
661 if (ret == 0) {
662 smb_stat_ex_from_stat(&smb_fname->st, &st);
664 if (ret < 0 && errno != ENOENT) {
665 DEBUG(0, ("glfs_lstat(%s) failed: %s\n",
666 smb_fname->base_name, strerror(errno)));
668 return ret;
671 static uint64_t vfs_gluster_get_alloc_size(struct vfs_handle_struct *handle,
672 files_struct *fsp,
673 const SMB_STRUCT_STAT *sbuf)
675 return sbuf->st_ex_blocks * 512;
678 static int vfs_gluster_unlink(struct vfs_handle_struct *handle,
679 const struct smb_filename *smb_fname)
681 return glfs_unlink(handle->data, smb_fname->base_name);
684 static int vfs_gluster_chmod(struct vfs_handle_struct *handle,
685 const char *path, mode_t mode)
687 return glfs_chmod(handle->data, path, mode);
690 static int vfs_gluster_fchmod(struct vfs_handle_struct *handle,
691 files_struct *fsp, mode_t mode)
693 return glfs_fchmod(glfd_fd_get(fsp->fh->fd), mode);
696 static int vfs_gluster_chown(struct vfs_handle_struct *handle,
697 const char *path, uid_t uid, gid_t gid)
699 return glfs_chown(handle->data, path, uid, gid);
702 static int vfs_gluster_fchown(struct vfs_handle_struct *handle,
703 files_struct *fsp, uid_t uid, gid_t gid)
705 return glfs_fchown(glfd_fd_get(fsp->fh->fd), uid, gid);
708 static int vfs_gluster_lchown(struct vfs_handle_struct *handle,
709 const char *path, uid_t uid, gid_t gid)
711 return glfs_lchown(handle->data, path, uid, gid);
714 static int vfs_gluster_chdir(struct vfs_handle_struct *handle, const char *path)
716 return glfs_chdir(handle->data, path);
719 static char *vfs_gluster_getwd(struct vfs_handle_struct *handle)
721 char *cwd;
722 char *ret;
724 cwd = SMB_CALLOC_ARRAY(char, PATH_MAX);
725 if (cwd == NULL) {
726 return NULL;
729 ret = glfs_getcwd(handle->data, cwd, PATH_MAX - 1);
730 if (ret == 0) {
731 free(cwd);
733 return ret;
736 static int vfs_gluster_ntimes(struct vfs_handle_struct *handle,
737 const struct smb_filename *smb_fname,
738 struct smb_file_time *ft)
740 struct timespec times[2];
742 if (null_timespec(ft->atime)) {
743 times[0].tv_sec = smb_fname->st.st_ex_atime.tv_sec;
744 times[0].tv_nsec = smb_fname->st.st_ex_atime.tv_nsec;
745 } else {
746 times[0].tv_sec = ft->atime.tv_sec;
747 times[0].tv_nsec = ft->atime.tv_nsec;
750 if (null_timespec(ft->mtime)) {
751 times[1].tv_sec = smb_fname->st.st_ex_mtime.tv_sec;
752 times[1].tv_nsec = smb_fname->st.st_ex_mtime.tv_nsec;
753 } else {
754 times[1].tv_sec = ft->mtime.tv_sec;
755 times[1].tv_nsec = ft->mtime.tv_nsec;
758 if ((timespec_compare(&times[0],
759 &smb_fname->st.st_ex_atime) == 0) &&
760 (timespec_compare(&times[1],
761 &smb_fname->st.st_ex_mtime) == 0)) {
762 return 0;
765 return glfs_utimens(handle->data, smb_fname->base_name, times);
768 static int vfs_gluster_ftruncate(struct vfs_handle_struct *handle,
769 files_struct *fsp, off_t offset)
771 return glfs_ftruncate(glfd_fd_get(fsp->fh->fd), offset);
774 static int vfs_gluster_fallocate(struct vfs_handle_struct *handle,
775 struct files_struct *fsp,
776 enum vfs_fallocate_mode mode,
777 off_t offset, off_t len)
779 errno = ENOTSUP;
780 return -1;
783 static char *vfs_gluster_realpath(struct vfs_handle_struct *handle,
784 const char *path)
786 return glfs_realpath(handle->data, path, 0);
789 static bool vfs_gluster_lock(struct vfs_handle_struct *handle,
790 files_struct *fsp, int op, off_t offset,
791 off_t count, int type)
793 struct flock flock = { 0, };
794 int ret;
796 flock.l_type = type;
797 flock.l_whence = SEEK_SET;
798 flock.l_start = offset;
799 flock.l_len = count;
800 flock.l_pid = 0;
802 ret = glfs_posix_lock(glfd_fd_get(fsp->fh->fd), op, &flock);
804 if (op == F_GETLK) {
805 /* lock query, true if someone else has locked */
806 if ((ret != -1) &&
807 (flock.l_type != F_UNLCK) &&
808 (flock.l_pid != 0) && (flock.l_pid != getpid()))
809 return true;
810 /* not me */
811 return false;
814 if (ret == -1) {
815 return false;
818 return true;
821 static int vfs_gluster_kernel_flock(struct vfs_handle_struct *handle,
822 files_struct *fsp, uint32 share_mode,
823 uint32_t access_mask)
825 errno = ENOSYS;
826 return -1;
829 static int vfs_gluster_linux_setlease(struct vfs_handle_struct *handle,
830 files_struct *fsp, int leasetype)
832 errno = ENOSYS;
833 return -1;
836 static bool vfs_gluster_getlock(struct vfs_handle_struct *handle,
837 files_struct *fsp, off_t *poffset,
838 off_t *pcount, int *ptype, pid_t *ppid)
840 struct flock flock = { 0, };
841 int ret;
843 flock.l_type = *ptype;
844 flock.l_whence = SEEK_SET;
845 flock.l_start = *poffset;
846 flock.l_len = *pcount;
847 flock.l_pid = 0;
849 ret = glfs_posix_lock(glfd_fd_get(fsp->fh->fd), F_GETLK, &flock);
851 if (ret == -1) {
852 return false;
855 *ptype = flock.l_type;
856 *poffset = flock.l_start;
857 *pcount = flock.l_len;
858 *ppid = flock.l_pid;
860 return true;
863 static int vfs_gluster_symlink(struct vfs_handle_struct *handle,
864 const char *oldpath, const char *newpath)
866 return glfs_symlink(handle->data, oldpath, newpath);
869 static int vfs_gluster_readlink(struct vfs_handle_struct *handle,
870 const char *path, char *buf, size_t bufsiz)
872 return glfs_readlink(handle->data, path, buf, bufsiz);
875 static int vfs_gluster_link(struct vfs_handle_struct *handle,
876 const char *oldpath, const char *newpath)
878 return glfs_link(handle->data, oldpath, newpath);
881 static int vfs_gluster_mknod(struct vfs_handle_struct *handle, const char *path,
882 mode_t mode, SMB_DEV_T dev)
884 return glfs_mknod(handle->data, path, mode, dev);
887 static NTSTATUS vfs_gluster_notify_watch(struct vfs_handle_struct *handle,
888 struct sys_notify_context *ctx,
889 const char *path, uint32_t *filter,
890 uint32_t *subdir_filter,
891 void (*callback) (struct sys_notify_context *ctx,
892 void *private_data,
893 struct notify_event *ev),
894 void *private_data, void *handle_p)
896 return NT_STATUS_NOT_IMPLEMENTED;
899 static int vfs_gluster_chflags(struct vfs_handle_struct *handle,
900 const char *path, unsigned int flags)
902 errno = ENOSYS;
903 return -1;
906 static int vfs_gluster_get_real_filename(struct vfs_handle_struct *handle,
907 const char *path, const char *name,
908 TALLOC_CTX *mem_ctx, char **found_name)
910 int ret;
911 char key_buf[NAME_MAX + 64];
912 char val_buf[NAME_MAX + 1];
914 if (strlen(name) >= NAME_MAX) {
915 errno = ENAMETOOLONG;
916 return -1;
919 snprintf(key_buf, NAME_MAX + 64,
920 "user.glusterfs.get_real_filename:%s", name);
922 ret = glfs_getxattr(handle->data, path, key_buf, val_buf, NAME_MAX + 1);
923 if (ret == -1) {
924 if (errno == ENODATA) {
925 errno = EOPNOTSUPP;
927 return -1;
930 *found_name = talloc_strdup(mem_ctx, val_buf);
931 if (found_name[0] == NULL) {
932 errno = ENOMEM;
933 return -1;
935 return 0;
938 static const char *vfs_gluster_connectpath(struct vfs_handle_struct *handle,
939 const char *filename)
941 return handle->conn->connectpath;
944 /* EA Operations */
946 static ssize_t vfs_gluster_getxattr(struct vfs_handle_struct *handle,
947 const char *path, const char *name,
948 void *value, size_t size)
950 return glfs_getxattr(handle->data, path, name, value, size);
953 static ssize_t vfs_gluster_fgetxattr(struct vfs_handle_struct *handle,
954 files_struct *fsp, const char *name,
955 void *value, size_t size)
957 return glfs_fgetxattr(glfd_fd_get(fsp->fh->fd), name, value, size);
960 static ssize_t vfs_gluster_listxattr(struct vfs_handle_struct *handle,
961 const char *path, char *list, size_t size)
963 return glfs_listxattr(handle->data, path, list, size);
966 static ssize_t vfs_gluster_flistxattr(struct vfs_handle_struct *handle,
967 files_struct *fsp, char *list,
968 size_t size)
970 return glfs_flistxattr(glfd_fd_get(fsp->fh->fd), list, size);
973 static int vfs_gluster_removexattr(struct vfs_handle_struct *handle,
974 const char *path, const char *name)
976 return glfs_removexattr(handle->data, path, name);
979 static int vfs_gluster_fremovexattr(struct vfs_handle_struct *handle,
980 files_struct *fsp, const char *name)
982 return glfs_fremovexattr(glfd_fd_get(fsp->fh->fd), name);
985 static int vfs_gluster_setxattr(struct vfs_handle_struct *handle,
986 const char *path, const char *name,
987 const void *value, size_t size, int flags)
989 return glfs_setxattr(handle->data, path, name, value, size, flags);
992 static int vfs_gluster_fsetxattr(struct vfs_handle_struct *handle,
993 files_struct *fsp, const char *name,
994 const void *value, size_t size, int flags)
996 return glfs_fsetxattr(glfd_fd_get(fsp->fh->fd), name, value, size,
997 flags);
1000 /* AIO Operations */
1002 static bool vfs_gluster_aio_force(struct vfs_handle_struct *handle,
1003 files_struct *fsp)
1005 return false;
1008 /* Offline Operations */
1010 static bool vfs_gluster_is_offline(struct vfs_handle_struct *handle,
1011 const struct smb_filename *fname,
1012 SMB_STRUCT_STAT *sbuf)
1014 return false;
1017 static int vfs_gluster_set_offline(struct vfs_handle_struct *handle,
1018 const struct smb_filename *fname)
1020 errno = ENOTSUP;
1021 return -1;
1025 Gluster ACL Format:
1027 Size = 4 (header) + N * 8 (entry)
1029 Offset Size Field (Little Endian)
1030 -------------------------------------
1031 0-3 4-byte Version
1033 4-5 2-byte Entry-1 tag
1034 6-7 2-byte Entry-1 perm
1035 8-11 4-byte Entry-1 id
1037 12-13 2-byte Entry-2 tag
1038 14-15 2-byte Entry-2 perm
1039 16-19 4-byte Entry-2 id
1045 /* header version */
1046 #define GLUSTER_ACL_VERSION 2
1048 /* perm bits */
1049 #define GLUSTER_ACL_READ 0x04
1050 #define GLUSTER_ACL_WRITE 0x02
1051 #define GLUSTER_ACL_EXECUTE 0x01
1053 /* tag values */
1054 #define GLUSTER_ACL_UNDEFINED_TAG 0x00
1055 #define GLUSTER_ACL_USER_OBJ 0x01
1056 #define GLUSTER_ACL_USER 0x02
1057 #define GLUSTER_ACL_GROUP_OBJ 0x04
1058 #define GLUSTER_ACL_GROUP 0x08
1059 #define GLUSTER_ACL_MASK 0x10
1060 #define GLUSTER_ACL_OTHER 0x20
1062 #define GLUSTER_ACL_UNDEFINED_ID (-1)
1064 #define GLUSTER_ACL_HEADER_SIZE 4
1065 #define GLUSTER_ACL_ENTRY_SIZE 8
1067 static SMB_ACL_T gluster_to_smb_acl(const char *buf, size_t xattr_size,
1068 TALLOC_CTX *mem_ctx)
1070 int count;
1071 size_t size;
1072 struct smb_acl_entry *smb_ace;
1073 struct smb_acl_t *result;
1074 int i;
1075 int offset;
1076 uint16_t tag;
1077 uint16_t perm;
1078 uint32_t id;
1080 size = xattr_size;
1082 if (size < GLUSTER_ACL_HEADER_SIZE) {
1083 /* ACL should be at least as big as the header (4 bytes) */
1084 errno = EINVAL;
1085 return NULL;
1088 size -= GLUSTER_ACL_HEADER_SIZE; /* size of header = 4 bytes */
1090 if (size % GLUSTER_ACL_ENTRY_SIZE) {
1091 /* Size of entries must strictly be a multiple of
1092 size of an ACE (8 bytes)
1094 errno = EINVAL;
1095 return NULL;
1098 count = size / GLUSTER_ACL_ENTRY_SIZE;
1100 /* Version is the first 4 bytes of the ACL */
1101 if (IVAL(buf, 0) != GLUSTER_ACL_VERSION) {
1102 DEBUG(0, ("Unknown gluster ACL version: %d\n",
1103 IVAL(buf, 0)));
1104 return NULL;
1106 offset = GLUSTER_ACL_HEADER_SIZE;
1108 result = sys_acl_init(mem_ctx);
1109 if (!result) {
1110 errno = ENOMEM;
1111 return NULL;
1114 result->acl = talloc_array(result, struct smb_acl_entry, count);
1115 if (!result->acl) {
1116 errno = ENOMEM;
1117 talloc_free(result);
1118 return NULL;
1121 result->count = count;
1123 smb_ace = result->acl;
1125 for (i = 0; i < count; i++) {
1126 /* TAG is the first 2 bytes of an entry */
1127 tag = SVAL(buf, offset);
1128 offset += 2;
1130 /* PERM is the next 2 bytes of an entry */
1131 perm = SVAL(buf, offset);
1132 offset += 2;
1134 /* ID is the last 4 bytes of an entry */
1135 id = IVAL(buf, offset);
1136 offset += 4;
1138 switch(tag) {
1139 case GLUSTER_ACL_USER:
1140 smb_ace->a_type = SMB_ACL_USER;
1141 break;
1142 case GLUSTER_ACL_USER_OBJ:
1143 smb_ace->a_type = SMB_ACL_USER_OBJ;
1144 break;
1145 case GLUSTER_ACL_GROUP:
1146 smb_ace->a_type = SMB_ACL_GROUP;
1147 break;
1148 case GLUSTER_ACL_GROUP_OBJ:
1149 smb_ace->a_type = SMB_ACL_GROUP_OBJ;
1150 break;
1151 case GLUSTER_ACL_OTHER:
1152 smb_ace->a_type = SMB_ACL_OTHER;
1153 break;
1154 case GLUSTER_ACL_MASK:
1155 smb_ace->a_type = SMB_ACL_MASK;
1156 break;
1157 default:
1158 DEBUG(0, ("unknown tag type %d\n", (unsigned int) tag));
1159 return NULL;
1163 switch(smb_ace->a_type) {
1164 case SMB_ACL_USER:
1165 smb_ace->info.user.uid = id;
1166 break;
1167 case SMB_ACL_GROUP:
1168 smb_ace->info.group.gid = id;
1169 break;
1170 default:
1171 break;
1174 smb_ace->a_perm = 0;
1175 smb_ace->a_perm |=
1176 ((perm & GLUSTER_ACL_READ) ? SMB_ACL_READ : 0);
1177 smb_ace->a_perm |=
1178 ((perm & GLUSTER_ACL_WRITE) ? SMB_ACL_WRITE : 0);
1179 smb_ace->a_perm |=
1180 ((perm & GLUSTER_ACL_EXECUTE) ? SMB_ACL_EXECUTE : 0);
1182 smb_ace++;
1185 return result;
1189 static int gluster_ace_cmp(const void *left, const void *right)
1191 int ret = 0;
1192 uint16_t tag_left, tag_right;
1193 uint32_t id_left, id_right;
1196 Sorting precedence:
1198 - Smaller TAG values must be earlier.
1200 - Within same TAG, smaller identifiers must be earlier, E.g:
1201 UID 0 entry must be earlier than UID 200
1202 GID 17 entry must be earlier than GID 19
1205 /* TAG is the first element in the entry */
1206 tag_left = SVAL(left, 0);
1207 tag_right = SVAL(right, 0);
1209 ret = (tag_left - tag_right);
1210 if (!ret) {
1211 /* ID is the third element in the entry, after two short
1212 integers (tag and perm), i.e at offset 4.
1214 id_left = IVAL(left, 4);
1215 id_right = IVAL(right, 4);
1216 ret = id_left - id_right;
1219 return ret;
1223 static ssize_t smb_to_gluster_acl(SMB_ACL_T theacl, char *buf, size_t len)
1225 ssize_t size;
1226 struct smb_acl_entry *smb_ace;
1227 int i;
1228 int count;
1229 uint16_t tag;
1230 uint16_t perm;
1231 uint32_t id;
1232 int offset;
1234 count = theacl->count;
1236 size = GLUSTER_ACL_HEADER_SIZE + (count * GLUSTER_ACL_ENTRY_SIZE);
1237 if (!buf) {
1238 return size;
1241 if (len < size) {
1242 errno = ERANGE;
1243 return -1;
1246 smb_ace = theacl->acl;
1248 /* Version is the first 4 bytes of the ACL */
1249 SIVAL(buf, 0, GLUSTER_ACL_VERSION);
1250 offset = GLUSTER_ACL_HEADER_SIZE;
1252 for (i = 0; i < count; i++) {
1253 /* Calculate tag */
1254 switch(smb_ace->a_type) {
1255 case SMB_ACL_USER:
1256 tag = GLUSTER_ACL_USER;
1257 break;
1258 case SMB_ACL_USER_OBJ:
1259 tag = GLUSTER_ACL_USER_OBJ;
1260 break;
1261 case SMB_ACL_GROUP:
1262 tag = GLUSTER_ACL_GROUP;
1263 break;
1264 case SMB_ACL_GROUP_OBJ:
1265 tag = GLUSTER_ACL_GROUP_OBJ;
1266 break;
1267 case SMB_ACL_OTHER:
1268 tag = GLUSTER_ACL_OTHER;
1269 break;
1270 case SMB_ACL_MASK:
1271 tag = GLUSTER_ACL_MASK;
1272 break;
1273 default:
1274 DEBUG(0, ("Unknown tag value %d\n",
1275 smb_ace->a_type));
1276 errno = EINVAL;
1277 return -1;
1281 /* Calculate id */
1282 switch(smb_ace->a_type) {
1283 case SMB_ACL_USER:
1284 id = smb_ace->info.user.uid;
1285 break;
1286 case SMB_ACL_GROUP:
1287 id = smb_ace->info.group.gid;
1288 break;
1289 default:
1290 id = GLUSTER_ACL_UNDEFINED_ID;
1291 break;
1294 /* Calculate perm */
1295 perm = 0;
1297 perm |=
1298 ((smb_ace->a_perm & SMB_ACL_READ) ? GLUSTER_ACL_READ : 0);
1299 perm |=
1300 ((smb_ace->a_perm & SMB_ACL_WRITE) ? GLUSTER_ACL_WRITE : 0);
1301 perm |=
1302 ((smb_ace->a_perm & SMB_ACL_EXECUTE) ? GLUSTER_ACL_EXECUTE : 0);
1305 /* TAG is the first 2 bytes of an entry */
1306 SSVAL(buf, offset, tag);
1307 offset += 2;
1309 /* PERM is the next 2 bytes of an entry */
1310 SSVAL(buf, offset, perm);
1311 offset += 2;
1313 /* ID is the last 4 bytes of an entry */
1314 SIVAL(buf, offset, id);
1315 offset += 4;
1317 smb_ace++;
1320 /* Skip the header, sort @count number of 8-byte entries */
1321 qsort(buf+GLUSTER_ACL_HEADER_SIZE, count, GLUSTER_ACL_ENTRY_SIZE,
1322 gluster_ace_cmp);
1324 return size;
1328 static SMB_ACL_T vfs_gluster_sys_acl_get_file(struct vfs_handle_struct *handle,
1329 const char *path_p,
1330 SMB_ACL_TYPE_T type,
1331 TALLOC_CTX *mem_ctx)
1333 struct smb_acl_t *result;
1334 char *buf;
1335 const char *key;
1336 ssize_t ret;
1338 switch (type) {
1339 case SMB_ACL_TYPE_ACCESS:
1340 key = "system.posix_acl_access";
1341 break;
1342 case SMB_ACL_TYPE_DEFAULT:
1343 key = "system.posix_acl_default";
1344 break;
1345 default:
1346 errno = EINVAL;
1347 return NULL;
1350 ret = glfs_getxattr(handle->data, path_p, key, 0, 0);
1351 if (ret <= 0) {
1352 return NULL;
1355 buf = alloca(ret);
1356 ret = glfs_getxattr(handle->data, path_p, key, buf, ret);
1357 if (ret <= 0) {
1358 return NULL;
1361 result = gluster_to_smb_acl(buf, ret, mem_ctx);
1363 return result;
1366 static SMB_ACL_T vfs_gluster_sys_acl_get_fd(struct vfs_handle_struct *handle,
1367 struct files_struct *fsp,
1368 TALLOC_CTX *mem_ctx)
1370 struct smb_acl_t *result;
1371 int ret;
1372 char *buf;
1374 ret = glfs_fgetxattr(glfd_fd_get(fsp->fh->fd),
1375 "system.posix_acl_access", 0, 0);
1376 if (ret <= 0) {
1377 return NULL;
1380 buf = alloca(ret);
1381 ret = glfs_fgetxattr(glfd_fd_get(fsp->fh->fd),
1382 "system.posix_acl_access", buf, ret);
1383 if (ret <= 0) {
1384 return NULL;
1387 result = gluster_to_smb_acl(buf, ret, mem_ctx);
1389 return result;
1392 static int vfs_gluster_sys_acl_set_file(struct vfs_handle_struct *handle,
1393 const char *name,
1394 SMB_ACL_TYPE_T acltype,
1395 SMB_ACL_T theacl)
1397 int ret;
1398 const char *key;
1399 char *buf;
1400 ssize_t size;
1402 switch (acltype) {
1403 case SMB_ACL_TYPE_ACCESS:
1404 key = "system.posix_acl_access";
1405 break;
1406 case SMB_ACL_TYPE_DEFAULT:
1407 key = "system.posix_acl_default";
1408 break;
1409 default:
1410 errno = EINVAL;
1411 return -1;
1414 size = smb_to_gluster_acl(theacl, 0, 0);
1415 buf = alloca(size);
1417 size = smb_to_gluster_acl(theacl, buf, size);
1418 if (size == -1) {
1419 return -1;
1422 ret = glfs_setxattr(handle->data, name, key, buf, size, 0);
1424 return ret;
1427 static int vfs_gluster_sys_acl_set_fd(struct vfs_handle_struct *handle,
1428 struct files_struct *fsp,
1429 SMB_ACL_T theacl)
1431 int ret;
1432 char *buf;
1433 ssize_t size;
1435 size = smb_to_gluster_acl(theacl, 0, 0);
1436 buf = alloca(size);
1438 size = smb_to_gluster_acl(theacl, buf, size);
1439 if (size == -1) {
1440 return -1;
1443 ret = glfs_fsetxattr(glfd_fd_get(fsp->fh->fd),
1444 "system.posix_acl_access", buf, size, 0);
1445 return ret;
1448 static int vfs_gluster_sys_acl_delete_def_file(struct vfs_handle_struct *handle,
1449 const char *path)
1451 return glfs_removexattr(handle->data, path, "system.posix_acl_default");
1454 static struct vfs_fn_pointers glusterfs_fns = {
1456 /* Disk Operations */
1458 .connect_fn = vfs_gluster_connect,
1459 .disconnect_fn = vfs_gluster_disconnect,
1460 .disk_free_fn = vfs_gluster_disk_free,
1461 .get_quota_fn = vfs_gluster_get_quota,
1462 .set_quota_fn = vfs_gluster_set_quota,
1463 .statvfs_fn = vfs_gluster_statvfs,
1464 .fs_capabilities_fn = vfs_gluster_fs_capabilities,
1466 .get_dfs_referrals_fn = NULL,
1468 /* Directory Operations */
1470 .opendir_fn = vfs_gluster_opendir,
1471 .fdopendir_fn = vfs_gluster_fdopendir,
1472 .readdir_fn = vfs_gluster_readdir,
1473 .seekdir_fn = vfs_gluster_seekdir,
1474 .telldir_fn = vfs_gluster_telldir,
1475 .rewind_dir_fn = vfs_gluster_rewinddir,
1476 .mkdir_fn = vfs_gluster_mkdir,
1477 .rmdir_fn = vfs_gluster_rmdir,
1478 .closedir_fn = vfs_gluster_closedir,
1479 .init_search_op_fn = vfs_gluster_init_search_op,
1481 /* File Operations */
1483 .open_fn = vfs_gluster_open,
1484 .create_file_fn = NULL,
1485 .close_fn = vfs_gluster_close,
1486 .read_fn = vfs_gluster_read,
1487 .pread_fn = vfs_gluster_pread,
1488 .pread_send_fn = vfs_gluster_pread_send,
1489 .pread_recv_fn = vfs_gluster_pread_recv,
1490 .write_fn = vfs_gluster_write,
1491 .pwrite_fn = vfs_gluster_pwrite,
1492 .pwrite_send_fn = vfs_gluster_pwrite_send,
1493 .pwrite_recv_fn = vfs_gluster_pwrite_recv,
1494 .lseek_fn = vfs_gluster_lseek,
1495 .sendfile_fn = vfs_gluster_sendfile,
1496 .recvfile_fn = vfs_gluster_recvfile,
1497 .rename_fn = vfs_gluster_rename,
1498 .fsync_fn = vfs_gluster_fsync,
1499 .fsync_send_fn = vfs_gluster_fsync_send,
1500 .fsync_recv_fn = vfs_gluster_fsync_recv,
1502 .stat_fn = vfs_gluster_stat,
1503 .fstat_fn = vfs_gluster_fstat,
1504 .lstat_fn = vfs_gluster_lstat,
1505 .get_alloc_size_fn = vfs_gluster_get_alloc_size,
1506 .unlink_fn = vfs_gluster_unlink,
1508 .chmod_fn = vfs_gluster_chmod,
1509 .fchmod_fn = vfs_gluster_fchmod,
1510 .chown_fn = vfs_gluster_chown,
1511 .fchown_fn = vfs_gluster_fchown,
1512 .lchown_fn = vfs_gluster_lchown,
1513 .chdir_fn = vfs_gluster_chdir,
1514 .getwd_fn = vfs_gluster_getwd,
1515 .ntimes_fn = vfs_gluster_ntimes,
1516 .ftruncate_fn = vfs_gluster_ftruncate,
1517 .fallocate_fn = vfs_gluster_fallocate,
1518 .lock_fn = vfs_gluster_lock,
1519 .kernel_flock_fn = vfs_gluster_kernel_flock,
1520 .linux_setlease_fn = vfs_gluster_linux_setlease,
1521 .getlock_fn = vfs_gluster_getlock,
1522 .symlink_fn = vfs_gluster_symlink,
1523 .readlink_fn = vfs_gluster_readlink,
1524 .link_fn = vfs_gluster_link,
1525 .mknod_fn = vfs_gluster_mknod,
1526 .realpath_fn = vfs_gluster_realpath,
1527 .notify_watch_fn = vfs_gluster_notify_watch,
1528 .chflags_fn = vfs_gluster_chflags,
1529 .file_id_create_fn = NULL,
1530 .copy_chunk_send_fn = NULL,
1531 .copy_chunk_recv_fn = NULL,
1532 .streaminfo_fn = NULL,
1533 .get_real_filename_fn = vfs_gluster_get_real_filename,
1534 .connectpath_fn = vfs_gluster_connectpath,
1536 .brl_lock_windows_fn = NULL,
1537 .brl_unlock_windows_fn = NULL,
1538 .brl_cancel_windows_fn = NULL,
1539 .strict_lock_fn = NULL,
1540 .strict_unlock_fn = NULL,
1541 .translate_name_fn = NULL,
1542 .fsctl_fn = NULL,
1544 /* NT ACL Operations */
1545 .fget_nt_acl_fn = NULL,
1546 .get_nt_acl_fn = NULL,
1547 .fset_nt_acl_fn = NULL,
1548 .audit_file_fn = NULL,
1550 /* Posix ACL Operations */
1551 .chmod_acl_fn = NULL, /* passthrough to default */
1552 .fchmod_acl_fn = NULL, /* passthrough to default */
1553 .sys_acl_get_file_fn = vfs_gluster_sys_acl_get_file,
1554 .sys_acl_get_fd_fn = vfs_gluster_sys_acl_get_fd,
1555 .sys_acl_blob_get_file_fn = posix_sys_acl_blob_get_file,
1556 .sys_acl_blob_get_fd_fn = posix_sys_acl_blob_get_fd,
1557 .sys_acl_set_file_fn = vfs_gluster_sys_acl_set_file,
1558 .sys_acl_set_fd_fn = vfs_gluster_sys_acl_set_fd,
1559 .sys_acl_delete_def_file_fn = vfs_gluster_sys_acl_delete_def_file,
1561 /* EA Operations */
1562 .getxattr_fn = vfs_gluster_getxattr,
1563 .fgetxattr_fn = vfs_gluster_fgetxattr,
1564 .listxattr_fn = vfs_gluster_listxattr,
1565 .flistxattr_fn = vfs_gluster_flistxattr,
1566 .removexattr_fn = vfs_gluster_removexattr,
1567 .fremovexattr_fn = vfs_gluster_fremovexattr,
1568 .setxattr_fn = vfs_gluster_setxattr,
1569 .fsetxattr_fn = vfs_gluster_fsetxattr,
1571 /* AIO Operations */
1572 .aio_force_fn = vfs_gluster_aio_force,
1574 /* Offline Operations */
1575 .is_offline_fn = vfs_gluster_is_offline,
1576 .set_offline_fn = vfs_gluster_set_offline,
1578 /* Durable handle Operations */
1579 .durable_cookie_fn = NULL,
1580 .durable_disconnect_fn = NULL,
1581 .durable_reconnect_fn = NULL,
1584 NTSTATUS vfs_glusterfs_init(void);
1585 NTSTATUS vfs_glusterfs_init(void)
1587 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
1588 "glusterfs", &glusterfs_fns);