2 Unix SMB/CIFS implementation.
3 Wrap gpfs calls in vfs functions.
5 Copyright (C) Christian Ambach <cambach1@de.ibm.com> 2006
7 Major code contributions by Chetan Shringarpure <chetan.sh@in.ibm.com>
8 and Gomati Mohanan <gomati.mohanan@in.ibm.com>
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #include "smbd/smbd.h"
26 #include "librpc/gen_ndr/ndr_xattr.h"
27 #include "include/smbprofile.h"
28 #include "modules/non_posix_acls.h"
29 #include "libcli/security/security.h"
32 #define DBGC_CLASS DBGC_VFS
34 #include <gpfs_fcntl.h>
35 #include "nfs4_acls.h"
37 #include "system/filesys.h"
39 #include "lib/util/tevent_unix.h"
41 struct gpfs_config_data {
56 static inline unsigned int gpfs_acl_flags(gpfs_acl_t *gacl)
58 if (gacl->acl_level == 1) { /* GPFS_ACL_LEVEL_V4FLAGS */
59 /* gacl->v4Level1.acl_flags requires gpfs 3.5 */
60 return *(unsigned int *)&gacl->ace_v4;
65 static inline gpfs_ace_v4_t *gpfs_ace_ptr(gpfs_acl_t *gacl, unsigned int i)
67 if (gacl->acl_level == 1) { /* GPFS_ACL_LEVEL_V4FLAGS */
68 /* &gacl->v4Level1.ace_v4[i] requires gpfs 3.5 */
69 char *ptr = (char *)&gacl->ace_v4[i] + sizeof(unsigned int);
70 return (gpfs_ace_v4_t *)ptr;
72 return &gacl->ace_v4[i];
75 static bool set_gpfs_sharemode(files_struct *fsp, uint32 access_mask,
78 unsigned int allow = GPFS_SHARE_NONE;
79 unsigned int deny = GPFS_DENY_NONE;
82 if ((fsp == NULL) || (fsp->fh == NULL) || (fsp->fh->fd < 0)) {
83 /* No real file, don't disturb */
87 allow |= (access_mask & (FILE_WRITE_DATA|FILE_APPEND_DATA|
88 DELETE_ACCESS)) ? GPFS_SHARE_WRITE : 0;
89 allow |= (access_mask & (FILE_READ_DATA|FILE_EXECUTE)) ?
92 if (allow == GPFS_SHARE_NONE) {
93 DEBUG(10, ("special case am=no_access:%x\n",access_mask));
96 deny |= (share_access & FILE_SHARE_WRITE) ?
98 deny |= (share_access & (FILE_SHARE_READ)) ?
101 DEBUG(10, ("am=%x, allow=%d, sa=%x, deny=%d\n",
102 access_mask, allow, share_access, deny));
104 result = gpfswrap_set_share(fsp->fh->fd, allow, deny);
106 if (errno == ENOSYS) {
107 DEBUG(5, ("VFS module vfs_gpfs loaded, but gpfs "
108 "set_share function support not available. "
109 "Allowing access\n"));
112 DEBUG(10, ("gpfs_set_share failed: %s\n",
117 return (result == 0);
120 static int vfs_gpfs_kernel_flock(vfs_handle_struct *handle, files_struct *fsp,
121 uint32 share_mode, uint32 access_mask)
124 struct gpfs_config_data *config;
127 START_PROFILE(syscall_kernel_flock);
129 SMB_VFS_HANDLE_GET_DATA(handle, config,
130 struct gpfs_config_data,
133 if(!config->sharemodes) {
137 kernel_flock(fsp->fh->fd, share_mode, access_mask);
139 if (!set_gpfs_sharemode(fsp, access_mask, fsp->share_access)) {
143 END_PROFILE(syscall_kernel_flock);
148 static int vfs_gpfs_close(vfs_handle_struct *handle, files_struct *fsp)
151 struct gpfs_config_data *config;
153 SMB_VFS_HANDLE_GET_DATA(handle, config,
154 struct gpfs_config_data,
157 if (config->sharemodes && (fsp->fh != NULL) && (fsp->fh->fd != -1)) {
158 set_gpfs_sharemode(fsp, 0, 0);
161 return SMB_VFS_NEXT_CLOSE(handle, fsp);
164 static int set_gpfs_lease(int fd, int leasetype)
166 int gpfs_type = GPFS_LEASE_NONE;
168 if (leasetype == F_RDLCK) {
169 gpfs_type = GPFS_LEASE_READ;
171 if (leasetype == F_WRLCK) {
172 gpfs_type = GPFS_LEASE_WRITE;
175 /* we unconditionally set CAP_LEASE, rather than looking for
176 -1/EACCES as there is a bug in some versions of
177 libgpfs_gpl.so which results in a leaked fd on /dev/ss0
178 each time we try this with the wrong capabilities set
180 linux_set_lease_capability();
181 return gpfswrap_set_lease(fd, gpfs_type);
184 static int vfs_gpfs_setlease(vfs_handle_struct *handle, files_struct *fsp,
187 struct gpfs_config_data *config;
190 START_PROFILE(syscall_linux_setlease);
192 SMB_VFS_HANDLE_GET_DATA(handle, config,
193 struct gpfs_config_data,
196 if (linux_set_lease_sighandler(fsp->fh->fd) == -1)
199 if (config->leases) {
201 * Ensure the lease owner is root to allow
202 * correct delivery of lease-break signals.
205 ret = set_gpfs_lease(fsp->fh->fd,leasetype);
209 END_PROFILE(syscall_linux_setlease);
214 static int vfs_gpfs_get_real_filename(struct vfs_handle_struct *handle,
222 char real_pathname[PATH_MAX+1];
225 struct gpfs_config_data *config;
227 SMB_VFS_HANDLE_GET_DATA(handle, config,
228 struct gpfs_config_data,
231 if (!config->getrealfilename) {
232 return SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name,
233 mem_ctx, found_name);
236 mangled = mangle_is_mangled(name, handle->conn->params);
238 return SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name,
239 mem_ctx, found_name);
242 full_path = talloc_asprintf(talloc_tos(), "%s/%s", path, name);
243 if (full_path == NULL) {
248 buflen = sizeof(real_pathname) - 1;
250 result = gpfswrap_get_realfilename_path(full_path, real_pathname,
253 TALLOC_FREE(full_path);
255 if ((result == -1) && (errno == ENOSYS)) {
256 return SMB_VFS_NEXT_GET_REAL_FILENAME(
257 handle, path, name, mem_ctx, found_name);
261 DEBUG(10, ("smbd_gpfs_get_realfilename_path returned %s\n",
267 * GPFS does not necessarily null-terminate the returned path
268 * but instead returns the buffer length in buflen.
271 if (buflen < sizeof(real_pathname)) {
272 real_pathname[buflen] = '\0';
274 real_pathname[sizeof(real_pathname)-1] = '\0';
277 DEBUG(10, ("smbd_gpfs_get_realfilename_path: %s/%s -> %s\n",
278 path, name, real_pathname));
280 name = strrchr_m(real_pathname, '/');
286 *found_name = talloc_strdup(mem_ctx, name+1);
287 if (*found_name == NULL) {
295 static void sd2gpfs_control(uint16_t control, struct gpfs_acl *gacl)
297 unsigned int gpfs_aclflags = 0;
298 control &= SEC_DESC_DACL_PROTECTED | SEC_DESC_SACL_PROTECTED |
299 SEC_DESC_DACL_AUTO_INHERITED | SEC_DESC_SACL_AUTO_INHERITED |
300 SEC_DESC_DACL_DEFAULTED | SEC_DESC_SACL_DEFAULTED |
301 SEC_DESC_DACL_PRESENT | SEC_DESC_SACL_PRESENT;
302 gpfs_aclflags = control << 8;
303 if (!(control & SEC_DESC_DACL_PRESENT))
304 gpfs_aclflags |= 0x00800000; /* ACL4_FLAG_NULL_DACL; */
305 if (!(control & SEC_DESC_SACL_PRESENT))
306 gpfs_aclflags |= 0x01000000; /* ACL4_FLAG_NULL_SACL; */
307 gacl->acl_level = 1; /* GPFS_ACL_LEVEL_V4FLAGS*/
308 /* gacl->v4Level1.acl_flags requires gpfs 3.5 */
309 *(unsigned int *)&gacl->ace_v4 = gpfs_aclflags;
312 static uint16_t gpfs2sd_control(unsigned int gpfs_aclflags)
314 uint16_t control = gpfs_aclflags >> 8;
315 control &= SEC_DESC_DACL_PROTECTED | SEC_DESC_SACL_PROTECTED |
316 SEC_DESC_DACL_AUTO_INHERITED | SEC_DESC_SACL_AUTO_INHERITED |
317 SEC_DESC_DACL_DEFAULTED | SEC_DESC_SACL_DEFAULTED |
318 SEC_DESC_DACL_PRESENT | SEC_DESC_SACL_PRESENT;
319 control |= SEC_DESC_SELF_RELATIVE;
323 static void gpfs_dumpacl(int level, struct gpfs_acl *gacl)
328 DEBUG(0, ("gpfs acl is NULL\n"));
332 DEBUG(level, ("len: %d, level: %d, version: %d, nace: %d, "
334 gacl->acl_len, gacl->acl_level, gacl->acl_version,
335 gacl->acl_nace, gpfs_acl_flags(gacl)));
337 for(i=0; i<gacl->acl_nace; i++)
339 struct gpfs_ace_v4 *gace = gpfs_ace_ptr(gacl, i);
340 DEBUG(level, ("\tace[%d]: type:%d, flags:0x%x, mask:0x%x, "
341 "iflags:0x%x, who:%u\n",
342 i, gace->aceType, gace->aceFlags, gace->aceMask,
343 gace->aceIFlags, gace->aceWho));
348 * get the ACL from GPFS, allocated on the specified mem_ctx
349 * internally retries when initial buffer was too small
351 * caller needs to cast result to either
352 * raw = yes: struct gpfs_opaque_acl
353 * raw = no: struct gpfs_acl
356 static void *vfs_gpfs_getacl(TALLOC_CTX *mem_ctx,
359 const gpfs_aclType_t type)
370 aclbuf = talloc_zero_size(mem_ctx, size);
371 if (aclbuf == NULL) {
377 struct gpfs_opaque_acl *buf = (struct gpfs_opaque_acl *) aclbuf;
378 buf->acl_type = type;
379 flags = GPFS_GETACL_NATIVE;
380 len = (unsigned int *) &(buf->acl_buffer_len);
381 struct_size = sizeof(struct gpfs_opaque_acl);
383 struct gpfs_acl *buf = (struct gpfs_acl *) aclbuf;
384 buf->acl_type = type;
385 buf->acl_level = 1; /* GPFS_ACL_LEVEL_V4FLAGS */
386 flags = GPFS_GETACL_STRUCT;
387 len = &(buf->acl_len);
388 /* reserve space for control flags in gpfs 3.5 and beyond */
389 struct_size = sizeof(struct gpfs_acl) + sizeof(unsigned int);
392 /* set the length of the buffer as input value */
396 ret = gpfswrap_getacl(discard_const_p(char, fname), flags, aclbuf);
397 if ((ret != 0) && (errno == ENOSPC)) {
399 * get the size needed to accommodate the complete buffer
401 * the value returned only applies to the ACL blob in the
402 * struct so make sure to also have headroom for the first
403 * struct members by adding room for the complete struct
404 * (might be a few bytes too much then)
406 size = *len + struct_size;
408 DEBUG(10, ("Increasing ACL buffer size to %zu\n", size));
413 DEBUG(5, ("smbd_gpfs_getacl failed with %s\n",
422 /* Tries to get nfs4 acls and returns SMB ACL allocated.
423 * On failure returns 1 if it got non-NFSv4 ACL to prompt
424 * retry with POSIX ACL checks.
425 * On failure returns -1 if there is system (GPFS) error, check errno.
426 * Returns 0 on success
428 static int gpfs_get_nfs4_acl(TALLOC_CTX *mem_ctx, const char *fname, SMB4ACL_T **ppacl)
431 struct gpfs_acl *gacl = NULL;
432 DEBUG(10, ("gpfs_get_nfs4_acl invoked for %s\n", fname));
435 gacl = (struct gpfs_acl*) vfs_gpfs_getacl(talloc_tos(), fname,
438 DEBUG(9, ("gpfs_getacl failed for %s with %s\n",
439 fname, strerror(errno)));
443 if (gacl->acl_type != GPFS_ACL_TYPE_NFS4) {
444 DEBUG(10, ("Got non-nfsv4 acl\n"));
445 /* Retry with POSIX ACLs check */
450 *ppacl = smb_create_smb4acl(mem_ctx);
452 if (gacl->acl_level == 1) { /* GPFS_ACL_LEVEL_V4FLAGS */
453 uint16_t control = gpfs2sd_control(gpfs_acl_flags(gacl));
454 smbacl4_set_controlflags(*ppacl, control);
457 DEBUG(10, ("len: %d, level: %d, version: %d, nace: %d, control: %x\n",
458 gacl->acl_len, gacl->acl_level, gacl->acl_version,
459 gacl->acl_nace, gpfs_acl_flags(gacl)));
461 for (i=0; i<gacl->acl_nace; i++) {
462 struct gpfs_ace_v4 *gace = gpfs_ace_ptr(gacl, i);
463 SMB_ACE4PROP_T smbace;
464 DEBUG(10, ("type: %d, iflags: %x, flags: %x, mask: %x, "
465 "who: %d\n", gace->aceType, gace->aceIFlags,
466 gace->aceFlags, gace->aceMask, gace->aceWho));
469 if (gace->aceIFlags & ACE4_IFLAG_SPECIAL_ID) {
470 smbace.flags |= SMB_ACE4_ID_SPECIAL;
471 switch (gace->aceWho) {
472 case ACE4_SPECIAL_OWNER:
473 smbace.who.special_id = SMB_ACE4_WHO_OWNER;
475 case ACE4_SPECIAL_GROUP:
476 smbace.who.special_id = SMB_ACE4_WHO_GROUP;
478 case ACE4_SPECIAL_EVERYONE:
479 smbace.who.special_id = SMB_ACE4_WHO_EVERYONE;
482 DEBUG(8, ("invalid special gpfs id %d "
483 "ignored\n", gace->aceWho));
484 continue; /* don't add it */
487 if (gace->aceFlags & ACE4_FLAG_GROUP_ID)
488 smbace.who.gid = gace->aceWho;
490 smbace.who.uid = gace->aceWho;
493 /* remove redundant deny entries */
494 if (i > 0 && gace->aceType == SMB_ACE4_ACCESS_DENIED_ACE_TYPE) {
495 struct gpfs_ace_v4 *prev = gpfs_ace_ptr(gacl, i - 1);
496 if (prev->aceType == SMB_ACE4_ACCESS_ALLOWED_ACE_TYPE &&
497 prev->aceFlags == gace->aceFlags &&
498 prev->aceIFlags == gace->aceIFlags &&
499 (gace->aceMask & prev->aceMask) == 0 &&
500 gace->aceWho == prev->aceWho) {
501 /* it's redundant - skip it */
506 smbace.aceType = gace->aceType;
507 smbace.aceFlags = gace->aceFlags;
508 smbace.aceMask = gace->aceMask;
509 smb_add_ace4(*ppacl, &smbace);
517 static NTSTATUS gpfsacl_fget_nt_acl(vfs_handle_struct *handle,
518 files_struct *fsp, uint32 security_info,
520 struct security_descriptor **ppdesc)
522 SMB4ACL_T *pacl = NULL;
524 struct gpfs_config_data *config;
525 TALLOC_CTX *frame = talloc_stackframe();
530 SMB_VFS_HANDLE_GET_DATA(handle, config,
531 struct gpfs_config_data,
532 return NT_STATUS_INTERNAL_ERROR);
535 status = SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info,
541 result = gpfs_get_nfs4_acl(frame, fsp->fsp_name->base_name, &pacl);
544 status = smb_fget_nt_acl_nfs4(fsp, security_info, mem_ctx,
551 DEBUG(10, ("retrying with posix acl...\n"));
552 status = posix_fget_nt_acl(fsp, security_info,
560 /* GPFS ACL was not read, something wrong happened, error code is set in errno */
561 return map_nt_error_from_unix(errno);
564 static NTSTATUS gpfsacl_get_nt_acl(vfs_handle_struct *handle,
566 uint32 security_info,
567 TALLOC_CTX *mem_ctx, struct security_descriptor **ppdesc)
569 SMB4ACL_T *pacl = NULL;
571 struct gpfs_config_data *config;
572 TALLOC_CTX *frame = talloc_stackframe();
577 SMB_VFS_HANDLE_GET_DATA(handle, config,
578 struct gpfs_config_data,
579 return NT_STATUS_INTERNAL_ERROR);
582 status = SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info,
588 result = gpfs_get_nfs4_acl(frame, name, &pacl);
591 status = smb_get_nt_acl_nfs4(handle->conn, name, security_info,
592 mem_ctx, ppdesc, pacl);
598 DEBUG(10, ("retrying with posix acl...\n"));
599 status = posix_get_nt_acl(handle->conn, name, security_info,
605 /* GPFS ACL was not read, something wrong happened, error code is set in errno */
607 return map_nt_error_from_unix(errno);
610 static struct gpfs_acl *vfs_gpfs_smbacl2gpfsacl(TALLOC_CTX *mem_ctx,
615 struct gpfs_acl *gacl;
616 gpfs_aclLen_t gacl_len;
619 gacl_len = offsetof(gpfs_acl_t, ace_v4) + sizeof(unsigned int)
620 + smb_get_naces(smbacl) * sizeof(gpfs_ace_v4_t);
622 gacl = (struct gpfs_acl *)TALLOC_SIZE(mem_ctx, gacl_len);
624 DEBUG(0, ("talloc failed\n"));
629 gacl->acl_level = 0; /* GPFS_ACL_LEVEL_BASE */
630 gacl->acl_version = GPFS_ACL_VERSION_NFS4;
631 gacl->acl_type = GPFS_ACL_TYPE_NFS4;
632 gacl->acl_nace = 0; /* change later... */
635 gacl->acl_level = 1; /* GPFS_ACL_LEVEL_V4FLAGS */
636 sd2gpfs_control(smbacl4_get_controlflags(smbacl), gacl);
639 for (smbace=smb_first_ace4(smbacl); smbace!=NULL; smbace = smb_next_ace4(smbace)) {
640 struct gpfs_ace_v4 *gace = gpfs_ace_ptr(gacl, gacl->acl_nace);
641 SMB_ACE4PROP_T *aceprop = smb_get_ace4(smbace);
643 gace->aceType = aceprop->aceType;
644 gace->aceFlags = aceprop->aceFlags;
645 gace->aceMask = aceprop->aceMask;
648 * GPFS can't distinguish between WRITE and APPEND on
649 * files, so one being set without the other is an
650 * error. Sorry for the many ()'s :-)
653 if (!fsp->is_directory
655 ((((gace->aceMask & ACE4_MASK_WRITE) == 0)
656 && ((gace->aceMask & ACE4_MASK_APPEND) != 0))
658 (((gace->aceMask & ACE4_MASK_WRITE) != 0)
659 && ((gace->aceMask & ACE4_MASK_APPEND) == 0)))
661 lp_parm_bool(fsp->conn->params->service, "gpfs",
662 "merge_writeappend", True)) {
663 DEBUG(2, ("vfs_gpfs.c: file [%s]: ACE contains "
664 "WRITE^APPEND, setting WRITE|APPEND\n",
666 gace->aceMask |= ACE4_MASK_WRITE|ACE4_MASK_APPEND;
669 gace->aceIFlags = (aceprop->flags&SMB_ACE4_ID_SPECIAL) ? ACE4_IFLAG_SPECIAL_ID : 0;
671 if (aceprop->flags&SMB_ACE4_ID_SPECIAL)
673 switch(aceprop->who.special_id)
675 case SMB_ACE4_WHO_EVERYONE:
676 gace->aceWho = ACE4_SPECIAL_EVERYONE;
678 case SMB_ACE4_WHO_OWNER:
679 gace->aceWho = ACE4_SPECIAL_OWNER;
681 case SMB_ACE4_WHO_GROUP:
682 gace->aceWho = ACE4_SPECIAL_GROUP;
685 DEBUG(8, ("unsupported special_id %d\n", aceprop->who.special_id));
686 continue; /* don't add it !!! */
689 /* just only for the type safety... */
690 if (aceprop->aceFlags&SMB_ACE4_IDENTIFIER_GROUP)
691 gace->aceWho = aceprop->who.gid;
693 gace->aceWho = aceprop->who.uid;
698 gacl->acl_len = (char *)gpfs_ace_ptr(gacl, gacl->acl_nace)
703 static bool gpfsacl_process_smbacl(vfs_handle_struct *handle,
708 struct gpfs_acl *gacl;
709 TALLOC_CTX *mem_ctx = talloc_tos();
711 gacl = vfs_gpfs_smbacl2gpfsacl(mem_ctx, fsp, smbacl, true);
712 if (gacl == NULL) { /* out of memory */
715 ret = gpfswrap_putacl(fsp->fsp_name->base_name,
716 GPFS_PUTACL_STRUCT | GPFS_ACL_SAMBA, gacl);
718 if ((ret != 0) && (errno == EINVAL)) {
719 DEBUG(10, ("Retry without nfs41 control flags\n"));
721 gacl = vfs_gpfs_smbacl2gpfsacl(mem_ctx, fsp, smbacl, false);
722 if (gacl == NULL) { /* out of memory */
725 ret = gpfswrap_putacl(fsp->fsp_name->base_name,
726 GPFS_PUTACL_STRUCT | GPFS_ACL_SAMBA,
731 DEBUG(8, ("gpfs_putacl failed with %s\n", strerror(errno)));
732 gpfs_dumpacl(8, gacl);
736 DEBUG(10, ("gpfs_putacl succeeded\n"));
740 static NTSTATUS gpfsacl_set_nt_acl_internal(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, const struct security_descriptor *psd)
742 struct gpfs_acl *acl;
743 NTSTATUS result = NT_STATUS_ACCESS_DENIED;
745 acl = (struct gpfs_acl*) vfs_gpfs_getacl(talloc_tos(),
746 fsp->fsp_name->base_name,
749 return map_nt_error_from_unix(errno);
752 if (acl->acl_version == GPFS_ACL_VERSION_NFS4) {
753 if (lp_parm_bool(fsp->conn->params->service, "gpfs",
754 "refuse_dacl_protected", false)
755 && (psd->type&SEC_DESC_DACL_PROTECTED)) {
756 DEBUG(2, ("Rejecting unsupported ACL with DACL_PROTECTED bit set\n"));
758 return NT_STATUS_NOT_SUPPORTED;
761 result = smb_set_nt_acl_nfs4(handle,
762 fsp, security_info_sent, psd,
763 gpfsacl_process_smbacl);
764 } else { /* assume POSIX ACL - by default... */
765 result = set_nt_acl(fsp, security_info_sent, psd);
772 static NTSTATUS gpfsacl_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, const struct security_descriptor *psd)
774 struct gpfs_config_data *config;
776 SMB_VFS_HANDLE_GET_DATA(handle, config,
777 struct gpfs_config_data,
778 return NT_STATUS_INTERNAL_ERROR);
781 return SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
784 return gpfsacl_set_nt_acl_internal(handle, fsp, security_info_sent, psd);
787 static SMB_ACL_T gpfs2smb_acl(const struct gpfs_acl *pacl, TALLOC_CTX *mem_ctx)
792 result = sys_acl_init(mem_ctx);
793 if (result == NULL) {
798 result->count = pacl->acl_nace;
799 result->acl = talloc_realloc(result, result->acl, struct smb_acl_entry,
801 if (result->acl == NULL) {
807 for (i=0; i<pacl->acl_nace; i++) {
808 struct smb_acl_entry *ace = &result->acl[i];
809 const struct gpfs_ace_v1 *g_ace = &pacl->ace_v1[i];
811 DEBUG(10, ("Converting type %d id %lu perm %x\n",
812 (int)g_ace->ace_type, (unsigned long)g_ace->ace_who,
813 (int)g_ace->ace_perm));
815 switch (g_ace->ace_type) {
817 ace->a_type = SMB_ACL_USER;
818 ace->info.user.uid = (uid_t)g_ace->ace_who;
820 case GPFS_ACL_USER_OBJ:
821 ace->a_type = SMB_ACL_USER_OBJ;
824 ace->a_type = SMB_ACL_GROUP;
825 ace->info.group.gid = (gid_t)g_ace->ace_who;
827 case GPFS_ACL_GROUP_OBJ:
828 ace->a_type = SMB_ACL_GROUP_OBJ;
831 ace->a_type = SMB_ACL_OTHER;
834 ace->a_type = SMB_ACL_MASK;
837 DEBUG(10, ("Got invalid ace_type: %d\n",
845 ace->a_perm |= (g_ace->ace_perm & ACL_PERM_READ) ?
847 ace->a_perm |= (g_ace->ace_perm & ACL_PERM_WRITE) ?
849 ace->a_perm |= (g_ace->ace_perm & ACL_PERM_EXECUTE) ?
852 DEBUGADD(10, ("Converted to %d perm %x\n",
853 ace->a_type, ace->a_perm));
859 static SMB_ACL_T gpfsacl_get_posix_acl(const char *path, gpfs_aclType_t type,
862 struct gpfs_acl *pacl;
863 SMB_ACL_T result = NULL;
865 pacl = vfs_gpfs_getacl(talloc_tos(), path, false, type);
868 DEBUG(10, ("vfs_gpfs_getacl failed for %s with %s\n",
869 path, strerror(errno)));
876 if (pacl->acl_version != GPFS_ACL_VERSION_POSIX) {
877 DEBUG(10, ("Got acl version %d, expected %d\n",
878 pacl->acl_version, GPFS_ACL_VERSION_POSIX));
883 DEBUG(10, ("len: %d, level: %d, version: %d, nace: %d\n",
884 pacl->acl_len, pacl->acl_level, pacl->acl_version,
887 result = gpfs2smb_acl(pacl, mem_ctx);
888 if (result != NULL) {
903 static SMB_ACL_T gpfsacl_sys_acl_get_file(vfs_handle_struct *handle,
908 gpfs_aclType_t gpfs_type;
909 struct gpfs_config_data *config;
911 SMB_VFS_HANDLE_GET_DATA(handle, config,
912 struct gpfs_config_data,
916 return SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, path_p,
921 case SMB_ACL_TYPE_ACCESS:
922 gpfs_type = GPFS_ACL_TYPE_ACCESS;
924 case SMB_ACL_TYPE_DEFAULT:
925 gpfs_type = GPFS_ACL_TYPE_DEFAULT;
928 DEBUG(0, ("Got invalid type: %d\n", type));
929 smb_panic("exiting");
932 return gpfsacl_get_posix_acl(path_p, gpfs_type, mem_ctx);
935 static SMB_ACL_T gpfsacl_sys_acl_get_fd(vfs_handle_struct *handle,
939 struct gpfs_config_data *config;
941 SMB_VFS_HANDLE_GET_DATA(handle, config,
942 struct gpfs_config_data,
946 return SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, mem_ctx);
949 return gpfsacl_get_posix_acl(fsp->fsp_name->base_name,
950 GPFS_ACL_TYPE_ACCESS, mem_ctx);
953 static int gpfsacl_sys_acl_blob_get_file(vfs_handle_struct *handle,
956 char **blob_description,
959 struct gpfs_config_data *config;
960 struct gpfs_opaque_acl *acl = NULL;
964 SMB_VFS_HANDLE_GET_DATA(handle, config,
965 struct gpfs_config_data,
969 return SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, path_p,
976 acl = (struct gpfs_opaque_acl *)
977 vfs_gpfs_getacl(mem_ctx,
983 DEBUG(5, ("vfs_gpfs_getacl finished with errno %d: %s\n",
984 errno, strerror(errno)));
986 /* EINVAL means POSIX ACL, bail out on other cases */
987 if (errno != EINVAL) {
996 * we only need the actual ACL blob here
997 * acl_version will always be NFS4 because we asked
999 * acl_type is only used for POSIX ACLs
1001 aclblob.data = (uint8_t*) acl->acl_var_data;
1002 aclblob.length = acl->acl_buffer_len;
1004 *blob_description = talloc_strdup(mem_ctx, "gpfs_nfs4_acl");
1005 if (!*blob_description) {
1011 result = non_posix_sys_acl_blob_get_file_helper(handle, path_p,
1019 /* fall back to POSIX ACL */
1020 return posix_sys_acl_blob_get_file(handle, path_p, mem_ctx,
1021 blob_description, blob);
1024 static int gpfsacl_sys_acl_blob_get_fd(vfs_handle_struct *handle,
1026 TALLOC_CTX *mem_ctx,
1027 char **blob_description,
1030 struct gpfs_config_data *config;
1031 struct gpfs_opaque_acl *acl = NULL;
1035 SMB_VFS_HANDLE_GET_DATA(handle, config,
1036 struct gpfs_config_data,
1040 return SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FD(handle, fsp, mem_ctx,
1041 blob_description, blob);
1045 acl = (struct gpfs_opaque_acl *) vfs_gpfs_getacl(mem_ctx,
1046 fsp->fsp_name->base_name,
1048 GPFS_ACL_TYPE_NFS4);
1051 DEBUG(5, ("vfs_gpfs_getacl finished with errno %d: %s\n",
1052 errno, strerror(errno)));
1054 /* EINVAL means POSIX ACL, bail out on other cases */
1055 if (errno != EINVAL) {
1062 * file has NFSv4 ACL
1064 * we only need the actual ACL blob here
1065 * acl_version will always be NFS4 because we asked
1067 * acl_type is only used for POSIX ACLs
1069 aclblob.data = (uint8_t*) acl->acl_var_data;
1070 aclblob.length = acl->acl_buffer_len;
1072 *blob_description = talloc_strdup(mem_ctx, "gpfs_nfs4_acl");
1073 if (!*blob_description) {
1079 result = non_posix_sys_acl_blob_get_fd_helper(handle, fsp,
1087 /* fall back to POSIX ACL */
1088 return posix_sys_acl_blob_get_fd(handle, fsp, mem_ctx,
1089 blob_description, blob);
1092 static struct gpfs_acl *smb2gpfs_acl(const SMB_ACL_T pacl,
1093 SMB_ACL_TYPE_T type)
1096 struct gpfs_acl *result;
1099 DEBUG(10, ("smb2gpfs_acl: Got ACL with %d entries\n", pacl->count));
1101 len = offsetof(gpfs_acl_t, ace_v1) + (pacl->count) *
1102 sizeof(gpfs_ace_v1_t);
1104 result = (struct gpfs_acl *)SMB_MALLOC(len);
1105 if (result == NULL) {
1110 result->acl_len = len;
1111 result->acl_level = 0;
1112 result->acl_version = GPFS_ACL_VERSION_POSIX;
1113 result->acl_type = (type == SMB_ACL_TYPE_DEFAULT) ?
1114 GPFS_ACL_TYPE_DEFAULT : GPFS_ACL_TYPE_ACCESS;
1115 result->acl_nace = pacl->count;
1117 for (i=0; i<pacl->count; i++) {
1118 const struct smb_acl_entry *ace = &pacl->acl[i];
1119 struct gpfs_ace_v1 *g_ace = &result->ace_v1[i];
1121 DEBUG(10, ("Converting type %d perm %x\n",
1122 (int)ace->a_type, (int)ace->a_perm));
1124 g_ace->ace_perm = 0;
1126 switch(ace->a_type) {
1128 g_ace->ace_type = GPFS_ACL_USER;
1129 g_ace->ace_who = (gpfs_uid_t)ace->info.user.uid;
1131 case SMB_ACL_USER_OBJ:
1132 g_ace->ace_type = GPFS_ACL_USER_OBJ;
1133 g_ace->ace_perm |= ACL_PERM_CONTROL;
1137 g_ace->ace_type = GPFS_ACL_GROUP;
1138 g_ace->ace_who = (gpfs_uid_t)ace->info.group.gid;
1140 case SMB_ACL_GROUP_OBJ:
1141 g_ace->ace_type = GPFS_ACL_GROUP_OBJ;
1145 g_ace->ace_type = GPFS_ACL_MASK;
1146 g_ace->ace_perm = 0x8f;
1150 g_ace->ace_type = GPFS_ACL_OTHER;
1154 DEBUG(10, ("Got invalid ace_type: %d\n", ace->a_type));
1160 g_ace->ace_perm |= (ace->a_perm & SMB_ACL_READ) ?
1162 g_ace->ace_perm |= (ace->a_perm & SMB_ACL_WRITE) ?
1164 g_ace->ace_perm |= (ace->a_perm & SMB_ACL_EXECUTE) ?
1165 ACL_PERM_EXECUTE : 0;
1167 DEBUGADD(10, ("Converted to %d id %d perm %x\n",
1168 g_ace->ace_type, g_ace->ace_who, g_ace->ace_perm));
1174 static int gpfsacl_sys_acl_set_file(vfs_handle_struct *handle,
1176 SMB_ACL_TYPE_T type,
1179 struct gpfs_acl *gpfs_acl;
1181 struct gpfs_config_data *config;
1183 SMB_VFS_HANDLE_GET_DATA(handle, config,
1184 struct gpfs_config_data,
1188 return SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, type, theacl);
1191 gpfs_acl = smb2gpfs_acl(theacl, type);
1192 if (gpfs_acl == NULL) {
1196 result = gpfswrap_putacl(discard_const_p(char, name),
1197 GPFS_PUTACL_STRUCT|GPFS_ACL_SAMBA, gpfs_acl);
1199 SAFE_FREE(gpfs_acl);
1203 static int gpfsacl_sys_acl_set_fd(vfs_handle_struct *handle,
1207 struct gpfs_config_data *config;
1209 SMB_VFS_HANDLE_GET_DATA(handle, config,
1210 struct gpfs_config_data,
1214 return SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
1217 return gpfsacl_sys_acl_set_file(handle, fsp->fsp_name->base_name,
1218 SMB_ACL_TYPE_ACCESS, theacl);
1221 static int gpfsacl_sys_acl_delete_def_file(vfs_handle_struct *handle,
1224 struct gpfs_config_data *config;
1226 SMB_VFS_HANDLE_GET_DATA(handle, config,
1227 struct gpfs_config_data,
1231 return SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path);
1239 * Assumed: mode bits are shiftable and standard
1240 * Output: the new aceMask field for an smb nfs4 ace
1242 static uint32 gpfsacl_mask_filter(uint32 aceType, uint32 aceMask, uint32 rwx)
1244 const uint32 posix_nfs4map[3] = {
1245 SMB_ACE4_EXECUTE, /* execute */
1246 SMB_ACE4_WRITE_DATA | SMB_ACE4_APPEND_DATA, /* write; GPFS specific */
1247 SMB_ACE4_READ_DATA /* read */
1250 uint32_t posix_mask = 0x01;
1254 for(i=0; i<3; i++) {
1255 nfs4_bits = posix_nfs4map[i];
1256 posix_bit = rwx & posix_mask;
1258 if (aceType==SMB_ACE4_ACCESS_ALLOWED_ACE_TYPE) {
1260 aceMask |= nfs4_bits;
1262 aceMask &= ~nfs4_bits;
1264 /* add deny bits when suitable */
1266 aceMask |= nfs4_bits;
1268 aceMask &= ~nfs4_bits;
1269 } /* other ace types are unexpected */
1277 static int gpfsacl_emu_chmod(vfs_handle_struct *handle,
1278 const char *path, mode_t mode)
1280 SMB4ACL_T *pacl = NULL;
1282 bool haveAllowEntry[SMB_ACE4_WHO_EVERYONE + 1] = {False, False, False, False};
1284 files_struct fake_fsp; /* TODO: rationalize parametrization */
1286 TALLOC_CTX *frame = talloc_stackframe();
1288 DEBUG(10, ("gpfsacl_emu_chmod invoked for %s mode %o\n", path, mode));
1290 result = gpfs_get_nfs4_acl(frame, path, &pacl);
1296 if (mode & ~(S_IRWXU | S_IRWXG | S_IRWXO)) {
1297 DEBUG(2, ("WARNING: cutting extra mode bits %o on %s\n", mode, path));
1300 for (smbace=smb_first_ace4(pacl); smbace!=NULL; smbace = smb_next_ace4(smbace)) {
1301 SMB_ACE4PROP_T *ace = smb_get_ace4(smbace);
1302 uint32_t specid = ace->who.special_id;
1304 if (ace->flags&SMB_ACE4_ID_SPECIAL &&
1305 ace->aceType<=SMB_ACE4_ACCESS_DENIED_ACE_TYPE &&
1306 specid <= SMB_ACE4_WHO_EVERYONE) {
1310 if (ace->aceType==SMB_ACE4_ACCESS_ALLOWED_ACE_TYPE)
1311 haveAllowEntry[specid] = True;
1313 /* mode >> 6 for @owner, mode >> 3 for @group,
1314 * mode >> 0 for @everyone */
1315 newMask = gpfsacl_mask_filter(ace->aceType, ace->aceMask,
1316 mode >> ((SMB_ACE4_WHO_EVERYONE - specid) * 3));
1317 if (ace->aceMask!=newMask) {
1318 DEBUG(10, ("ace changed for %s (%o -> %o) id=%d\n",
1319 path, ace->aceMask, newMask, specid));
1321 ace->aceMask = newMask;
1325 /* make sure we have at least ALLOW entries
1326 * for all the 3 special ids (@EVERYONE, @OWNER, @GROUP)
1329 for(i = SMB_ACE4_WHO_OWNER; i<=SMB_ACE4_WHO_EVERYONE; i++) {
1332 if (haveAllowEntry[i]==True)
1336 ace.aceType = SMB_ACE4_ACCESS_ALLOWED_ACE_TYPE;
1337 ace.flags |= SMB_ACE4_ID_SPECIAL;
1338 ace.who.special_id = i;
1340 if (i==SMB_ACE4_WHO_GROUP) /* not sure it's necessary... */
1341 ace.aceFlags |= SMB_ACE4_IDENTIFIER_GROUP;
1343 ace.aceMask = gpfsacl_mask_filter(ace.aceType, ace.aceMask,
1344 mode >> ((SMB_ACE4_WHO_EVERYONE - i) * 3));
1346 /* don't add unnecessary aces */
1350 /* we add it to the END - as windows expects allow aces */
1351 smb_add_ace4(pacl, &ace);
1352 DEBUG(10, ("Added ALLOW ace for %s, mode=%o, id=%d, aceMask=%x\n",
1353 path, mode, i, ace.aceMask));
1356 /* don't add complementary DENY ACEs here */
1357 ZERO_STRUCT(fake_fsp);
1358 fake_fsp.fsp_name = synthetic_smb_fname(
1359 frame, path, NULL, NULL);
1360 if (fake_fsp.fsp_name == NULL) {
1366 if (gpfsacl_process_smbacl(handle, &fake_fsp, pacl) == False) {
1372 return 0; /* ok for [f]chmod */
1375 static int vfs_gpfs_chmod(vfs_handle_struct *handle, const char *path, mode_t mode)
1377 struct smb_filename *smb_fname_cpath;
1380 smb_fname_cpath = synthetic_smb_fname(talloc_tos(), path, NULL, NULL);
1381 if (smb_fname_cpath == NULL) {
1386 if (SMB_VFS_NEXT_STAT(handle, smb_fname_cpath) != 0) {
1390 /* avoid chmod() if possible, to preserve acls */
1391 if ((smb_fname_cpath->st.st_ex_mode & ~S_IFMT) == mode) {
1395 rc = gpfsacl_emu_chmod(handle, path, mode);
1397 return SMB_VFS_NEXT_CHMOD(handle, path, mode);
1401 static int vfs_gpfs_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mode)
1406 if (SMB_VFS_NEXT_FSTAT(handle, fsp, &st) != 0) {
1410 /* avoid chmod() if possible, to preserve acls */
1411 if ((st.st_ex_mode & ~S_IFMT) == mode) {
1415 rc = gpfsacl_emu_chmod(handle, fsp->fsp_name->base_name,
1418 return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
1422 static int gpfs_set_xattr(struct vfs_handle_struct *handle, const char *path,
1423 const char *name, const void *value, size_t size, int flags){
1424 struct xattr_DOSATTRIB dosattrib;
1425 enum ndr_err_code ndr_err;
1427 unsigned int dosmode=0;
1428 struct gpfs_winattr attrs;
1430 struct gpfs_config_data *config;
1432 SMB_VFS_HANDLE_GET_DATA(handle, config,
1433 struct gpfs_config_data,
1436 if (!config->winattr) {
1437 DEBUG(10, ("gpfs_set_xattr:name is %s -> next\n",name));
1438 return SMB_VFS_NEXT_SETXATTR(handle,path,name,value,size,flags);
1441 DEBUG(10, ("gpfs_set_xattr: %s \n",path));
1443 /* Only handle DOS Attributes */
1444 if (strcmp(name,SAMBA_XATTR_DOS_ATTRIB) != 0){
1445 DEBUG(5, ("gpfs_set_xattr:name is %s\n",name));
1446 return SMB_VFS_NEXT_SETXATTR(handle,path,name,value,size,flags);
1449 blob.data = discard_const_p(uint8_t, value);
1452 ndr_err = ndr_pull_struct_blob(&blob, talloc_tos(), &dosattrib,
1453 (ndr_pull_flags_fn_t)ndr_pull_xattr_DOSATTRIB);
1455 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1456 DEBUG(1, ("gpfs_set_xattr: bad ndr decode "
1457 "from EA on file %s: Error = %s\n",
1458 path, ndr_errstr(ndr_err)));
1462 if (dosattrib.version != 3) {
1463 DEBUG(1, ("gpfs_set_xattr: expected dosattrib version 3, got "
1464 "%d\n", (int)dosattrib.version));
1467 if (!(dosattrib.info.info3.valid_flags & XATTR_DOSINFO_ATTRIB)) {
1468 DEBUG(10, ("gpfs_set_xattr: XATTR_DOSINFO_ATTRIB not "
1469 "valid, ignoring\n"));
1473 dosmode = dosattrib.info.info3.attrib;
1476 /*Just map RD_ONLY, ARCHIVE, SYSTEM HIDDEN and SPARSE. Ignore the others*/
1477 if (dosmode & FILE_ATTRIBUTE_ARCHIVE){
1478 attrs.winAttrs |= GPFS_WINATTR_ARCHIVE;
1480 if (dosmode & FILE_ATTRIBUTE_HIDDEN){
1481 attrs.winAttrs |= GPFS_WINATTR_HIDDEN;
1483 if (dosmode & FILE_ATTRIBUTE_SYSTEM){
1484 attrs.winAttrs |= GPFS_WINATTR_SYSTEM;
1486 if (dosmode & FILE_ATTRIBUTE_READONLY){
1487 attrs.winAttrs |= GPFS_WINATTR_READONLY;
1489 if (dosmode & FILE_ATTRIBUTE_SPARSE) {
1490 attrs.winAttrs |= GPFS_WINATTR_SPARSE_FILE;
1494 ret = gpfswrap_set_winattrs_path(discard_const_p(char, path),
1495 GPFS_WINATTR_SET_ATTRS, &attrs);
1497 if (errno == ENOSYS) {
1498 return SMB_VFS_NEXT_SETXATTR(handle, path, name, value,
1502 DEBUG(1, ("gpfs_set_xattr:Set GPFS attributes failed %d\n",ret));
1506 DEBUG(10, ("gpfs_set_xattr:Set attributes: 0x%x\n",attrs.winAttrs));
1510 static ssize_t gpfs_get_xattr(struct vfs_handle_struct *handle, const char *path,
1511 const char *name, void *value, size_t size){
1512 char *attrstr = value;
1513 unsigned int dosmode = 0;
1514 struct gpfs_winattr attrs;
1516 struct gpfs_config_data *config;
1518 SMB_VFS_HANDLE_GET_DATA(handle, config,
1519 struct gpfs_config_data,
1522 if (!config->winattr) {
1523 DEBUG(10, ("gpfs_get_xattr:name is %s -> next\n",name));
1524 return SMB_VFS_NEXT_GETXATTR(handle,path,name,value,size);
1527 DEBUG(10, ("gpfs_get_xattr: %s \n",path));
1529 /* Only handle DOS Attributes */
1530 if (strcmp(name,SAMBA_XATTR_DOS_ATTRIB) != 0){
1531 DEBUG(5, ("gpfs_get_xattr:name is %s\n",name));
1532 return SMB_VFS_NEXT_GETXATTR(handle,path,name,value,size);
1535 ret = gpfswrap_get_winattrs_path(discard_const_p(char, path), &attrs);
1539 if (errno == ENOSYS) {
1540 return SMB_VFS_NEXT_GETXATTR(handle, path, name, value,
1544 if (errno != EPERM && errno != EACCES) {
1549 DEBUG(dbg_lvl, ("gpfs_get_xattr: Get GPFS attributes failed: "
1550 "%d (%s)\n", ret, strerror(errno)));
1554 DEBUG(10, ("gpfs_get_xattr:Got attributes: 0x%x\n",attrs.winAttrs));
1556 /*Just map RD_ONLY, ARCHIVE, SYSTEM, HIDDEN and SPARSE. Ignore the others*/
1557 if (attrs.winAttrs & GPFS_WINATTR_ARCHIVE){
1558 dosmode |= FILE_ATTRIBUTE_ARCHIVE;
1560 if (attrs.winAttrs & GPFS_WINATTR_HIDDEN){
1561 dosmode |= FILE_ATTRIBUTE_HIDDEN;
1563 if (attrs.winAttrs & GPFS_WINATTR_SYSTEM){
1564 dosmode |= FILE_ATTRIBUTE_SYSTEM;
1566 if (attrs.winAttrs & GPFS_WINATTR_READONLY){
1567 dosmode |= FILE_ATTRIBUTE_READONLY;
1569 if (attrs.winAttrs & GPFS_WINATTR_SPARSE_FILE) {
1570 dosmode |= FILE_ATTRIBUTE_SPARSE;
1573 snprintf(attrstr, size, "0x%2.2x",
1574 (unsigned int)(dosmode & SAMBA_ATTRIBUTES_MASK));
1575 DEBUG(10, ("gpfs_get_xattr: returning %s\n",attrstr));
1579 #if defined(HAVE_FSTATAT)
1580 static int stat_with_capability(struct vfs_handle_struct *handle,
1581 struct smb_filename *smb_fname, int flag)
1586 const char *rel_name = NULL;
1590 b = parent_dirname(talloc_tos(), smb_fname->base_name,
1591 &dir_name, &rel_name);
1597 fd = open(dir_name, O_RDONLY, 0);
1598 TALLOC_FREE(dir_name);
1603 set_effective_capability(DAC_OVERRIDE_CAPABILITY);
1604 ret = fstatat(fd, rel_name, &st, flag);
1605 drop_effective_capability(DAC_OVERRIDE_CAPABILITY);
1610 init_stat_ex_from_stat(
1611 &smb_fname->st, &st,
1612 lp_fake_directory_create_times(SNUM(handle->conn)));
1619 static int vfs_gpfs_stat(struct vfs_handle_struct *handle,
1620 struct smb_filename *smb_fname)
1622 struct gpfs_winattr attrs;
1626 struct gpfs_config_data *config;
1628 SMB_VFS_HANDLE_GET_DATA(handle, config,
1629 struct gpfs_config_data,
1632 ret = SMB_VFS_NEXT_STAT(handle, smb_fname);
1633 #if defined(HAVE_FSTATAT)
1634 if (ret == -1 && errno == EACCES) {
1635 DEBUG(10, ("Trying stat with capability for %s\n",
1636 smb_fname->base_name));
1637 ret = stat_with_capability(handle, smb_fname, 0);
1644 if (!config->winattr) {
1648 status = get_full_smb_filename(talloc_tos(), smb_fname, &fname);
1649 if (!NT_STATUS_IS_OK(status)) {
1650 errno = map_errno_from_nt_status(status);
1653 ret = gpfswrap_get_winattrs_path(discard_const_p(char, fname), &attrs);
1656 smb_fname->st.st_ex_calculated_birthtime = false;
1657 smb_fname->st.st_ex_btime.tv_sec = attrs.creationTime.tv_sec;
1658 smb_fname->st.st_ex_btime.tv_nsec = attrs.creationTime.tv_nsec;
1663 static int vfs_gpfs_fstat(struct vfs_handle_struct *handle,
1664 struct files_struct *fsp, SMB_STRUCT_STAT *sbuf)
1666 struct gpfs_winattr attrs;
1668 struct gpfs_config_data *config;
1670 SMB_VFS_HANDLE_GET_DATA(handle, config,
1671 struct gpfs_config_data,
1674 ret = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
1678 if ((fsp->fh == NULL) || (fsp->fh->fd == -1)) {
1681 if (!config->winattr) {
1685 ret = gpfswrap_get_winattrs(fsp->fh->fd, &attrs);
1687 sbuf->st_ex_calculated_birthtime = false;
1688 sbuf->st_ex_btime.tv_sec = attrs.creationTime.tv_sec;
1689 sbuf->st_ex_btime.tv_nsec = attrs.creationTime.tv_nsec;
1694 static int vfs_gpfs_lstat(struct vfs_handle_struct *handle,
1695 struct smb_filename *smb_fname)
1697 struct gpfs_winattr attrs;
1701 struct gpfs_config_data *config;
1703 SMB_VFS_HANDLE_GET_DATA(handle, config,
1704 struct gpfs_config_data,
1707 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname);
1708 #if defined(HAVE_FSTATAT)
1709 if (ret == -1 && errno == EACCES) {
1710 DEBUG(10, ("Trying lstat with capability for %s\n",
1711 smb_fname->base_name));
1712 ret = stat_with_capability(handle, smb_fname,
1713 AT_SYMLINK_NOFOLLOW);
1720 if (!config->winattr) {
1724 status = get_full_smb_filename(talloc_tos(), smb_fname, &path);
1725 if (!NT_STATUS_IS_OK(status)) {
1726 errno = map_errno_from_nt_status(status);
1729 ret = gpfswrap_get_winattrs_path(discard_const_p(char, path), &attrs);
1732 smb_fname->st.st_ex_calculated_birthtime = false;
1733 smb_fname->st.st_ex_btime.tv_sec = attrs.creationTime.tv_sec;
1734 smb_fname->st.st_ex_btime.tv_nsec = attrs.creationTime.tv_nsec;
1739 static int vfs_gpfs_ntimes(struct vfs_handle_struct *handle,
1740 const struct smb_filename *smb_fname,
1741 struct smb_file_time *ft)
1744 struct gpfs_winattr attrs;
1748 struct gpfs_config_data *config;
1750 SMB_VFS_HANDLE_GET_DATA(handle, config,
1751 struct gpfs_config_data,
1754 status = get_full_smb_filename(talloc_tos(), smb_fname, &path);
1755 if (!NT_STATUS_IS_OK(status)) {
1756 errno = map_errno_from_nt_status(status);
1760 /* Try to use gpfs_set_times if it is enabled and available */
1761 if (config->settimes) {
1762 ret = smbd_gpfs_set_times_path(path, ft);
1764 if (ret == 0 || (ret == -1 && errno != ENOSYS)) {
1769 DEBUG(10,("gpfs_set_times() not available or disabled, "
1770 "use ntimes and winattr\n"));
1772 ret = SMB_VFS_NEXT_NTIMES(handle, smb_fname, ft);
1774 /* don't complain if access was denied */
1775 if (errno != EPERM && errno != EACCES) {
1776 DEBUG(1,("vfs_gpfs_ntimes: SMB_VFS_NEXT_NTIMES failed:"
1777 "%s", strerror(errno)));
1782 if(null_timespec(ft->create_time)){
1783 DEBUG(10,("vfs_gpfs_ntimes:Create Time is NULL\n"));
1787 if (!config->winattr) {
1792 attrs.creationTime.tv_sec = ft->create_time.tv_sec;
1793 attrs.creationTime.tv_nsec = ft->create_time.tv_nsec;
1795 ret = gpfswrap_set_winattrs_path(discard_const_p(char, path),
1796 GPFS_WINATTR_SET_CREATION_TIME,
1798 if(ret == -1 && errno != ENOSYS){
1799 DEBUG(1,("vfs_gpfs_ntimes: set GPFS ntimes failed %d\n",ret));
1806 static int vfs_gpfs_fallocate(struct vfs_handle_struct *handle,
1807 struct files_struct *fsp, enum vfs_fallocate_mode mode,
1808 off_t offset, off_t len)
1811 struct gpfs_config_data *config;
1813 SMB_VFS_HANDLE_GET_DATA(handle, config,
1814 struct gpfs_config_data,
1817 if (!config->prealloc) {
1818 /* you should better not run fallocate() on GPFS at all */
1823 if (mode == VFS_FALLOCATE_KEEP_SIZE) {
1824 DEBUG(10, ("Unsupported VFS_FALLOCATE_KEEP_SIZE\n"));
1829 ret = gpfswrap_prealloc(fsp->fh->fd, offset, len);
1831 if (ret == -1 && errno != ENOSYS) {
1832 DEBUG(0, ("GPFS prealloc failed: %s\n", strerror(errno)));
1833 } else if (ret == -1 && errno == ENOSYS) {
1834 DEBUG(10, ("GPFS prealloc not supported.\n"));
1836 DEBUG(10, ("GPFS prealloc succeeded.\n"));
1842 static int vfs_gpfs_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
1846 struct gpfs_config_data *config;
1848 SMB_VFS_HANDLE_GET_DATA(handle, config,
1849 struct gpfs_config_data,
1852 if (!config->ftruncate) {
1853 return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
1856 result = gpfswrap_ftruncate(fsp->fh->fd, len);
1857 if ((result == -1) && (errno == ENOSYS)) {
1858 return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
1863 static bool vfs_gpfs_is_offline(struct vfs_handle_struct *handle,
1864 const struct smb_filename *fname,
1865 SMB_STRUCT_STAT *sbuf)
1867 struct gpfs_winattr attrs;
1870 struct gpfs_config_data *config;
1873 SMB_VFS_HANDLE_GET_DATA(handle, config,
1874 struct gpfs_config_data,
1877 if (!config->winattr) {
1878 return SMB_VFS_NEXT_IS_OFFLINE(handle, fname, sbuf);
1881 status = get_full_smb_filename(talloc_tos(), fname, &path);
1882 if (!NT_STATUS_IS_OK(status)) {
1883 errno = map_errno_from_nt_status(status);
1887 ret = gpfswrap_get_winattrs_path(path, &attrs);
1893 if ((attrs.winAttrs & GPFS_WINATTR_OFFLINE) != 0) {
1894 DEBUG(10, ("%s is offline\n", path));
1898 DEBUG(10, ("%s is online\n", path));
1900 return SMB_VFS_NEXT_IS_OFFLINE(handle, fname, sbuf);
1903 static bool vfs_gpfs_aio_force(struct vfs_handle_struct *handle,
1904 struct files_struct *fsp)
1906 return vfs_gpfs_is_offline(handle, fsp->fsp_name, &fsp->fsp_name->st);
1909 static ssize_t vfs_gpfs_sendfile(vfs_handle_struct *handle, int tofd,
1910 files_struct *fsp, const DATA_BLOB *hdr,
1911 off_t offset, size_t n)
1913 if (SMB_VFS_IS_OFFLINE(handle->conn, fsp->fsp_name, &fsp->fsp_name->st))
1918 return SMB_VFS_NEXT_SENDFILE(handle, tofd, fsp, hdr, offset, n);
1921 static int vfs_gpfs_connect(struct vfs_handle_struct *handle,
1922 const char *service, const char *user)
1924 struct gpfs_config_data *config;
1927 gpfswrap_lib_init(0);
1929 config = talloc_zero(handle->conn, struct gpfs_config_data);
1931 DEBUG(0, ("talloc_zero() failed\n"));
1936 ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
1938 TALLOC_FREE(config);
1942 config->sharemodes = lp_parm_bool(SNUM(handle->conn), "gpfs",
1943 "sharemodes", true);
1945 config->leases = lp_parm_bool(SNUM(handle->conn), "gpfs",
1948 config->hsm = lp_parm_bool(SNUM(handle->conn), "gpfs",
1951 config->syncio = lp_parm_bool(SNUM(handle->conn), "gpfs",
1954 config->winattr = lp_parm_bool(SNUM(handle->conn), "gpfs",
1957 config->ftruncate = lp_parm_bool(SNUM(handle->conn), "gpfs",
1960 config->getrealfilename = lp_parm_bool(SNUM(handle->conn), "gpfs",
1961 "getrealfilename", true);
1963 config->dfreequota = lp_parm_bool(SNUM(handle->conn), "gpfs",
1964 "dfreequota", false);
1966 config->prealloc = lp_parm_bool(SNUM(handle->conn), "gpfs",
1969 config->acl = lp_parm_bool(SNUM(handle->conn), "gpfs", "acl", true);
1971 config->settimes = lp_parm_bool(SNUM(handle->conn), "gpfs",
1973 config->recalls = lp_parm_bool(SNUM(handle->conn), "gpfs",
1976 SMB_VFS_HANDLE_SET_DATA(handle, config,
1977 NULL, struct gpfs_config_data,
1980 if (config->leases) {
1982 * GPFS lease code is based on kernel oplock code
1983 * so make sure it is turned on
1985 if (!lp_kernel_oplocks(SNUM(handle->conn))) {
1986 DEBUG(5, ("Enabling kernel oplocks for "
1987 "gpfs:leases to work\n"));
1988 lp_do_parameter(SNUM(handle->conn), "kernel oplocks",
1993 * as the kernel does not properly support Level II oplocks
1994 * and GPFS leases code is based on kernel infrastructure, we
1995 * need to turn off Level II oplocks if gpfs:leases is enabled
1997 if (lp_level2_oplocks(SNUM(handle->conn))) {
1998 DEBUG(5, ("gpfs:leases are enabled, disabling "
1999 "Level II oplocks\n"));
2000 lp_do_parameter(SNUM(handle->conn), "level2 oplocks",
2008 static int get_gpfs_fset_id(const char *pathname, int *fset_id)
2010 int err, fd, errno_fcntl;
2013 gpfsFcntlHeader_t hdr;
2014 gpfsGetFilesetName_t fsn;
2017 arg.hdr.totalLength = sizeof(arg);
2018 arg.hdr.fcntlVersion = GPFS_FCNTL_CURRENT_VERSION;
2019 arg.hdr.fcntlReserved = 0;
2020 arg.fsn.structLen = sizeof(arg.fsn);
2021 arg.fsn.structType = GPFS_FCNTL_GET_FILESETNAME;
2023 fd = open(pathname, O_RDONLY);
2025 DEBUG(1, ("Could not open %s: %s\n",
2026 pathname, strerror(errno)));
2030 err = gpfswrap_fcntl(fd, &arg);
2031 errno_fcntl = errno;
2035 errno = errno_fcntl;
2036 if (errno != ENOSYS) {
2037 DEBUG(1, ("GPFS_FCNTL_GET_FILESETNAME for %s failed: "
2038 "%s\n", pathname, strerror(errno)));
2043 err = gpfswrap_getfilesetid(discard_const_p(char, pathname),
2044 arg.fsn.buffer, fset_id);
2045 if (err && errno != ENOSYS) {
2046 DEBUG(1, ("gpfs_getfilesetid for %s failed: %s\n",
2047 pathname, strerror(errno)));
2052 static int get_gpfs_quota(const char *pathname, int type, int id,
2053 struct gpfs_quotaInfo *qi)
2058 ret = gpfswrap_quotactl(discard_const_p(char, pathname),
2059 GPFS_QCMD(Q_GETQUOTA, type), id, qi);
2062 if (errno == GPFS_E_NO_QUOTA_INST) {
2063 DEBUG(10, ("Quotas disabled on GPFS filesystem.\n"));
2064 } else if (errno != ENOSYS) {
2065 DEBUG(0, ("Get quota failed, type %d, id, %d, "
2066 "errno %d.\n", type, id, errno));
2072 DEBUG(10, ("quota type %d, id %d, blk u:%lld h:%lld s:%lld gt:%u\n",
2073 type, id, qi->blockUsage, qi->blockHardLimit,
2074 qi->blockSoftLimit, qi->blockGraceTime));
2079 static int vfs_gpfs_get_quotas(const char *path, uid_t uid, gid_t gid,
2081 struct gpfs_quotaInfo *qi_user,
2082 struct gpfs_quotaInfo *qi_group,
2083 struct gpfs_quotaInfo *qi_fset)
2090 * We want to always use the directory to get the fileset id,
2091 * because files might have a share mode. We also do not want
2092 * to get the parent directory when there is already a
2093 * directory to avoid stepping in a different fileset. The
2094 * path passed here is currently either "." or a filename, so
2095 * this is ok. The proper solution would be having a way to
2096 * query the fileset id without opening the file.
2098 b = parent_dirname(talloc_tos(), path, &dir_path, NULL);
2104 DEBUG(10, ("path %s, directory %s\n", path, dir_path));
2106 err = get_gpfs_fset_id(dir_path, fset_id);
2108 DEBUG(0, ("Get fset id failed path %s, dir %s, errno %d.\n",
2109 path, dir_path, errno));
2113 err = get_gpfs_quota(path, GPFS_USRQUOTA, uid, qi_user);
2118 err = get_gpfs_quota(path, GPFS_GRPQUOTA, gid, qi_group);
2123 err = get_gpfs_quota(path, GPFS_FILESETQUOTA, *fset_id, qi_fset);
2131 static void vfs_gpfs_disk_free_quota(struct gpfs_quotaInfo qi, time_t cur_time,
2132 uint64_t *dfree, uint64_t *dsize)
2134 uint64_t usage, limit;
2137 * The quota reporting is done in units of 1024 byte blocks, but
2138 * sys_fsusage uses units of 512 byte blocks, adjust the block number
2139 * accordingly. Also filter possibly negative usage counts from gpfs.
2141 usage = qi.blockUsage < 0 ? 0 : (uint64_t)qi.blockUsage * 2;
2142 limit = (uint64_t)qi.blockHardLimit * 2;
2145 * When the grace time for the exceeded soft block quota has been
2146 * exceeded, the soft block quota becomes an additional hard limit.
2148 if (qi.blockSoftLimit &&
2149 qi.blockGraceTime && cur_time > qi.blockGraceTime) {
2150 /* report disk as full */
2152 *dsize = MIN(*dsize, usage);
2155 if (!qi.blockHardLimit)
2158 if (usage >= limit) {
2159 /* report disk as full */
2161 *dsize = MIN(*dsize, usage);
2164 /* limit has not been reached, determine "free space" */
2165 *dfree = MIN(*dfree, limit - usage);
2166 *dsize = MIN(*dsize, limit);
2170 static uint64_t vfs_gpfs_disk_free(vfs_handle_struct *handle, const char *path,
2172 uint64_t *dfree, uint64_t *dsize)
2174 struct security_unix_token *utok;
2175 struct gpfs_quotaInfo qi_user, qi_group, qi_fset;
2176 struct gpfs_config_data *config;
2180 SMB_VFS_HANDLE_GET_DATA(handle, config, struct gpfs_config_data,
2181 return (uint64_t)-1);
2182 if (!config->dfreequota) {
2183 return SMB_VFS_NEXT_DISK_FREE(handle, path,
2184 bsize, dfree, dsize);
2187 err = sys_fsusage(path, dfree, dsize);
2189 DEBUG (0, ("Could not get fs usage, errno %d\n", errno));
2190 return SMB_VFS_NEXT_DISK_FREE(handle, path,
2191 bsize, dfree, dsize);
2194 /* sys_fsusage returns units of 512 bytes */
2197 DEBUG(10, ("fs dfree %llu, dsize %llu\n",
2198 (unsigned long long)*dfree, (unsigned long long)*dsize));
2200 utok = handle->conn->session_info->unix_token;
2201 err = vfs_gpfs_get_quotas(path, utok->uid, utok->gid, &fset_id,
2202 &qi_user, &qi_group, &qi_fset);
2204 return SMB_VFS_NEXT_DISK_FREE(handle, path,
2205 bsize, dfree, dsize);
2208 cur_time = time(NULL);
2210 /* Adjust free space and size according to quota limits. */
2211 vfs_gpfs_disk_free_quota(qi_user, cur_time, dfree, dsize);
2212 vfs_gpfs_disk_free_quota(qi_group, cur_time, dfree, dsize);
2214 /* Id 0 indicates the default quota, not an actual quota */
2216 vfs_gpfs_disk_free_quota(qi_fset, cur_time, dfree, dsize);
2219 disk_norm(bsize, dfree, dsize);
2223 static uint32_t vfs_gpfs_capabilities(struct vfs_handle_struct *handle,
2224 enum timestamp_set_resolution *p_ts_res)
2226 struct gpfs_config_data *config;
2229 next = SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res);
2231 SMB_VFS_HANDLE_GET_DATA(handle, config,
2232 struct gpfs_config_data,
2236 next |= FILE_SUPPORTS_REMOTE_STORAGE;
2241 static int vfs_gpfs_open(struct vfs_handle_struct *handle,
2242 struct smb_filename *smb_fname, files_struct *fsp,
2243 int flags, mode_t mode)
2245 struct gpfs_config_data *config;
2247 SMB_VFS_HANDLE_GET_DATA(handle, config,
2248 struct gpfs_config_data,
2251 if (config->hsm && !config->recalls) {
2252 if (SMB_VFS_IS_OFFLINE(handle->conn, smb_fname, &smb_fname->st))
2254 DEBUG(10, ("Refusing access to offline file %s\n",
2261 if (config->syncio) {
2264 return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
2267 static ssize_t vfs_gpfs_pread(vfs_handle_struct *handle, files_struct *fsp,
2268 void *data, size_t n, off_t offset)
2273 was_offline = SMB_VFS_IS_OFFLINE(handle->conn, fsp->fsp_name,
2274 &fsp->fsp_name->st);
2276 ret = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
2278 if ((ret != -1) && was_offline) {
2279 notify_fname(handle->conn, NOTIFY_ACTION_MODIFIED,
2280 FILE_NOTIFY_CHANGE_ATTRIBUTES,
2281 fsp->fsp_name->base_name);
2287 struct vfs_gpfs_pread_state {
2288 struct files_struct *fsp;
2294 static void vfs_gpfs_pread_done(struct tevent_req *subreq);
2296 static struct tevent_req *vfs_gpfs_pread_send(struct vfs_handle_struct *handle,
2297 TALLOC_CTX *mem_ctx,
2298 struct tevent_context *ev,
2299 struct files_struct *fsp,
2300 void *data, size_t n,
2303 struct tevent_req *req, *subreq;
2304 struct vfs_gpfs_pread_state *state;
2306 req = tevent_req_create(mem_ctx, &state, struct vfs_gpfs_pread_state);
2310 state->was_offline = SMB_VFS_IS_OFFLINE(handle->conn, fsp->fsp_name,
2311 &fsp->fsp_name->st);
2313 subreq = SMB_VFS_NEXT_PREAD_SEND(state, ev, handle, fsp, data,
2315 if (tevent_req_nomem(subreq, req)) {
2316 return tevent_req_post(req, ev);
2318 tevent_req_set_callback(subreq, vfs_gpfs_pread_done, req);
2322 static void vfs_gpfs_pread_done(struct tevent_req *subreq)
2324 struct tevent_req *req = tevent_req_callback_data(
2325 subreq, struct tevent_req);
2326 struct vfs_gpfs_pread_state *state = tevent_req_data(
2327 req, struct vfs_gpfs_pread_state);
2329 state->ret = SMB_VFS_PREAD_RECV(subreq, &state->err);
2330 TALLOC_FREE(subreq);
2331 tevent_req_done(req);
2334 static ssize_t vfs_gpfs_pread_recv(struct tevent_req *req, int *err)
2336 struct vfs_gpfs_pread_state *state = tevent_req_data(
2337 req, struct vfs_gpfs_pread_state);
2338 struct files_struct *fsp = state->fsp;
2340 if (tevent_req_is_unix_error(req, err)) {
2345 if ((state->ret != -1) && state->was_offline) {
2346 DEBUG(10, ("sending notify\n"));
2347 notify_fname(fsp->conn, NOTIFY_ACTION_MODIFIED,
2348 FILE_NOTIFY_CHANGE_ATTRIBUTES,
2349 fsp->fsp_name->base_name);
2355 static ssize_t vfs_gpfs_pwrite(vfs_handle_struct *handle, files_struct *fsp,
2356 const void *data, size_t n, off_t offset)
2361 was_offline = SMB_VFS_IS_OFFLINE(handle->conn, fsp->fsp_name,
2362 &fsp->fsp_name->st);
2364 ret = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
2366 if ((ret != -1) && was_offline) {
2367 notify_fname(handle->conn, NOTIFY_ACTION_MODIFIED,
2368 FILE_NOTIFY_CHANGE_ATTRIBUTES,
2369 fsp->fsp_name->base_name);
2375 struct vfs_gpfs_pwrite_state {
2376 struct files_struct *fsp;
2382 static void vfs_gpfs_pwrite_done(struct tevent_req *subreq);
2384 static struct tevent_req *vfs_gpfs_pwrite_send(
2385 struct vfs_handle_struct *handle,
2386 TALLOC_CTX *mem_ctx,
2387 struct tevent_context *ev,
2388 struct files_struct *fsp,
2389 const void *data, size_t n,
2392 struct tevent_req *req, *subreq;
2393 struct vfs_gpfs_pwrite_state *state;
2395 req = tevent_req_create(mem_ctx, &state, struct vfs_gpfs_pwrite_state);
2399 state->was_offline = SMB_VFS_IS_OFFLINE(handle->conn, fsp->fsp_name,
2400 &fsp->fsp_name->st);
2402 subreq = SMB_VFS_NEXT_PWRITE_SEND(state, ev, handle, fsp, data,
2404 if (tevent_req_nomem(subreq, req)) {
2405 return tevent_req_post(req, ev);
2407 tevent_req_set_callback(subreq, vfs_gpfs_pwrite_done, req);
2411 static void vfs_gpfs_pwrite_done(struct tevent_req *subreq)
2413 struct tevent_req *req = tevent_req_callback_data(
2414 subreq, struct tevent_req);
2415 struct vfs_gpfs_pwrite_state *state = tevent_req_data(
2416 req, struct vfs_gpfs_pwrite_state);
2418 state->ret = SMB_VFS_PWRITE_RECV(subreq, &state->err);
2419 TALLOC_FREE(subreq);
2420 tevent_req_done(req);
2423 static ssize_t vfs_gpfs_pwrite_recv(struct tevent_req *req, int *err)
2425 struct vfs_gpfs_pwrite_state *state = tevent_req_data(
2426 req, struct vfs_gpfs_pwrite_state);
2427 struct files_struct *fsp = state->fsp;
2429 if (tevent_req_is_unix_error(req, err)) {
2434 if ((state->ret != -1) && state->was_offline) {
2435 DEBUG(10, ("sending notify\n"));
2436 notify_fname(fsp->conn, NOTIFY_ACTION_MODIFIED,
2437 FILE_NOTIFY_CHANGE_ATTRIBUTES,
2438 fsp->fsp_name->base_name);
2445 static struct vfs_fn_pointers vfs_gpfs_fns = {
2446 .connect_fn = vfs_gpfs_connect,
2447 .disk_free_fn = vfs_gpfs_disk_free,
2448 .fs_capabilities_fn = vfs_gpfs_capabilities,
2449 .kernel_flock_fn = vfs_gpfs_kernel_flock,
2450 .linux_setlease_fn = vfs_gpfs_setlease,
2451 .get_real_filename_fn = vfs_gpfs_get_real_filename,
2452 .fget_nt_acl_fn = gpfsacl_fget_nt_acl,
2453 .get_nt_acl_fn = gpfsacl_get_nt_acl,
2454 .fset_nt_acl_fn = gpfsacl_fset_nt_acl,
2455 .sys_acl_get_file_fn = gpfsacl_sys_acl_get_file,
2456 .sys_acl_get_fd_fn = gpfsacl_sys_acl_get_fd,
2457 .sys_acl_blob_get_file_fn = gpfsacl_sys_acl_blob_get_file,
2458 .sys_acl_blob_get_fd_fn = gpfsacl_sys_acl_blob_get_fd,
2459 .sys_acl_set_file_fn = gpfsacl_sys_acl_set_file,
2460 .sys_acl_set_fd_fn = gpfsacl_sys_acl_set_fd,
2461 .sys_acl_delete_def_file_fn = gpfsacl_sys_acl_delete_def_file,
2462 .chmod_fn = vfs_gpfs_chmod,
2463 .fchmod_fn = vfs_gpfs_fchmod,
2464 .close_fn = vfs_gpfs_close,
2465 .setxattr_fn = gpfs_set_xattr,
2466 .getxattr_fn = gpfs_get_xattr,
2467 .stat_fn = vfs_gpfs_stat,
2468 .fstat_fn = vfs_gpfs_fstat,
2469 .lstat_fn = vfs_gpfs_lstat,
2470 .ntimes_fn = vfs_gpfs_ntimes,
2471 .is_offline_fn = vfs_gpfs_is_offline,
2472 .aio_force_fn = vfs_gpfs_aio_force,
2473 .sendfile_fn = vfs_gpfs_sendfile,
2474 .fallocate_fn = vfs_gpfs_fallocate,
2475 .open_fn = vfs_gpfs_open,
2476 .pread_fn = vfs_gpfs_pread,
2477 .pread_send_fn = vfs_gpfs_pread_send,
2478 .pread_recv_fn = vfs_gpfs_pread_recv,
2479 .pwrite_fn = vfs_gpfs_pwrite,
2480 .pwrite_send_fn = vfs_gpfs_pwrite_send,
2481 .pwrite_recv_fn = vfs_gpfs_pwrite_recv,
2482 .ftruncate_fn = vfs_gpfs_ftruncate
2485 NTSTATUS vfs_gpfs_init(void);
2486 NTSTATUS vfs_gpfs_init(void)
2490 ret = gpfswrap_init();
2492 DEBUG(1, ("Could not initialize GPFS library wrapper\n"));
2495 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "gpfs",