s3:libads/kerberos_proto.h: add GPL/Copyright header (cherry picked from commit 6bf32...
[Samba.git] / source3 / modules / vfs_gpfs.c
blob08e5f556eadab86f7ccf486aee68fc108494ce75
1 /*
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/>.
24 #include "includes.h"
25 #include "smbd/smbd.h"
26 #include "librpc/gen_ndr/ndr_xattr.h"
27 #include "include/smbprofile.h"
29 #undef DBGC_CLASS
30 #define DBGC_CLASS DBGC_VFS
32 #include <gpfs_gpl.h>
33 #include "nfs4_acls.h"
34 #include "vfs_gpfs.h"
35 #include "system/filesys.h"
37 struct gpfs_config_data {
38 bool sharemodes;
39 bool leases;
40 bool hsm;
44 static int vfs_gpfs_kernel_flock(vfs_handle_struct *handle, files_struct *fsp,
45 uint32 share_mode, uint32 access_mask)
48 struct gpfs_config_data *config;
50 SMB_VFS_HANDLE_GET_DATA(handle, config,
51 struct gpfs_config_data,
52 return -1);
54 START_PROFILE(syscall_kernel_flock);
56 kernel_flock(fsp->fh->fd, share_mode, access_mask);
58 if (config->sharemodes
59 && !set_gpfs_sharemode(fsp, access_mask, fsp->share_access)) {
60 return -1;
63 END_PROFILE(syscall_kernel_flock);
65 return 0;
68 static int vfs_gpfs_close(vfs_handle_struct *handle, files_struct *fsp)
71 struct gpfs_config_data *config;
73 SMB_VFS_HANDLE_GET_DATA(handle, config,
74 struct gpfs_config_data,
75 return -1);
77 if (config->sharemodes && (fsp->fh != NULL) && (fsp->fh->fd != -1)) {
78 set_gpfs_sharemode(fsp, 0, 0);
81 return SMB_VFS_NEXT_CLOSE(handle, fsp);
84 static int vfs_gpfs_setlease(vfs_handle_struct *handle, files_struct *fsp,
85 int leasetype)
87 struct gpfs_config_data *config;
88 int ret=0;
90 SMB_VFS_HANDLE_GET_DATA(handle, config,
91 struct gpfs_config_data,
92 return -1);
94 START_PROFILE(syscall_linux_setlease);
96 if (linux_set_lease_sighandler(fsp->fh->fd) == -1)
97 return -1;
99 if (config->leases) {
100 ret = set_gpfs_lease(fsp->fh->fd,leasetype);
103 if (ret < 0) {
104 /* This must have come from GPFS not being available */
105 /* or some other error, hence call the default */
106 ret = linux_setlease(fsp->fh->fd, leasetype);
109 END_PROFILE(syscall_linux_setlease);
111 return ret;
114 static int vfs_gpfs_get_real_filename(struct vfs_handle_struct *handle,
115 const char *path,
116 const char *name,
117 TALLOC_CTX *mem_ctx,
118 char **found_name)
120 int result;
121 char *full_path;
122 char real_pathname[PATH_MAX+1];
123 int buflen;
124 bool mangled;
126 mangled = mangle_is_mangled(name, handle->conn->params);
127 if (mangled) {
128 return SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name,
129 mem_ctx, found_name);
132 full_path = talloc_asprintf(talloc_tos(), "%s/%s", path, name);
133 if (full_path == NULL) {
134 errno = ENOMEM;
135 return -1;
138 buflen = sizeof(real_pathname) - 1;
140 result = smbd_gpfs_get_realfilename_path(full_path, real_pathname,
141 &buflen);
143 TALLOC_FREE(full_path);
145 if ((result == -1) && (errno == ENOSYS)) {
146 return SMB_VFS_NEXT_GET_REAL_FILENAME(
147 handle, path, name, mem_ctx, found_name);
150 if (result == -1) {
151 DEBUG(10, ("smbd_gpfs_get_realfilename_path returned %s\n",
152 strerror(errno)));
153 return -1;
157 * GPFS does not necessarily null-terminate the returned path
158 * but instead returns the buffer length in buflen.
161 if (buflen < sizeof(real_pathname)) {
162 real_pathname[buflen] = '\0';
163 } else {
164 real_pathname[sizeof(real_pathname)-1] = '\0';
167 DEBUG(10, ("smbd_gpfs_get_realfilename_path: %s/%s -> %s\n",
168 path, name, real_pathname));
170 name = strrchr_m(real_pathname, '/');
171 if (name == NULL) {
172 errno = ENOENT;
173 return -1;
176 *found_name = talloc_strdup(mem_ctx, name+1);
177 if (*found_name == NULL) {
178 errno = ENOMEM;
179 return -1;
182 return 0;
185 static void gpfs_dumpacl(int level, struct gpfs_acl *gacl)
187 int i;
188 if (gacl==NULL)
190 DEBUG(0, ("gpfs acl is NULL\n"));
191 return;
194 DEBUG(level, ("gpfs acl: nace: %d, type:%d, version:%d, level:%d, len:%d\n",
195 gacl->acl_nace, gacl->acl_type, gacl->acl_version, gacl->acl_level, gacl->acl_len));
196 for(i=0; i<gacl->acl_nace; i++)
198 struct gpfs_ace_v4 *gace = gacl->ace_v4 + i;
199 DEBUG(level, ("\tace[%d]: type:%d, flags:0x%x, mask:0x%x, iflags:0x%x, who:%u\n",
200 i, gace->aceType, gace->aceFlags, gace->aceMask,
201 gace->aceIFlags, gace->aceWho));
205 static struct gpfs_acl *gpfs_getacl_alloc(const char *fname, gpfs_aclType_t type)
207 struct gpfs_acl *acl;
208 size_t len = 200;
209 int ret;
210 TALLOC_CTX *mem_ctx = talloc_tos();
212 acl = (struct gpfs_acl *)TALLOC_SIZE(mem_ctx, len);
213 if (acl == NULL) {
214 errno = ENOMEM;
215 return NULL;
218 acl->acl_len = len;
219 acl->acl_level = 0;
220 acl->acl_version = 0;
221 acl->acl_type = type;
223 ret = smbd_gpfs_getacl((char *)fname, GPFS_GETACL_STRUCT | GPFS_ACL_SAMBA, acl);
224 if ((ret != 0) && (errno == ENOSPC)) {
225 struct gpfs_acl *new_acl = (struct gpfs_acl *)TALLOC_SIZE(
226 mem_ctx, acl->acl_len + sizeof(struct gpfs_acl));
227 if (new_acl == NULL) {
228 errno = ENOMEM;
229 return NULL;
232 new_acl->acl_len = acl->acl_len;
233 new_acl->acl_level = acl->acl_level;
234 new_acl->acl_version = acl->acl_version;
235 new_acl->acl_type = acl->acl_type;
236 acl = new_acl;
238 ret = smbd_gpfs_getacl((char *)fname, GPFS_GETACL_STRUCT | GPFS_ACL_SAMBA, acl);
240 if (ret != 0)
242 DEBUG(8, ("smbd_gpfs_getacl failed with %s\n",strerror(errno)));
243 return NULL;
246 return acl;
249 /* Tries to get nfs4 acls and returns SMB ACL allocated.
250 * On failure returns 1 if it got non-NFSv4 ACL to prompt
251 * retry with POSIX ACL checks.
252 * On failure returns -1 if there is system (GPFS) error, check errno.
253 * Returns 0 on success
255 static int gpfs_get_nfs4_acl(const char *fname, SMB4ACL_T **ppacl)
257 int i;
258 struct gpfs_acl *gacl = NULL;
259 DEBUG(10, ("gpfs_get_nfs4_acl invoked for %s\n", fname));
261 /* First get the real acl length */
262 gacl = gpfs_getacl_alloc(fname, 0);
263 if (gacl == NULL) {
264 DEBUG(9, ("gpfs_getacl failed for %s with %s\n",
265 fname, strerror(errno)));
266 return -1;
269 if (gacl->acl_type != GPFS_ACL_TYPE_NFS4) {
270 DEBUG(10, ("Got non-nfsv4 acl\n"));
271 /* Retry with POSIX ACLs check */
272 return 1;
275 *ppacl = smb_create_smb4acl();
277 DEBUG(10, ("len: %d, level: %d, version: %d, nace: %d\n",
278 gacl->acl_len, gacl->acl_level, gacl->acl_version,
279 gacl->acl_nace));
281 for (i=0; i<gacl->acl_nace; i++) {
282 struct gpfs_ace_v4 *gace = &gacl->ace_v4[i];
283 SMB_ACE4PROP_T smbace;
284 DEBUG(10, ("type: %d, iflags: %x, flags: %x, mask: %x, "
285 "who: %d\n", gace->aceType, gace->aceIFlags,
286 gace->aceFlags, gace->aceMask, gace->aceWho));
288 ZERO_STRUCT(smbace);
289 if (gace->aceIFlags & ACE4_IFLAG_SPECIAL_ID) {
290 smbace.flags |= SMB_ACE4_ID_SPECIAL;
291 switch (gace->aceWho) {
292 case ACE4_SPECIAL_OWNER:
293 smbace.who.special_id = SMB_ACE4_WHO_OWNER;
294 break;
295 case ACE4_SPECIAL_GROUP:
296 smbace.who.special_id = SMB_ACE4_WHO_GROUP;
297 break;
298 case ACE4_SPECIAL_EVERYONE:
299 smbace.who.special_id = SMB_ACE4_WHO_EVERYONE;
300 break;
301 default:
302 DEBUG(8, ("invalid special gpfs id %d "
303 "ignored\n", gace->aceWho));
304 continue; /* don't add it */
306 } else {
307 if (gace->aceFlags & ACE4_FLAG_GROUP_ID)
308 smbace.who.gid = gace->aceWho;
309 else
310 smbace.who.uid = gace->aceWho;
313 /* remove redundent deny entries */
314 if (i > 0 && gace->aceType == SMB_ACE4_ACCESS_DENIED_ACE_TYPE) {
315 struct gpfs_ace_v4 *prev = &gacl->ace_v4[i-1];
316 if (prev->aceType == SMB_ACE4_ACCESS_ALLOWED_ACE_TYPE &&
317 prev->aceFlags == gace->aceFlags &&
318 prev->aceIFlags == gace->aceIFlags &&
319 (gace->aceMask & prev->aceMask) == 0 &&
320 gace->aceWho == prev->aceWho) {
321 /* its redundent - skip it */
322 continue;
326 smbace.aceType = gace->aceType;
327 smbace.aceFlags = gace->aceFlags;
328 smbace.aceMask = gace->aceMask;
329 smb_add_ace4(*ppacl, &smbace);
332 return 0;
335 static NTSTATUS gpfsacl_fget_nt_acl(vfs_handle_struct *handle,
336 files_struct *fsp, uint32 security_info,
337 struct security_descriptor **ppdesc)
339 SMB4ACL_T *pacl = NULL;
340 int result;
342 *ppdesc = NULL;
343 result = gpfs_get_nfs4_acl(fsp->fsp_name->base_name, &pacl);
345 if (result == 0)
346 return smb_fget_nt_acl_nfs4(fsp, security_info, ppdesc, pacl);
348 if (result > 0) {
349 DEBUG(10, ("retrying with posix acl...\n"));
350 return posix_fget_nt_acl(fsp, security_info, ppdesc);
353 /* GPFS ACL was not read, something wrong happened, error code is set in errno */
354 return map_nt_error_from_unix(errno);
357 static NTSTATUS gpfsacl_get_nt_acl(vfs_handle_struct *handle,
358 const char *name,
359 uint32 security_info, struct security_descriptor **ppdesc)
361 SMB4ACL_T *pacl = NULL;
362 int result;
364 *ppdesc = NULL;
365 result = gpfs_get_nfs4_acl(name, &pacl);
367 if (result == 0)
368 return smb_get_nt_acl_nfs4(handle->conn, name, security_info, ppdesc, pacl);
370 if (result > 0) {
371 DEBUG(10, ("retrying with posix acl...\n"));
372 return posix_get_nt_acl(handle->conn, name, security_info, ppdesc);
375 /* GPFS ACL was not read, something wrong happened, error code is set in errno */
376 return map_nt_error_from_unix(errno);
379 static bool gpfsacl_process_smbacl(files_struct *fsp, SMB4ACL_T *smbacl)
381 int ret;
382 gpfs_aclLen_t gacl_len;
383 SMB4ACE_T *smbace;
384 struct gpfs_acl *gacl;
385 TALLOC_CTX *mem_ctx = talloc_tos();
387 gacl_len = sizeof(struct gpfs_acl) +
388 (smb_get_naces(smbacl)-1)*sizeof(gpfs_ace_v4_t);
390 gacl = (struct gpfs_acl *)TALLOC_SIZE(mem_ctx, gacl_len);
391 if (gacl == NULL) {
392 DEBUG(0, ("talloc failed\n"));
393 errno = ENOMEM;
394 return False;
397 gacl->acl_len = gacl_len;
398 gacl->acl_level = 0;
399 gacl->acl_version = GPFS_ACL_VERSION_NFS4;
400 gacl->acl_type = GPFS_ACL_TYPE_NFS4;
401 gacl->acl_nace = 0; /* change later... */
403 for (smbace=smb_first_ace4(smbacl); smbace!=NULL; smbace = smb_next_ace4(smbace)) {
404 struct gpfs_ace_v4 *gace = &gacl->ace_v4[gacl->acl_nace];
405 SMB_ACE4PROP_T *aceprop = smb_get_ace4(smbace);
407 gace->aceType = aceprop->aceType;
408 gace->aceFlags = aceprop->aceFlags;
409 gace->aceMask = aceprop->aceMask;
412 * GPFS can't distinguish between WRITE and APPEND on
413 * files, so one being set without the other is an
414 * error. Sorry for the many ()'s :-)
417 if (!fsp->is_directory
419 ((((gace->aceMask & ACE4_MASK_WRITE) == 0)
420 && ((gace->aceMask & ACE4_MASK_APPEND) != 0))
422 (((gace->aceMask & ACE4_MASK_WRITE) != 0)
423 && ((gace->aceMask & ACE4_MASK_APPEND) == 0)))
425 lp_parm_bool(fsp->conn->params->service, "gpfs",
426 "merge_writeappend", True)) {
427 DEBUG(2, ("vfs_gpfs.c: file [%s]: ACE contains "
428 "WRITE^APPEND, setting WRITE|APPEND\n",
429 fsp_str_dbg(fsp)));
430 gace->aceMask |= ACE4_MASK_WRITE|ACE4_MASK_APPEND;
433 gace->aceIFlags = (aceprop->flags&SMB_ACE4_ID_SPECIAL) ? ACE4_IFLAG_SPECIAL_ID : 0;
435 if (aceprop->flags&SMB_ACE4_ID_SPECIAL)
437 switch(aceprop->who.special_id)
439 case SMB_ACE4_WHO_EVERYONE:
440 gace->aceWho = ACE4_SPECIAL_EVERYONE;
441 break;
442 case SMB_ACE4_WHO_OWNER:
443 gace->aceWho = ACE4_SPECIAL_OWNER;
444 break;
445 case SMB_ACE4_WHO_GROUP:
446 gace->aceWho = ACE4_SPECIAL_GROUP;
447 break;
448 default:
449 DEBUG(8, ("unsupported special_id %d\n", aceprop->who.special_id));
450 continue; /* don't add it !!! */
452 } else {
453 /* just only for the type safety... */
454 if (aceprop->aceFlags&SMB_ACE4_IDENTIFIER_GROUP)
455 gace->aceWho = aceprop->who.gid;
456 else
457 gace->aceWho = aceprop->who.uid;
460 gacl->acl_nace++;
463 ret = smbd_gpfs_putacl(fsp->fsp_name->base_name,
464 GPFS_PUTACL_STRUCT | GPFS_ACL_SAMBA, gacl);
465 if (ret != 0) {
466 DEBUG(8, ("gpfs_putacl failed with %s\n", strerror(errno)));
467 gpfs_dumpacl(8, gacl);
468 return False;
471 DEBUG(10, ("gpfs_putacl succeeded\n"));
472 return True;
475 static NTSTATUS gpfsacl_set_nt_acl_internal(files_struct *fsp, uint32 security_info_sent, const struct security_descriptor *psd)
477 struct gpfs_acl *acl;
478 NTSTATUS result = NT_STATUS_ACCESS_DENIED;
480 acl = gpfs_getacl_alloc(fsp->fsp_name->base_name, 0);
481 if (acl == NULL)
482 return result;
484 if (acl->acl_version&GPFS_ACL_VERSION_NFS4)
486 if (lp_parm_bool(fsp->conn->params->service, "gpfs",
487 "refuse_dacl_protected", false)
488 && (psd->type&SEC_DESC_DACL_PROTECTED)) {
489 DEBUG(2, ("Rejecting unsupported ACL with DACL_PROTECTED bit set\n"));
490 return NT_STATUS_NOT_SUPPORTED;
493 result = smb_set_nt_acl_nfs4(
494 fsp, security_info_sent, psd,
495 gpfsacl_process_smbacl);
496 } else { /* assume POSIX ACL - by default... */
497 result = set_nt_acl(fsp, security_info_sent, psd);
500 return result;
503 static NTSTATUS gpfsacl_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, const struct security_descriptor *psd)
505 return gpfsacl_set_nt_acl_internal(fsp, security_info_sent, psd);
508 static SMB_ACL_T gpfs2smb_acl(const struct gpfs_acl *pacl)
510 SMB_ACL_T result;
511 int i;
513 result = sys_acl_init(pacl->acl_nace);
514 if (result == NULL) {
515 errno = ENOMEM;
516 return NULL;
519 result->count = pacl->acl_nace;
521 for (i=0; i<pacl->acl_nace; i++) {
522 struct smb_acl_entry *ace = &result->acl[i];
523 const struct gpfs_ace_v1 *g_ace = &pacl->ace_v1[i];
525 DEBUG(10, ("Converting type %d id %lu perm %x\n",
526 (int)g_ace->ace_type, (unsigned long)g_ace->ace_who,
527 (int)g_ace->ace_perm));
529 switch (g_ace->ace_type) {
530 case GPFS_ACL_USER:
531 ace->a_type = SMB_ACL_USER;
532 ace->uid = (uid_t)g_ace->ace_who;
533 break;
534 case GPFS_ACL_USER_OBJ:
535 ace->a_type = SMB_ACL_USER_OBJ;
536 break;
537 case GPFS_ACL_GROUP:
538 ace->a_type = SMB_ACL_GROUP;
539 ace->gid = (gid_t)g_ace->ace_who;
540 break;
541 case GPFS_ACL_GROUP_OBJ:
542 ace->a_type = SMB_ACL_GROUP_OBJ;
543 break;
544 case GPFS_ACL_OTHER:
545 ace->a_type = SMB_ACL_OTHER;
546 break;
547 case GPFS_ACL_MASK:
548 ace->a_type = SMB_ACL_MASK;
549 break;
550 default:
551 DEBUG(10, ("Got invalid ace_type: %d\n",
552 g_ace->ace_type));
553 errno = EINVAL;
554 SAFE_FREE(result);
555 return NULL;
558 ace->a_perm = 0;
559 ace->a_perm |= (g_ace->ace_perm & ACL_PERM_READ) ?
560 SMB_ACL_READ : 0;
561 ace->a_perm |= (g_ace->ace_perm & ACL_PERM_WRITE) ?
562 SMB_ACL_WRITE : 0;
563 ace->a_perm |= (g_ace->ace_perm & ACL_PERM_EXECUTE) ?
564 SMB_ACL_EXECUTE : 0;
566 DEBUGADD(10, ("Converted to %d perm %x\n",
567 ace->a_type, ace->a_perm));
570 return result;
573 static SMB_ACL_T gpfsacl_get_posix_acl(const char *path, gpfs_aclType_t type)
575 struct gpfs_acl *pacl;
576 SMB_ACL_T result = NULL;
578 pacl = gpfs_getacl_alloc(path, type);
580 if (pacl == NULL) {
581 DEBUG(10, ("gpfs_getacl failed for %s with %s\n",
582 path, strerror(errno)));
583 if (errno == 0) {
584 errno = EINVAL;
586 goto done;
589 if (pacl->acl_version != GPFS_ACL_VERSION_POSIX) {
590 DEBUG(10, ("Got acl version %d, expected %d\n",
591 pacl->acl_version, GPFS_ACL_VERSION_POSIX));
592 errno = EINVAL;
593 goto done;
596 DEBUG(10, ("len: %d, level: %d, version: %d, nace: %d\n",
597 pacl->acl_len, pacl->acl_level, pacl->acl_version,
598 pacl->acl_nace));
600 result = gpfs2smb_acl(pacl);
601 if (result == NULL) {
602 goto done;
605 done:
607 if (errno != 0) {
608 SAFE_FREE(result);
610 return result;
613 static SMB_ACL_T gpfsacl_sys_acl_get_file(vfs_handle_struct *handle,
614 const char *path_p,
615 SMB_ACL_TYPE_T type)
617 gpfs_aclType_t gpfs_type;
619 switch(type) {
620 case SMB_ACL_TYPE_ACCESS:
621 gpfs_type = GPFS_ACL_TYPE_ACCESS;
622 break;
623 case SMB_ACL_TYPE_DEFAULT:
624 gpfs_type = GPFS_ACL_TYPE_DEFAULT;
625 break;
626 default:
627 DEBUG(0, ("Got invalid type: %d\n", type));
628 smb_panic("exiting");
631 return gpfsacl_get_posix_acl(path_p, gpfs_type);
634 static SMB_ACL_T gpfsacl_sys_acl_get_fd(vfs_handle_struct *handle,
635 files_struct *fsp)
637 return gpfsacl_get_posix_acl(fsp->fsp_name->base_name,
638 GPFS_ACL_TYPE_ACCESS);
641 static struct gpfs_acl *smb2gpfs_acl(const SMB_ACL_T pacl,
642 SMB_ACL_TYPE_T type)
644 gpfs_aclLen_t len;
645 struct gpfs_acl *result;
646 int i;
647 union gpfs_ace_union
649 gpfs_ace_v1_t ace_v1[1]; /* when GPFS_ACL_VERSION_POSIX */
650 gpfs_ace_v4_t ace_v4[1]; /* when GPFS_ACL_VERSION_NFS4 */
653 DEBUG(10, ("smb2gpfs_acl: Got ACL with %d entries\n", pacl->count));
655 len = sizeof(struct gpfs_acl) - sizeof(union gpfs_ace_union) +
656 (pacl->count)*sizeof(gpfs_ace_v1_t);
658 result = (struct gpfs_acl *)SMB_MALLOC(len);
659 if (result == NULL) {
660 errno = ENOMEM;
661 return result;
664 result->acl_len = len;
665 result->acl_level = 0;
666 result->acl_version = GPFS_ACL_VERSION_POSIX;
667 result->acl_type = (type == SMB_ACL_TYPE_DEFAULT) ?
668 GPFS_ACL_TYPE_DEFAULT : GPFS_ACL_TYPE_ACCESS;
669 result->acl_nace = pacl->count;
671 for (i=0; i<pacl->count; i++) {
672 const struct smb_acl_entry *ace = &pacl->acl[i];
673 struct gpfs_ace_v1 *g_ace = &result->ace_v1[i];
675 DEBUG(10, ("Converting type %d perm %x\n",
676 (int)ace->a_type, (int)ace->a_perm));
678 g_ace->ace_perm = 0;
680 switch(ace->a_type) {
681 case SMB_ACL_USER:
682 g_ace->ace_type = GPFS_ACL_USER;
683 g_ace->ace_who = (gpfs_uid_t)ace->uid;
684 break;
685 case SMB_ACL_USER_OBJ:
686 g_ace->ace_type = GPFS_ACL_USER_OBJ;
687 g_ace->ace_perm |= ACL_PERM_CONTROL;
688 g_ace->ace_who = 0;
689 break;
690 case SMB_ACL_GROUP:
691 g_ace->ace_type = GPFS_ACL_GROUP;
692 g_ace->ace_who = (gpfs_uid_t)ace->gid;
693 break;
694 case SMB_ACL_GROUP_OBJ:
695 g_ace->ace_type = GPFS_ACL_GROUP_OBJ;
696 g_ace->ace_who = 0;
697 break;
698 case SMB_ACL_MASK:
699 g_ace->ace_type = GPFS_ACL_MASK;
700 g_ace->ace_perm = 0x8f;
701 g_ace->ace_who = 0;
702 break;
703 case SMB_ACL_OTHER:
704 g_ace->ace_type = GPFS_ACL_OTHER;
705 g_ace->ace_who = 0;
706 break;
707 default:
708 DEBUG(10, ("Got invalid ace_type: %d\n", ace->a_type));
709 errno = EINVAL;
710 SAFE_FREE(result);
711 return NULL;
714 g_ace->ace_perm |= (ace->a_perm & SMB_ACL_READ) ?
715 ACL_PERM_READ : 0;
716 g_ace->ace_perm |= (ace->a_perm & SMB_ACL_WRITE) ?
717 ACL_PERM_WRITE : 0;
718 g_ace->ace_perm |= (ace->a_perm & SMB_ACL_EXECUTE) ?
719 ACL_PERM_EXECUTE : 0;
721 DEBUGADD(10, ("Converted to %d id %d perm %x\n",
722 g_ace->ace_type, g_ace->ace_who, g_ace->ace_perm));
725 return result;
728 static int gpfsacl_sys_acl_set_file(vfs_handle_struct *handle,
729 const char *name,
730 SMB_ACL_TYPE_T type,
731 SMB_ACL_T theacl)
733 struct gpfs_acl *gpfs_acl;
734 int result;
736 gpfs_acl = smb2gpfs_acl(theacl, type);
737 if (gpfs_acl == NULL) {
738 return -1;
741 result = smbd_gpfs_putacl((char *)name, GPFS_PUTACL_STRUCT | GPFS_ACL_SAMBA, gpfs_acl);
743 SAFE_FREE(gpfs_acl);
744 return result;
747 static int gpfsacl_sys_acl_set_fd(vfs_handle_struct *handle,
748 files_struct *fsp,
749 SMB_ACL_T theacl)
751 return gpfsacl_sys_acl_set_file(handle, fsp->fsp_name->base_name,
752 SMB_ACL_TYPE_ACCESS, theacl);
755 static int gpfsacl_sys_acl_delete_def_file(vfs_handle_struct *handle,
756 const char *path)
758 errno = ENOTSUP;
759 return -1;
763 * Assumed: mode bits are shiftable and standard
764 * Output: the new aceMask field for an smb nfs4 ace
766 static uint32 gpfsacl_mask_filter(uint32 aceType, uint32 aceMask, uint32 rwx)
768 const uint32 posix_nfs4map[3] = {
769 SMB_ACE4_EXECUTE, /* execute */
770 SMB_ACE4_WRITE_DATA | SMB_ACE4_APPEND_DATA, /* write; GPFS specific */
771 SMB_ACE4_READ_DATA /* read */
773 int i;
774 uint32_t posix_mask = 0x01;
775 uint32_t posix_bit;
776 uint32_t nfs4_bits;
778 for(i=0; i<3; i++) {
779 nfs4_bits = posix_nfs4map[i];
780 posix_bit = rwx & posix_mask;
782 if (aceType==SMB_ACE4_ACCESS_ALLOWED_ACE_TYPE) {
783 if (posix_bit)
784 aceMask |= nfs4_bits;
785 else
786 aceMask &= ~nfs4_bits;
787 } else {
788 /* add deny bits when suitable */
789 if (!posix_bit)
790 aceMask |= nfs4_bits;
791 else
792 aceMask &= ~nfs4_bits;
793 } /* other ace types are unexpected */
795 posix_mask <<= 1;
798 return aceMask;
801 static int gpfsacl_emu_chmod(const char *path, mode_t mode)
803 SMB4ACL_T *pacl = NULL;
804 int result;
805 bool haveAllowEntry[SMB_ACE4_WHO_EVERYONE + 1] = {False, False, False, False};
806 int i;
807 files_struct fake_fsp; /* TODO: rationalize parametrization */
808 SMB4ACE_T *smbace;
809 NTSTATUS status;
811 DEBUG(10, ("gpfsacl_emu_chmod invoked for %s mode %o\n", path, mode));
813 result = gpfs_get_nfs4_acl(path, &pacl);
814 if (result)
815 return result;
817 if (mode & ~(S_IRWXU | S_IRWXG | S_IRWXO)) {
818 DEBUG(2, ("WARNING: cutting extra mode bits %o on %s\n", mode, path));
821 for (smbace=smb_first_ace4(pacl); smbace!=NULL; smbace = smb_next_ace4(smbace)) {
822 SMB_ACE4PROP_T *ace = smb_get_ace4(smbace);
823 uint32_t specid = ace->who.special_id;
825 if (ace->flags&SMB_ACE4_ID_SPECIAL &&
826 ace->aceType<=SMB_ACE4_ACCESS_DENIED_ACE_TYPE &&
827 specid <= SMB_ACE4_WHO_EVERYONE) {
829 uint32_t newMask;
831 if (ace->aceType==SMB_ACE4_ACCESS_ALLOWED_ACE_TYPE)
832 haveAllowEntry[specid] = True;
834 /* mode >> 6 for @owner, mode >> 3 for @group,
835 * mode >> 0 for @everyone */
836 newMask = gpfsacl_mask_filter(ace->aceType, ace->aceMask,
837 mode >> ((SMB_ACE4_WHO_EVERYONE - specid) * 3));
838 if (ace->aceMask!=newMask) {
839 DEBUG(10, ("ace changed for %s (%o -> %o) id=%d\n",
840 path, ace->aceMask, newMask, specid));
842 ace->aceMask = newMask;
846 /* make sure we have at least ALLOW entries
847 * for all the 3 special ids (@EVERYONE, @OWNER, @GROUP)
848 * - if necessary
850 for(i = SMB_ACE4_WHO_OWNER; i<=SMB_ACE4_WHO_EVERYONE; i++) {
851 SMB_ACE4PROP_T ace;
853 if (haveAllowEntry[i]==True)
854 continue;
856 ZERO_STRUCT(ace);
857 ace.aceType = SMB_ACE4_ACCESS_ALLOWED_ACE_TYPE;
858 ace.flags |= SMB_ACE4_ID_SPECIAL;
859 ace.who.special_id = i;
861 if (i==SMB_ACE4_WHO_GROUP) /* not sure it's necessary... */
862 ace.aceFlags |= SMB_ACE4_IDENTIFIER_GROUP;
864 ace.aceMask = gpfsacl_mask_filter(ace.aceType, ace.aceMask,
865 mode >> ((SMB_ACE4_WHO_EVERYONE - i) * 3));
867 /* don't add unnecessary aces */
868 if (!ace.aceMask)
869 continue;
871 /* we add it to the END - as windows expects allow aces */
872 smb_add_ace4(pacl, &ace);
873 DEBUG(10, ("Added ALLOW ace for %s, mode=%o, id=%d, aceMask=%x\n",
874 path, mode, i, ace.aceMask));
877 /* don't add complementary DENY ACEs here */
878 ZERO_STRUCT(fake_fsp);
879 status = create_synthetic_smb_fname(talloc_tos(), path, NULL, NULL,
880 &fake_fsp.fsp_name);
881 if (!NT_STATUS_IS_OK(status)) {
882 errno = map_errno_from_nt_status(status);
883 return -1;
885 /* put the acl */
886 if (gpfsacl_process_smbacl(&fake_fsp, pacl) == False) {
887 TALLOC_FREE(fake_fsp.fsp_name);
888 return -1;
891 TALLOC_FREE(fake_fsp.fsp_name);
892 return 0; /* ok for [f]chmod */
895 static int vfs_gpfs_chmod(vfs_handle_struct *handle, const char *path, mode_t mode)
897 struct smb_filename *smb_fname_cpath;
898 int rc;
899 NTSTATUS status;
901 status = create_synthetic_smb_fname(
902 talloc_tos(), path, NULL, NULL, &smb_fname_cpath);
904 if (SMB_VFS_NEXT_STAT(handle, smb_fname_cpath) != 0) {
905 return -1;
908 /* avoid chmod() if possible, to preserve acls */
909 if ((smb_fname_cpath->st.st_ex_mode & ~S_IFMT) == mode) {
910 return 0;
913 rc = gpfsacl_emu_chmod(path, mode);
914 if (rc == 1)
915 return SMB_VFS_NEXT_CHMOD(handle, path, mode);
916 return rc;
919 static int vfs_gpfs_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mode)
921 SMB_STRUCT_STAT st;
922 int rc;
924 if (SMB_VFS_NEXT_FSTAT(handle, fsp, &st) != 0) {
925 return -1;
928 /* avoid chmod() if possible, to preserve acls */
929 if ((st.st_ex_mode & ~S_IFMT) == mode) {
930 return 0;
933 rc = gpfsacl_emu_chmod(fsp->fsp_name->base_name, mode);
934 if (rc == 1)
935 return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
936 return rc;
939 static int gpfs_set_xattr(struct vfs_handle_struct *handle, const char *path,
940 const char *name, const void *value, size_t size, int flags){
941 struct xattr_DOSATTRIB dosattrib;
942 enum ndr_err_code ndr_err;
943 DATA_BLOB blob;
944 const char *attrstr = value;
945 unsigned int dosmode=0;
946 struct gpfs_winattr attrs;
947 int ret = 0;
949 DEBUG(10, ("gpfs_set_xattr: %s \n",path));
951 /* Only handle DOS Attributes */
952 if (strcmp(name,SAMBA_XATTR_DOS_ATTRIB) != 0){
953 DEBUG(1, ("gpfs_set_xattr:name is %s\n",name));
954 return SMB_VFS_NEXT_SETXATTR(handle,path,name,value,size,flags);
957 blob.data = (uint8_t *)attrstr;
958 blob.length = size;
960 ndr_err = ndr_pull_struct_blob(&blob, talloc_tos(), &dosattrib,
961 (ndr_pull_flags_fn_t)ndr_pull_xattr_DOSATTRIB);
963 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
964 DEBUG(1, ("gpfs_set_xattr: bad ndr decode "
965 "from EA on file %s: Error = %s\n",
966 path, ndr_errstr(ndr_err)));
967 return false;
970 if (dosattrib.version != 3) {
971 DEBUG(1, ("gpfs_set_xattr: expected dosattrib version 3, got "
972 "%d\n", (int)dosattrib.version));
973 return false;
975 if (!(dosattrib.info.info3.valid_flags & XATTR_DOSINFO_ATTRIB)) {
976 DEBUG(10, ("gpfs_set_xattr: XATTR_DOSINFO_ATTRIB not "
977 "valid, ignoring\n"));
978 return true;
981 dosmode = dosattrib.info.info3.attrib;
983 attrs.winAttrs = 0;
984 /*Just map RD_ONLY, ARCHIVE, SYSTEM HIDDEN and SPARSE. Ignore the others*/
985 if (dosmode & FILE_ATTRIBUTE_ARCHIVE){
986 attrs.winAttrs |= GPFS_WINATTR_ARCHIVE;
988 if (dosmode & FILE_ATTRIBUTE_HIDDEN){
989 attrs.winAttrs |= GPFS_WINATTR_HIDDEN;
991 if (dosmode & FILE_ATTRIBUTE_SYSTEM){
992 attrs.winAttrs |= GPFS_WINATTR_SYSTEM;
994 if (dosmode & FILE_ATTRIBUTE_READONLY){
995 attrs.winAttrs |= GPFS_WINATTR_READONLY;
997 if (dosmode & FILE_ATTRIBUTE_SPARSE) {
998 attrs.winAttrs |= GPFS_WINATTR_SPARSE_FILE;
1002 ret = set_gpfs_winattrs(CONST_DISCARD(char *, path),
1003 GPFS_WINATTR_SET_ATTRS, &attrs);
1004 if ( ret == -1){
1005 if (errno == ENOSYS) {
1006 return SMB_VFS_NEXT_SETXATTR(handle, path, name, value,
1007 size, flags);
1010 DEBUG(1, ("gpfs_set_xattr:Set GPFS attributes failed %d\n",ret));
1011 return -1;
1014 DEBUG(10, ("gpfs_set_xattr:Set attributes: 0x%x\n",attrs.winAttrs));
1015 return 0;
1018 static ssize_t gpfs_get_xattr(struct vfs_handle_struct *handle, const char *path,
1019 const char *name, void *value, size_t size){
1020 char *attrstr = value;
1021 unsigned int dosmode = 0;
1022 struct gpfs_winattr attrs;
1023 int ret = 0;
1025 DEBUG(10, ("gpfs_get_xattr: %s \n",path));
1027 /* Only handle DOS Attributes */
1028 if (strcmp(name,SAMBA_XATTR_DOS_ATTRIB) != 0){
1029 DEBUG(1, ("gpfs_get_xattr:name is %s\n",name));
1030 return SMB_VFS_NEXT_GETXATTR(handle,path,name,value,size);
1033 ret = get_gpfs_winattrs(CONST_DISCARD(char *, path), &attrs);
1034 if ( ret == -1){
1035 if (errno == ENOSYS) {
1036 return SMB_VFS_NEXT_GETXATTR(handle, path, name, value,
1037 size);
1040 DEBUG(1, ("gpfs_get_xattr: Get GPFS attributes failed: "
1041 "%d (%s)\n", ret, strerror(errno)));
1042 return -1;
1045 DEBUG(10, ("gpfs_get_xattr:Got attributes: 0x%x\n",attrs.winAttrs));
1047 /*Just map RD_ONLY, ARCHIVE, SYSTEM, HIDDEN and SPARSE. Ignore the others*/
1048 if (attrs.winAttrs & GPFS_WINATTR_ARCHIVE){
1049 dosmode |= FILE_ATTRIBUTE_ARCHIVE;
1051 if (attrs.winAttrs & GPFS_WINATTR_HIDDEN){
1052 dosmode |= FILE_ATTRIBUTE_HIDDEN;
1054 if (attrs.winAttrs & GPFS_WINATTR_SYSTEM){
1055 dosmode |= FILE_ATTRIBUTE_SYSTEM;
1057 if (attrs.winAttrs & GPFS_WINATTR_READONLY){
1058 dosmode |= FILE_ATTRIBUTE_READONLY;
1060 if (attrs.winAttrs & GPFS_WINATTR_SPARSE_FILE) {
1061 dosmode |= FILE_ATTRIBUTE_SPARSE;
1064 snprintf(attrstr, size, "0x%2.2x",
1065 (unsigned int)(dosmode & SAMBA_ATTRIBUTES_MASK));
1066 DEBUG(10, ("gpfs_get_xattr: returning %s\n",attrstr));
1067 return 4;
1070 static int vfs_gpfs_stat(struct vfs_handle_struct *handle,
1071 struct smb_filename *smb_fname)
1073 struct gpfs_winattr attrs;
1074 char *fname = NULL;
1075 NTSTATUS status;
1076 int ret;
1078 ret = SMB_VFS_NEXT_STAT(handle, smb_fname);
1079 if (ret == -1) {
1080 return -1;
1082 status = get_full_smb_filename(talloc_tos(), smb_fname, &fname);
1083 if (!NT_STATUS_IS_OK(status)) {
1084 errno = map_errno_from_nt_status(status);
1085 return -1;
1087 ret = get_gpfs_winattrs(CONST_DISCARD(char *, fname), &attrs);
1088 TALLOC_FREE(fname);
1089 if (ret == 0) {
1090 smb_fname->st.st_ex_btime.tv_sec = attrs.creationTime.tv_sec;
1091 smb_fname->st.st_ex_btime.tv_nsec = attrs.creationTime.tv_nsec;
1092 smb_fname->st.vfs_private = attrs.winAttrs;
1094 return 0;
1097 static int vfs_gpfs_fstat(struct vfs_handle_struct *handle,
1098 struct files_struct *fsp, SMB_STRUCT_STAT *sbuf)
1100 struct gpfs_winattr attrs;
1101 int ret;
1103 ret = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
1104 if (ret == -1) {
1105 return -1;
1107 if ((fsp->fh == NULL) || (fsp->fh->fd == -1)) {
1108 return 0;
1110 ret = smbd_fget_gpfs_winattrs(fsp->fh->fd, &attrs);
1111 if (ret == 0) {
1112 sbuf->st_ex_btime.tv_sec = attrs.creationTime.tv_sec;
1113 sbuf->st_ex_btime.tv_nsec = attrs.creationTime.tv_nsec;
1115 return 0;
1118 static int vfs_gpfs_lstat(struct vfs_handle_struct *handle,
1119 struct smb_filename *smb_fname)
1121 struct gpfs_winattr attrs;
1122 char *path = NULL;
1123 NTSTATUS status;
1124 int ret;
1126 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname);
1127 if (ret == -1) {
1128 return -1;
1130 status = get_full_smb_filename(talloc_tos(), smb_fname, &path);
1131 if (!NT_STATUS_IS_OK(status)) {
1132 errno = map_errno_from_nt_status(status);
1133 return -1;
1135 ret = get_gpfs_winattrs(CONST_DISCARD(char *, path), &attrs);
1136 TALLOC_FREE(path);
1137 if (ret == 0) {
1138 smb_fname->st.st_ex_btime.tv_sec = attrs.creationTime.tv_sec;
1139 smb_fname->st.st_ex_btime.tv_nsec = attrs.creationTime.tv_nsec;
1140 smb_fname->st.vfs_private = attrs.winAttrs;
1142 return 0;
1145 static int vfs_gpfs_ntimes(struct vfs_handle_struct *handle,
1146 const struct smb_filename *smb_fname,
1147 struct smb_file_time *ft)
1150 struct gpfs_winattr attrs;
1151 int ret;
1152 char *path = NULL;
1153 NTSTATUS status;
1155 ret = SMB_VFS_NEXT_NTIMES(handle, smb_fname, ft);
1156 if(ret == -1){
1157 DEBUG(1,("vfs_gpfs_ntimes: SMB_VFS_NEXT_NTIMES failed\n"));
1158 return -1;
1161 if(null_timespec(ft->create_time)){
1162 DEBUG(10,("vfs_gpfs_ntimes:Create Time is NULL\n"));
1163 return 0;
1166 status = get_full_smb_filename(talloc_tos(), smb_fname, &path);
1167 if (!NT_STATUS_IS_OK(status)) {
1168 errno = map_errno_from_nt_status(status);
1169 return -1;
1172 attrs.winAttrs = 0;
1173 attrs.creationTime.tv_sec = ft->create_time.tv_sec;
1174 attrs.creationTime.tv_nsec = ft->create_time.tv_nsec;
1176 ret = set_gpfs_winattrs(CONST_DISCARD(char *, path),
1177 GPFS_WINATTR_SET_CREATION_TIME, &attrs);
1178 if(ret == -1 && errno != ENOSYS){
1179 DEBUG(1,("vfs_gpfs_ntimes: set GPFS ntimes failed %d\n",ret));
1180 return -1;
1182 return 0;
1186 static int vfs_gpfs_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
1187 SMB_OFF_T len)
1189 int result;
1191 result = smbd_gpfs_ftruncate(fsp->fh->fd, len);
1192 if ((result == -1) && (errno == ENOSYS)) {
1193 return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
1195 return result;
1198 static bool vfs_gpfs_is_offline(struct vfs_handle_struct *handle,
1199 const struct smb_filename *fname,
1200 SMB_STRUCT_STAT *sbuf)
1202 struct gpfs_winattr attrs;
1203 char *path = NULL;
1204 NTSTATUS status;
1206 status = get_full_smb_filename(talloc_tos(), fname, &path);
1207 if (!NT_STATUS_IS_OK(status)) {
1208 errno = map_errno_from_nt_status(status);
1209 return -1;
1212 if (VALID_STAT(*sbuf)) {
1213 attrs.winAttrs = sbuf->vfs_private;
1214 } else {
1215 int ret;
1216 ret = get_gpfs_winattrs(path, &attrs);
1218 if (ret == -1) {
1219 TALLOC_FREE(path);
1220 return false;
1223 if ((attrs.winAttrs & GPFS_WINATTR_OFFLINE) != 0) {
1224 DEBUG(10, ("%s is offline\n", path));
1225 TALLOC_FREE(path);
1226 return true;
1228 DEBUG(10, ("%s is online\n", path));
1229 TALLOC_FREE(path);
1230 return SMB_VFS_NEXT_IS_OFFLINE(handle, fname, sbuf);
1233 static bool vfs_gpfs_aio_force(struct vfs_handle_struct *handle,
1234 struct files_struct *fsp)
1236 return vfs_gpfs_is_offline(handle, fsp->fsp_name, &fsp->fsp_name->st);
1239 static ssize_t vfs_gpfs_sendfile(vfs_handle_struct *handle, int tofd,
1240 files_struct *fsp, const DATA_BLOB *hdr,
1241 SMB_OFF_T offset, size_t n)
1243 if ((fsp->fsp_name->st.vfs_private & GPFS_WINATTR_OFFLINE) != 0) {
1244 errno = ENOSYS;
1245 return -1;
1247 return SMB_VFS_NEXT_SENDFILE(handle, tofd, fsp, hdr, offset, n);
1250 int vfs_gpfs_connect(struct vfs_handle_struct *handle, const char *service,
1251 const char *user)
1253 struct gpfs_config_data *config;
1255 smbd_gpfs_lib_init();
1257 int ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
1259 if (ret < 0) {
1260 return ret;
1263 config = talloc_zero(handle->conn, struct gpfs_config_data);
1264 if (!config) {
1265 SMB_VFS_NEXT_DISCONNECT(handle);
1266 DEBUG(0, ("talloc_zero() failed\n")); return -1;
1269 config->sharemodes = lp_parm_bool(SNUM(handle->conn), "gpfs",
1270 "sharemodes", true);
1272 config->leases = lp_parm_bool(SNUM(handle->conn), "gpfs",
1273 "leases", true);
1275 config->hsm = lp_parm_bool(SNUM(handle->conn), "gpfs",
1276 "hsm", false);
1278 SMB_VFS_HANDLE_SET_DATA(handle, config,
1279 NULL, struct gpfs_config_data,
1280 return -1);
1282 return 0;
1285 static uint32_t vfs_gpfs_capabilities(struct vfs_handle_struct *handle,
1286 enum timestamp_set_resolution *p_ts_res)
1288 struct gpfs_config_data *config;
1289 uint32_t next;
1291 next = SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res);
1293 SMB_VFS_HANDLE_GET_DATA(handle, config,
1294 struct gpfs_config_data,
1295 return next);
1297 if (config->hsm) {
1298 next |= FILE_SUPPORTS_REMOTE_STORAGE;
1300 return next;
1303 static int vfs_gpfs_open(struct vfs_handle_struct *handle,
1304 struct smb_filename *smb_fname, files_struct *fsp,
1305 int flags, mode_t mode)
1307 if (lp_parm_bool(fsp->conn->params->service, "gpfs", "syncio",
1308 false)) {
1309 flags |= O_SYNC;
1311 return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
1315 static struct vfs_fn_pointers vfs_gpfs_fns = {
1316 .connect_fn = vfs_gpfs_connect,
1317 .fs_capabilities = vfs_gpfs_capabilities,
1318 .kernel_flock = vfs_gpfs_kernel_flock,
1319 .linux_setlease = vfs_gpfs_setlease,
1320 .get_real_filename = vfs_gpfs_get_real_filename,
1321 .fget_nt_acl = gpfsacl_fget_nt_acl,
1322 .get_nt_acl = gpfsacl_get_nt_acl,
1323 .fset_nt_acl = gpfsacl_fset_nt_acl,
1324 .sys_acl_get_file = gpfsacl_sys_acl_get_file,
1325 .sys_acl_get_fd = gpfsacl_sys_acl_get_fd,
1326 .sys_acl_set_file = gpfsacl_sys_acl_set_file,
1327 .sys_acl_set_fd = gpfsacl_sys_acl_set_fd,
1328 .sys_acl_delete_def_file = gpfsacl_sys_acl_delete_def_file,
1329 .chmod = vfs_gpfs_chmod,
1330 .fchmod = vfs_gpfs_fchmod,
1331 .close_fn = vfs_gpfs_close,
1332 .setxattr = gpfs_set_xattr,
1333 .getxattr = gpfs_get_xattr,
1334 .stat = vfs_gpfs_stat,
1335 .fstat = vfs_gpfs_fstat,
1336 .lstat = vfs_gpfs_lstat,
1337 .ntimes = vfs_gpfs_ntimes,
1338 .is_offline = vfs_gpfs_is_offline,
1339 .aio_force = vfs_gpfs_aio_force,
1340 .sendfile = vfs_gpfs_sendfile,
1341 .open_fn = vfs_gpfs_open,
1342 .ftruncate = vfs_gpfs_ftruncate
1345 NTSTATUS vfs_gpfs_init(void);
1346 NTSTATUS vfs_gpfs_init(void)
1348 init_gpfs();
1350 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "gpfs",
1351 &vfs_gpfs_fns);