s3:vfs_gpfs fix a memory leak in gpfsacl_get_posix_acl
[Samba/gebeck_regimport.git] / source3 / modules / vfs_gpfs.c
blob8f5a19cd602b551661a2aa35adc674860a73c67e
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"
36 #include "auth.h"
37 #include "lib/util/tevent_unix.h"
39 struct gpfs_config_data {
40 bool sharemodes;
41 bool leases;
42 bool hsm;
43 bool syncio;
44 bool winattr;
45 bool ftruncate;
46 bool getrealfilename;
47 bool dfreequota;
48 bool prealloc;
49 bool acl;
53 static int vfs_gpfs_kernel_flock(vfs_handle_struct *handle, files_struct *fsp,
54 uint32 share_mode, uint32 access_mask)
57 struct gpfs_config_data *config;
58 int ret = 0;
60 SMB_VFS_HANDLE_GET_DATA(handle, config,
61 struct gpfs_config_data,
62 return -1);
64 if(!config->sharemodes) {
65 return 0;
68 START_PROFILE(syscall_kernel_flock);
70 kernel_flock(fsp->fh->fd, share_mode, access_mask);
72 if (!set_gpfs_sharemode(fsp, access_mask, fsp->share_access)) {
73 ret = -1;
76 END_PROFILE(syscall_kernel_flock);
78 return ret;
81 static int vfs_gpfs_close(vfs_handle_struct *handle, files_struct *fsp)
84 struct gpfs_config_data *config;
86 SMB_VFS_HANDLE_GET_DATA(handle, config,
87 struct gpfs_config_data,
88 return -1);
90 if (config->sharemodes && (fsp->fh != NULL) && (fsp->fh->fd != -1)) {
91 set_gpfs_sharemode(fsp, 0, 0);
94 return SMB_VFS_NEXT_CLOSE(handle, fsp);
97 static int vfs_gpfs_setlease(vfs_handle_struct *handle, files_struct *fsp,
98 int leasetype)
100 struct gpfs_config_data *config;
101 int ret=0;
103 SMB_VFS_HANDLE_GET_DATA(handle, config,
104 struct gpfs_config_data,
105 return -1);
107 if (linux_set_lease_sighandler(fsp->fh->fd) == -1)
108 return -1;
110 START_PROFILE(syscall_linux_setlease);
112 if (config->leases) {
113 ret = set_gpfs_lease(fsp->fh->fd,leasetype);
116 END_PROFILE(syscall_linux_setlease);
118 return ret;
121 static int vfs_gpfs_get_real_filename(struct vfs_handle_struct *handle,
122 const char *path,
123 const char *name,
124 TALLOC_CTX *mem_ctx,
125 char **found_name)
127 int result;
128 char *full_path;
129 char real_pathname[PATH_MAX+1];
130 int buflen;
131 bool mangled;
132 struct gpfs_config_data *config;
134 SMB_VFS_HANDLE_GET_DATA(handle, config,
135 struct gpfs_config_data,
136 return -1);
138 if (!config->getrealfilename) {
139 return SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name,
140 mem_ctx, found_name);
143 mangled = mangle_is_mangled(name, handle->conn->params);
144 if (mangled) {
145 return SMB_VFS_NEXT_GET_REAL_FILENAME(handle, path, name,
146 mem_ctx, found_name);
149 full_path = talloc_asprintf(talloc_tos(), "%s/%s", path, name);
150 if (full_path == NULL) {
151 errno = ENOMEM;
152 return -1;
155 buflen = sizeof(real_pathname) - 1;
157 result = smbd_gpfs_get_realfilename_path(full_path, real_pathname,
158 &buflen);
160 TALLOC_FREE(full_path);
162 if ((result == -1) && (errno == ENOSYS)) {
163 return SMB_VFS_NEXT_GET_REAL_FILENAME(
164 handle, path, name, mem_ctx, found_name);
167 if (result == -1) {
168 DEBUG(10, ("smbd_gpfs_get_realfilename_path returned %s\n",
169 strerror(errno)));
170 return -1;
174 * GPFS does not necessarily null-terminate the returned path
175 * but instead returns the buffer length in buflen.
178 if (buflen < sizeof(real_pathname)) {
179 real_pathname[buflen] = '\0';
180 } else {
181 real_pathname[sizeof(real_pathname)-1] = '\0';
184 DEBUG(10, ("smbd_gpfs_get_realfilename_path: %s/%s -> %s\n",
185 path, name, real_pathname));
187 name = strrchr_m(real_pathname, '/');
188 if (name == NULL) {
189 errno = ENOENT;
190 return -1;
193 *found_name = talloc_strdup(mem_ctx, name+1);
194 if (*found_name == NULL) {
195 errno = ENOMEM;
196 return -1;
199 return 0;
202 static void gpfs_dumpacl(int level, struct gpfs_acl *gacl)
204 gpfs_aclCount_t i;
205 if (gacl==NULL)
207 DEBUG(0, ("gpfs acl is NULL\n"));
208 return;
211 DEBUG(level, ("gpfs acl: nace: %d, type:%d, version:%d, level:%d, len:%d\n",
212 gacl->acl_nace, gacl->acl_type, gacl->acl_version, gacl->acl_level, gacl->acl_len));
213 for(i=0; i<gacl->acl_nace; i++)
215 struct gpfs_ace_v4 *gace = gacl->ace_v4 + i;
216 DEBUG(level, ("\tace[%d]: type:%d, flags:0x%x, mask:0x%x, iflags:0x%x, who:%u\n",
217 i, gace->aceType, gace->aceFlags, gace->aceMask,
218 gace->aceIFlags, gace->aceWho));
222 static struct gpfs_acl *gpfs_getacl_alloc(const char *fname, gpfs_aclType_t type)
224 struct gpfs_acl *acl;
225 size_t len = 200;
226 int ret;
227 TALLOC_CTX *mem_ctx = talloc_tos();
229 acl = (struct gpfs_acl *)TALLOC_SIZE(mem_ctx, len);
230 if (acl == NULL) {
231 errno = ENOMEM;
232 return NULL;
235 acl->acl_len = len;
236 acl->acl_level = 0;
237 acl->acl_version = 0;
238 acl->acl_type = type;
240 ret = smbd_gpfs_getacl((char *)fname, GPFS_GETACL_STRUCT, acl);
241 if ((ret != 0) && (errno == ENOSPC)) {
242 struct gpfs_acl *new_acl = (struct gpfs_acl *)TALLOC_SIZE(
243 mem_ctx, acl->acl_len + sizeof(struct gpfs_acl));
244 if (new_acl == NULL) {
245 talloc_free(acl);
246 errno = ENOMEM;
247 return NULL;
250 new_acl->acl_len = acl->acl_len;
251 new_acl->acl_level = acl->acl_level;
252 new_acl->acl_version = acl->acl_version;
253 new_acl->acl_type = acl->acl_type;
254 talloc_free(acl);
255 acl = new_acl;
257 ret = smbd_gpfs_getacl((char *)fname, GPFS_GETACL_STRUCT, acl);
259 if (ret != 0) {
260 DEBUG(8, ("smbd_gpfs_getacl failed with %s\n",strerror(errno)));
261 talloc_free(acl);
262 return NULL;
265 return acl;
268 /* Tries to get nfs4 acls and returns SMB ACL allocated.
269 * On failure returns 1 if it got non-NFSv4 ACL to prompt
270 * retry with POSIX ACL checks.
271 * On failure returns -1 if there is system (GPFS) error, check errno.
272 * Returns 0 on success
274 static int gpfs_get_nfs4_acl(const char *fname, SMB4ACL_T **ppacl)
276 gpfs_aclCount_t i;
277 struct gpfs_acl *gacl = NULL;
278 DEBUG(10, ("gpfs_get_nfs4_acl invoked for %s\n", fname));
280 /* First get the real acl length */
281 gacl = gpfs_getacl_alloc(fname, 0);
282 if (gacl == NULL) {
283 DEBUG(9, ("gpfs_getacl failed for %s with %s\n",
284 fname, strerror(errno)));
285 return -1;
288 if (gacl->acl_type != GPFS_ACL_TYPE_NFS4) {
289 DEBUG(10, ("Got non-nfsv4 acl\n"));
290 /* Retry with POSIX ACLs check */
291 talloc_free(gacl);
292 return 1;
295 *ppacl = smb_create_smb4acl();
297 DEBUG(10, ("len: %d, level: %d, version: %d, nace: %d\n",
298 gacl->acl_len, gacl->acl_level, gacl->acl_version,
299 gacl->acl_nace));
301 for (i=0; i<gacl->acl_nace; i++) {
302 struct gpfs_ace_v4 *gace = &gacl->ace_v4[i];
303 SMB_ACE4PROP_T smbace;
304 DEBUG(10, ("type: %d, iflags: %x, flags: %x, mask: %x, "
305 "who: %d\n", gace->aceType, gace->aceIFlags,
306 gace->aceFlags, gace->aceMask, gace->aceWho));
308 ZERO_STRUCT(smbace);
309 if (gace->aceIFlags & ACE4_IFLAG_SPECIAL_ID) {
310 smbace.flags |= SMB_ACE4_ID_SPECIAL;
311 switch (gace->aceWho) {
312 case ACE4_SPECIAL_OWNER:
313 smbace.who.special_id = SMB_ACE4_WHO_OWNER;
314 break;
315 case ACE4_SPECIAL_GROUP:
316 smbace.who.special_id = SMB_ACE4_WHO_GROUP;
317 break;
318 case ACE4_SPECIAL_EVERYONE:
319 smbace.who.special_id = SMB_ACE4_WHO_EVERYONE;
320 break;
321 default:
322 DEBUG(8, ("invalid special gpfs id %d "
323 "ignored\n", gace->aceWho));
324 continue; /* don't add it */
326 } else {
327 if (gace->aceFlags & ACE4_FLAG_GROUP_ID)
328 smbace.who.gid = gace->aceWho;
329 else
330 smbace.who.uid = gace->aceWho;
333 /* remove redundent deny entries */
334 if (i > 0 && gace->aceType == SMB_ACE4_ACCESS_DENIED_ACE_TYPE) {
335 struct gpfs_ace_v4 *prev = &gacl->ace_v4[i-1];
336 if (prev->aceType == SMB_ACE4_ACCESS_ALLOWED_ACE_TYPE &&
337 prev->aceFlags == gace->aceFlags &&
338 prev->aceIFlags == gace->aceIFlags &&
339 (gace->aceMask & prev->aceMask) == 0 &&
340 gace->aceWho == prev->aceWho) {
341 /* its redundent - skip it */
342 continue;
346 smbace.aceType = gace->aceType;
347 smbace.aceFlags = gace->aceFlags;
348 smbace.aceMask = gace->aceMask;
349 smb_add_ace4(*ppacl, &smbace);
352 return 0;
355 static NTSTATUS gpfsacl_fget_nt_acl(vfs_handle_struct *handle,
356 files_struct *fsp, uint32 security_info,
357 TALLOC_CTX *mem_ctx,
358 struct security_descriptor **ppdesc)
360 SMB4ACL_T *pacl = NULL;
361 int result;
362 struct gpfs_config_data *config;
364 *ppdesc = NULL;
366 SMB_VFS_HANDLE_GET_DATA(handle, config,
367 struct gpfs_config_data,
368 return NT_STATUS_INTERNAL_ERROR);
370 if (!config->acl) {
371 return SMB_VFS_NEXT_FGET_NT_ACL(handle, fsp, security_info,
372 mem_ctx, ppdesc);
375 result = gpfs_get_nfs4_acl(fsp->fsp_name->base_name, &pacl);
377 if (result == 0)
378 return smb_fget_nt_acl_nfs4(fsp, security_info, mem_ctx, ppdesc, pacl);
380 if (result > 0) {
381 DEBUG(10, ("retrying with posix acl...\n"));
382 return posix_fget_nt_acl(fsp, security_info, mem_ctx, ppdesc);
385 /* GPFS ACL was not read, something wrong happened, error code is set in errno */
386 return map_nt_error_from_unix(errno);
389 static NTSTATUS gpfsacl_get_nt_acl(vfs_handle_struct *handle,
390 const char *name,
391 uint32 security_info,
392 TALLOC_CTX *mem_ctx, struct security_descriptor **ppdesc)
394 SMB4ACL_T *pacl = NULL;
395 int result;
396 struct gpfs_config_data *config;
398 *ppdesc = NULL;
400 SMB_VFS_HANDLE_GET_DATA(handle, config,
401 struct gpfs_config_data,
402 return NT_STATUS_INTERNAL_ERROR);
404 if (!config->acl) {
405 return SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info,
406 mem_ctx, ppdesc);
409 result = gpfs_get_nfs4_acl(name, &pacl);
411 if (result == 0)
412 return smb_get_nt_acl_nfs4(handle->conn, name, security_info,
413 mem_ctx, ppdesc, pacl);
415 if (result > 0) {
416 DEBUG(10, ("retrying with posix acl...\n"));
417 return posix_get_nt_acl(handle->conn, name, security_info,
418 mem_ctx, ppdesc);
421 /* GPFS ACL was not read, something wrong happened, error code is set in errno */
422 return map_nt_error_from_unix(errno);
425 static bool gpfsacl_process_smbacl(files_struct *fsp, SMB4ACL_T *smbacl)
427 int ret;
428 gpfs_aclLen_t gacl_len;
429 SMB4ACE_T *smbace;
430 struct gpfs_acl *gacl;
431 TALLOC_CTX *mem_ctx = talloc_tos();
433 gacl_len = offsetof(gpfs_acl_t, ace_v4) + smb_get_naces(smbacl) *
434 sizeof(gpfs_ace_v4_t);
436 gacl = (struct gpfs_acl *)TALLOC_SIZE(mem_ctx, gacl_len);
437 if (gacl == NULL) {
438 DEBUG(0, ("talloc failed\n"));
439 errno = ENOMEM;
440 return False;
443 gacl->acl_len = gacl_len;
444 gacl->acl_level = 0;
445 gacl->acl_version = GPFS_ACL_VERSION_NFS4;
446 gacl->acl_type = GPFS_ACL_TYPE_NFS4;
447 gacl->acl_nace = 0; /* change later... */
449 for (smbace=smb_first_ace4(smbacl); smbace!=NULL; smbace = smb_next_ace4(smbace)) {
450 struct gpfs_ace_v4 *gace = &gacl->ace_v4[gacl->acl_nace];
451 SMB_ACE4PROP_T *aceprop = smb_get_ace4(smbace);
453 gace->aceType = aceprop->aceType;
454 gace->aceFlags = aceprop->aceFlags;
455 gace->aceMask = aceprop->aceMask;
458 * GPFS can't distinguish between WRITE and APPEND on
459 * files, so one being set without the other is an
460 * error. Sorry for the many ()'s :-)
463 if (!fsp->is_directory
465 ((((gace->aceMask & ACE4_MASK_WRITE) == 0)
466 && ((gace->aceMask & ACE4_MASK_APPEND) != 0))
468 (((gace->aceMask & ACE4_MASK_WRITE) != 0)
469 && ((gace->aceMask & ACE4_MASK_APPEND) == 0)))
471 lp_parm_bool(fsp->conn->params->service, "gpfs",
472 "merge_writeappend", True)) {
473 DEBUG(2, ("vfs_gpfs.c: file [%s]: ACE contains "
474 "WRITE^APPEND, setting WRITE|APPEND\n",
475 fsp_str_dbg(fsp)));
476 gace->aceMask |= ACE4_MASK_WRITE|ACE4_MASK_APPEND;
479 gace->aceIFlags = (aceprop->flags&SMB_ACE4_ID_SPECIAL) ? ACE4_IFLAG_SPECIAL_ID : 0;
481 if (aceprop->flags&SMB_ACE4_ID_SPECIAL)
483 switch(aceprop->who.special_id)
485 case SMB_ACE4_WHO_EVERYONE:
486 gace->aceWho = ACE4_SPECIAL_EVERYONE;
487 break;
488 case SMB_ACE4_WHO_OWNER:
489 gace->aceWho = ACE4_SPECIAL_OWNER;
490 break;
491 case SMB_ACE4_WHO_GROUP:
492 gace->aceWho = ACE4_SPECIAL_GROUP;
493 break;
494 default:
495 DEBUG(8, ("unsupported special_id %d\n", aceprop->who.special_id));
496 continue; /* don't add it !!! */
498 } else {
499 /* just only for the type safety... */
500 if (aceprop->aceFlags&SMB_ACE4_IDENTIFIER_GROUP)
501 gace->aceWho = aceprop->who.gid;
502 else
503 gace->aceWho = aceprop->who.uid;
506 gacl->acl_nace++;
509 ret = smbd_gpfs_putacl(fsp->fsp_name->base_name,
510 GPFS_PUTACL_STRUCT | GPFS_ACL_SAMBA, gacl);
511 if (ret != 0) {
512 DEBUG(8, ("gpfs_putacl failed with %s\n", strerror(errno)));
513 gpfs_dumpacl(8, gacl);
514 return False;
517 DEBUG(10, ("gpfs_putacl succeeded\n"));
518 return True;
521 static NTSTATUS gpfsacl_set_nt_acl_internal(files_struct *fsp, uint32 security_info_sent, const struct security_descriptor *psd)
523 struct gpfs_acl *acl;
524 NTSTATUS result = NT_STATUS_ACCESS_DENIED;
526 acl = gpfs_getacl_alloc(fsp->fsp_name->base_name, 0);
527 if (acl == NULL)
528 return result;
530 if (acl->acl_version&GPFS_ACL_VERSION_NFS4)
532 if (lp_parm_bool(fsp->conn->params->service, "gpfs",
533 "refuse_dacl_protected", false)
534 && (psd->type&SEC_DESC_DACL_PROTECTED)) {
535 DEBUG(2, ("Rejecting unsupported ACL with DACL_PROTECTED bit set\n"));
536 return NT_STATUS_NOT_SUPPORTED;
539 result = smb_set_nt_acl_nfs4(
540 fsp, security_info_sent, psd,
541 gpfsacl_process_smbacl);
542 } else { /* assume POSIX ACL - by default... */
543 result = set_nt_acl(fsp, security_info_sent, psd);
546 return result;
549 static NTSTATUS gpfsacl_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, const struct security_descriptor *psd)
551 struct gpfs_config_data *config;
553 SMB_VFS_HANDLE_GET_DATA(handle, config,
554 struct gpfs_config_data,
555 return NT_STATUS_INTERNAL_ERROR);
557 if (!config->acl) {
558 return SMB_VFS_NEXT_FSET_NT_ACL(handle, fsp, security_info_sent, psd);
561 return gpfsacl_set_nt_acl_internal(fsp, security_info_sent, psd);
564 static SMB_ACL_T gpfs2smb_acl(const struct gpfs_acl *pacl, TALLOC_CTX *mem_ctx)
566 SMB_ACL_T result;
567 gpfs_aclCount_t i;
569 result = sys_acl_init(mem_ctx);
570 if (result == NULL) {
571 errno = ENOMEM;
572 return NULL;
575 result->count = pacl->acl_nace;
576 result->acl = talloc_realloc(result, result->acl, struct smb_acl_entry,
577 result->count);
579 for (i=0; i<pacl->acl_nace; i++) {
580 struct smb_acl_entry *ace = &result->acl[i];
581 const struct gpfs_ace_v1 *g_ace = &pacl->ace_v1[i];
583 DEBUG(10, ("Converting type %d id %lu perm %x\n",
584 (int)g_ace->ace_type, (unsigned long)g_ace->ace_who,
585 (int)g_ace->ace_perm));
587 switch (g_ace->ace_type) {
588 case GPFS_ACL_USER:
589 ace->a_type = SMB_ACL_USER;
590 ace->info.user.uid = (uid_t)g_ace->ace_who;
591 break;
592 case GPFS_ACL_USER_OBJ:
593 ace->a_type = SMB_ACL_USER_OBJ;
594 break;
595 case GPFS_ACL_GROUP:
596 ace->a_type = SMB_ACL_GROUP;
597 ace->info.group.gid = (gid_t)g_ace->ace_who;
598 break;
599 case GPFS_ACL_GROUP_OBJ:
600 ace->a_type = SMB_ACL_GROUP_OBJ;
601 break;
602 case GPFS_ACL_OTHER:
603 ace->a_type = SMB_ACL_OTHER;
604 break;
605 case GPFS_ACL_MASK:
606 ace->a_type = SMB_ACL_MASK;
607 break;
608 default:
609 DEBUG(10, ("Got invalid ace_type: %d\n",
610 g_ace->ace_type));
611 errno = EINVAL;
612 TALLOC_FREE(result);
613 return NULL;
616 ace->a_perm = 0;
617 ace->a_perm |= (g_ace->ace_perm & ACL_PERM_READ) ?
618 SMB_ACL_READ : 0;
619 ace->a_perm |= (g_ace->ace_perm & ACL_PERM_WRITE) ?
620 SMB_ACL_WRITE : 0;
621 ace->a_perm |= (g_ace->ace_perm & ACL_PERM_EXECUTE) ?
622 SMB_ACL_EXECUTE : 0;
624 DEBUGADD(10, ("Converted to %d perm %x\n",
625 ace->a_type, ace->a_perm));
628 return result;
631 static SMB_ACL_T gpfsacl_get_posix_acl(const char *path, gpfs_aclType_t type,
632 TALLOC_CTX *mem_ctx)
634 struct gpfs_acl *pacl;
635 SMB_ACL_T result = NULL;
637 pacl = gpfs_getacl_alloc(path, type);
639 if (pacl == NULL) {
640 DEBUG(10, ("gpfs_getacl failed for %s with %s\n",
641 path, strerror(errno)));
642 if (errno == 0) {
643 errno = EINVAL;
645 goto done;
648 if (pacl->acl_version != GPFS_ACL_VERSION_POSIX) {
649 DEBUG(10, ("Got acl version %d, expected %d\n",
650 pacl->acl_version, GPFS_ACL_VERSION_POSIX));
651 errno = EINVAL;
652 goto done;
655 DEBUG(10, ("len: %d, level: %d, version: %d, nace: %d\n",
656 pacl->acl_len, pacl->acl_level, pacl->acl_version,
657 pacl->acl_nace));
659 result = gpfs2smb_acl(pacl, mem_ctx);
660 if (result != NULL) {
661 errno = 0;
664 done:
666 if (pacl != NULL) {
667 talloc_free(pacl);
669 if (errno != 0) {
670 TALLOC_FREE(result);
672 return result;
675 static SMB_ACL_T gpfsacl_sys_acl_get_file(vfs_handle_struct *handle,
676 const char *path_p,
677 SMB_ACL_TYPE_T type,
678 TALLOC_CTX *mem_ctx)
680 gpfs_aclType_t gpfs_type;
681 struct gpfs_config_data *config;
683 SMB_VFS_HANDLE_GET_DATA(handle, config,
684 struct gpfs_config_data,
685 return NULL);
687 if (!config->acl) {
688 return SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, path_p,
689 type, mem_ctx);
692 switch(type) {
693 case SMB_ACL_TYPE_ACCESS:
694 gpfs_type = GPFS_ACL_TYPE_ACCESS;
695 break;
696 case SMB_ACL_TYPE_DEFAULT:
697 gpfs_type = GPFS_ACL_TYPE_DEFAULT;
698 break;
699 default:
700 DEBUG(0, ("Got invalid type: %d\n", type));
701 smb_panic("exiting");
704 return gpfsacl_get_posix_acl(path_p, gpfs_type, mem_ctx);
707 static SMB_ACL_T gpfsacl_sys_acl_get_fd(vfs_handle_struct *handle,
708 files_struct *fsp,
709 TALLOC_CTX *mem_ctx)
711 struct gpfs_config_data *config;
713 SMB_VFS_HANDLE_GET_DATA(handle, config,
714 struct gpfs_config_data,
715 return NULL);
717 if (!config->acl) {
718 return SMB_VFS_NEXT_SYS_ACL_GET_FD(handle, fsp, mem_ctx);
721 return gpfsacl_get_posix_acl(fsp->fsp_name->base_name,
722 GPFS_ACL_TYPE_ACCESS, mem_ctx);
725 static int gpfsacl_sys_acl_blob_get_file(vfs_handle_struct *handle,
726 const char *path_p,
727 TALLOC_CTX *mem_ctx,
728 char **blob_description,
729 DATA_BLOB *blob)
731 struct gpfs_config_data *config;
732 SMB4ACL_T *pacl = NULL;
733 int result;
735 SMB_VFS_HANDLE_GET_DATA(handle, config,
736 struct gpfs_config_data,
737 return -1);
739 if (!config->acl) {
740 return SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, path_p,
741 mem_ctx,
742 blob_description,
743 blob);
746 result = gpfs_get_nfs4_acl(path_p, &pacl);
747 if (result == 0) {
748 /* We don't have a way to linearlise the NFS4 ACL
749 * right now, and it is much closer to the NT ACL
750 * anyway */
751 errno = EINVAL;
752 return -1;
755 return posix_sys_acl_blob_get_file(handle, path_p, mem_ctx,
756 blob_description, blob);
759 static int gpfsacl_sys_acl_blob_get_fd(vfs_handle_struct *handle,
760 files_struct *fsp,
761 TALLOC_CTX *mem_ctx,
762 char **blob_description,
763 DATA_BLOB *blob)
765 struct gpfs_config_data *config;
766 SMB4ACL_T *pacl = NULL;
767 int result;
769 SMB_VFS_HANDLE_GET_DATA(handle, config,
770 struct gpfs_config_data,
771 return -1);
773 if (!config->acl) {
774 return SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FD(handle, fsp, mem_ctx,
775 blob_description, blob);
778 result = gpfs_get_nfs4_acl(fsp->fsp_name->base_name, &pacl);
779 if (result == 0) {
780 /* We don't have a way to linearlise the NFS4 ACL
781 * right now, and it is much closer to the NT ACL
782 * anyway */
783 errno = EINVAL;
784 return -1;
787 return posix_sys_acl_blob_get_fd(handle, fsp, mem_ctx,
788 blob_description, blob);
791 static struct gpfs_acl *smb2gpfs_acl(const SMB_ACL_T pacl,
792 SMB_ACL_TYPE_T type)
794 gpfs_aclLen_t len;
795 struct gpfs_acl *result;
796 int i;
798 DEBUG(10, ("smb2gpfs_acl: Got ACL with %d entries\n", pacl->count));
800 len = offsetof(gpfs_acl_t, ace_v1) + (pacl->count) *
801 sizeof(gpfs_ace_v1_t);
803 result = (struct gpfs_acl *)SMB_MALLOC(len);
804 if (result == NULL) {
805 errno = ENOMEM;
806 return result;
809 result->acl_len = len;
810 result->acl_level = 0;
811 result->acl_version = GPFS_ACL_VERSION_POSIX;
812 result->acl_type = (type == SMB_ACL_TYPE_DEFAULT) ?
813 GPFS_ACL_TYPE_DEFAULT : GPFS_ACL_TYPE_ACCESS;
814 result->acl_nace = pacl->count;
816 for (i=0; i<pacl->count; i++) {
817 const struct smb_acl_entry *ace = &pacl->acl[i];
818 struct gpfs_ace_v1 *g_ace = &result->ace_v1[i];
820 DEBUG(10, ("Converting type %d perm %x\n",
821 (int)ace->a_type, (int)ace->a_perm));
823 g_ace->ace_perm = 0;
825 switch(ace->a_type) {
826 case SMB_ACL_USER:
827 g_ace->ace_type = GPFS_ACL_USER;
828 g_ace->ace_who = (gpfs_uid_t)ace->info.user.uid;
829 break;
830 case SMB_ACL_USER_OBJ:
831 g_ace->ace_type = GPFS_ACL_USER_OBJ;
832 g_ace->ace_perm |= ACL_PERM_CONTROL;
833 g_ace->ace_who = 0;
834 break;
835 case SMB_ACL_GROUP:
836 g_ace->ace_type = GPFS_ACL_GROUP;
837 g_ace->ace_who = (gpfs_uid_t)ace->info.group.gid;
838 break;
839 case SMB_ACL_GROUP_OBJ:
840 g_ace->ace_type = GPFS_ACL_GROUP_OBJ;
841 g_ace->ace_who = 0;
842 break;
843 case SMB_ACL_MASK:
844 g_ace->ace_type = GPFS_ACL_MASK;
845 g_ace->ace_perm = 0x8f;
846 g_ace->ace_who = 0;
847 break;
848 case SMB_ACL_OTHER:
849 g_ace->ace_type = GPFS_ACL_OTHER;
850 g_ace->ace_who = 0;
851 break;
852 default:
853 DEBUG(10, ("Got invalid ace_type: %d\n", ace->a_type));
854 errno = EINVAL;
855 SAFE_FREE(result);
856 return NULL;
859 g_ace->ace_perm |= (ace->a_perm & SMB_ACL_READ) ?
860 ACL_PERM_READ : 0;
861 g_ace->ace_perm |= (ace->a_perm & SMB_ACL_WRITE) ?
862 ACL_PERM_WRITE : 0;
863 g_ace->ace_perm |= (ace->a_perm & SMB_ACL_EXECUTE) ?
864 ACL_PERM_EXECUTE : 0;
866 DEBUGADD(10, ("Converted to %d id %d perm %x\n",
867 g_ace->ace_type, g_ace->ace_who, g_ace->ace_perm));
870 return result;
873 static int gpfsacl_sys_acl_set_file(vfs_handle_struct *handle,
874 const char *name,
875 SMB_ACL_TYPE_T type,
876 SMB_ACL_T theacl)
878 struct gpfs_acl *gpfs_acl;
879 int result;
880 struct gpfs_config_data *config;
882 SMB_VFS_HANDLE_GET_DATA(handle, config,
883 struct gpfs_config_data,
884 return -1);
886 if (!config->acl) {
887 return SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name, type, theacl);
890 gpfs_acl = smb2gpfs_acl(theacl, type);
891 if (gpfs_acl == NULL) {
892 return -1;
895 result = smbd_gpfs_putacl((char *)name, GPFS_PUTACL_STRUCT | GPFS_ACL_SAMBA, gpfs_acl);
897 SAFE_FREE(gpfs_acl);
898 return result;
901 static int gpfsacl_sys_acl_set_fd(vfs_handle_struct *handle,
902 files_struct *fsp,
903 SMB_ACL_T theacl)
905 struct gpfs_config_data *config;
907 SMB_VFS_HANDLE_GET_DATA(handle, config,
908 struct gpfs_config_data,
909 return -1);
911 if (!config->acl) {
912 return SMB_VFS_NEXT_SYS_ACL_SET_FD(handle, fsp, theacl);
915 return gpfsacl_sys_acl_set_file(handle, fsp->fsp_name->base_name,
916 SMB_ACL_TYPE_ACCESS, theacl);
919 static int gpfsacl_sys_acl_delete_def_file(vfs_handle_struct *handle,
920 const char *path)
922 struct gpfs_config_data *config;
924 SMB_VFS_HANDLE_GET_DATA(handle, config,
925 struct gpfs_config_data,
926 return -1);
928 if (!config->acl) {
929 return SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path);
932 errno = ENOTSUP;
933 return -1;
937 * Assumed: mode bits are shiftable and standard
938 * Output: the new aceMask field for an smb nfs4 ace
940 static uint32 gpfsacl_mask_filter(uint32 aceType, uint32 aceMask, uint32 rwx)
942 const uint32 posix_nfs4map[3] = {
943 SMB_ACE4_EXECUTE, /* execute */
944 SMB_ACE4_WRITE_DATA | SMB_ACE4_APPEND_DATA, /* write; GPFS specific */
945 SMB_ACE4_READ_DATA /* read */
947 int i;
948 uint32_t posix_mask = 0x01;
949 uint32_t posix_bit;
950 uint32_t nfs4_bits;
952 for(i=0; i<3; i++) {
953 nfs4_bits = posix_nfs4map[i];
954 posix_bit = rwx & posix_mask;
956 if (aceType==SMB_ACE4_ACCESS_ALLOWED_ACE_TYPE) {
957 if (posix_bit)
958 aceMask |= nfs4_bits;
959 else
960 aceMask &= ~nfs4_bits;
961 } else {
962 /* add deny bits when suitable */
963 if (!posix_bit)
964 aceMask |= nfs4_bits;
965 else
966 aceMask &= ~nfs4_bits;
967 } /* other ace types are unexpected */
969 posix_mask <<= 1;
972 return aceMask;
975 static int gpfsacl_emu_chmod(const char *path, mode_t mode)
977 SMB4ACL_T *pacl = NULL;
978 int result;
979 bool haveAllowEntry[SMB_ACE4_WHO_EVERYONE + 1] = {False, False, False, False};
980 int i;
981 files_struct fake_fsp; /* TODO: rationalize parametrization */
982 SMB4ACE_T *smbace;
983 NTSTATUS status;
985 DEBUG(10, ("gpfsacl_emu_chmod invoked for %s mode %o\n", path, mode));
987 result = gpfs_get_nfs4_acl(path, &pacl);
988 if (result)
989 return result;
991 if (mode & ~(S_IRWXU | S_IRWXG | S_IRWXO)) {
992 DEBUG(2, ("WARNING: cutting extra mode bits %o on %s\n", mode, path));
995 for (smbace=smb_first_ace4(pacl); smbace!=NULL; smbace = smb_next_ace4(smbace)) {
996 SMB_ACE4PROP_T *ace = smb_get_ace4(smbace);
997 uint32_t specid = ace->who.special_id;
999 if (ace->flags&SMB_ACE4_ID_SPECIAL &&
1000 ace->aceType<=SMB_ACE4_ACCESS_DENIED_ACE_TYPE &&
1001 specid <= SMB_ACE4_WHO_EVERYONE) {
1003 uint32_t newMask;
1005 if (ace->aceType==SMB_ACE4_ACCESS_ALLOWED_ACE_TYPE)
1006 haveAllowEntry[specid] = True;
1008 /* mode >> 6 for @owner, mode >> 3 for @group,
1009 * mode >> 0 for @everyone */
1010 newMask = gpfsacl_mask_filter(ace->aceType, ace->aceMask,
1011 mode >> ((SMB_ACE4_WHO_EVERYONE - specid) * 3));
1012 if (ace->aceMask!=newMask) {
1013 DEBUG(10, ("ace changed for %s (%o -> %o) id=%d\n",
1014 path, ace->aceMask, newMask, specid));
1016 ace->aceMask = newMask;
1020 /* make sure we have at least ALLOW entries
1021 * for all the 3 special ids (@EVERYONE, @OWNER, @GROUP)
1022 * - if necessary
1024 for(i = SMB_ACE4_WHO_OWNER; i<=SMB_ACE4_WHO_EVERYONE; i++) {
1025 SMB_ACE4PROP_T ace;
1027 if (haveAllowEntry[i]==True)
1028 continue;
1030 ZERO_STRUCT(ace);
1031 ace.aceType = SMB_ACE4_ACCESS_ALLOWED_ACE_TYPE;
1032 ace.flags |= SMB_ACE4_ID_SPECIAL;
1033 ace.who.special_id = i;
1035 if (i==SMB_ACE4_WHO_GROUP) /* not sure it's necessary... */
1036 ace.aceFlags |= SMB_ACE4_IDENTIFIER_GROUP;
1038 ace.aceMask = gpfsacl_mask_filter(ace.aceType, ace.aceMask,
1039 mode >> ((SMB_ACE4_WHO_EVERYONE - i) * 3));
1041 /* don't add unnecessary aces */
1042 if (!ace.aceMask)
1043 continue;
1045 /* we add it to the END - as windows expects allow aces */
1046 smb_add_ace4(pacl, &ace);
1047 DEBUG(10, ("Added ALLOW ace for %s, mode=%o, id=%d, aceMask=%x\n",
1048 path, mode, i, ace.aceMask));
1051 /* don't add complementary DENY ACEs here */
1052 ZERO_STRUCT(fake_fsp);
1053 status = create_synthetic_smb_fname(talloc_tos(), path, NULL, NULL,
1054 &fake_fsp.fsp_name);
1055 if (!NT_STATUS_IS_OK(status)) {
1056 errno = map_errno_from_nt_status(status);
1057 return -1;
1059 /* put the acl */
1060 if (gpfsacl_process_smbacl(&fake_fsp, pacl) == False) {
1061 TALLOC_FREE(fake_fsp.fsp_name);
1062 return -1;
1065 TALLOC_FREE(fake_fsp.fsp_name);
1066 return 0; /* ok for [f]chmod */
1069 static int vfs_gpfs_chmod(vfs_handle_struct *handle, const char *path, mode_t mode)
1071 struct smb_filename *smb_fname_cpath;
1072 int rc;
1073 NTSTATUS status;
1075 status = create_synthetic_smb_fname(
1076 talloc_tos(), path, NULL, NULL, &smb_fname_cpath);
1078 if (SMB_VFS_NEXT_STAT(handle, smb_fname_cpath) != 0) {
1079 return -1;
1082 /* avoid chmod() if possible, to preserve acls */
1083 if ((smb_fname_cpath->st.st_ex_mode & ~S_IFMT) == mode) {
1084 return 0;
1087 rc = gpfsacl_emu_chmod(path, mode);
1088 if (rc == 1)
1089 return SMB_VFS_NEXT_CHMOD(handle, path, mode);
1090 return rc;
1093 static int vfs_gpfs_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mode)
1095 SMB_STRUCT_STAT st;
1096 int rc;
1098 if (SMB_VFS_NEXT_FSTAT(handle, fsp, &st) != 0) {
1099 return -1;
1102 /* avoid chmod() if possible, to preserve acls */
1103 if ((st.st_ex_mode & ~S_IFMT) == mode) {
1104 return 0;
1107 rc = gpfsacl_emu_chmod(fsp->fsp_name->base_name, mode);
1108 if (rc == 1)
1109 return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
1110 return rc;
1113 static int gpfs_set_xattr(struct vfs_handle_struct *handle, const char *path,
1114 const char *name, const void *value, size_t size, int flags){
1115 struct xattr_DOSATTRIB dosattrib;
1116 enum ndr_err_code ndr_err;
1117 DATA_BLOB blob;
1118 const char *attrstr = value;
1119 unsigned int dosmode=0;
1120 struct gpfs_winattr attrs;
1121 int ret = 0;
1122 struct gpfs_config_data *config;
1124 SMB_VFS_HANDLE_GET_DATA(handle, config,
1125 struct gpfs_config_data,
1126 return -1);
1128 if (!config->winattr) {
1129 DEBUG(10, ("gpfs_set_xattr:name is %s -> next\n",name));
1130 return SMB_VFS_NEXT_SETXATTR(handle,path,name,value,size,flags);
1133 DEBUG(10, ("gpfs_set_xattr: %s \n",path));
1135 /* Only handle DOS Attributes */
1136 if (strcmp(name,SAMBA_XATTR_DOS_ATTRIB) != 0){
1137 DEBUG(5, ("gpfs_set_xattr:name is %s\n",name));
1138 return SMB_VFS_NEXT_SETXATTR(handle,path,name,value,size,flags);
1141 blob.data = (uint8_t *)attrstr;
1142 blob.length = size;
1144 ndr_err = ndr_pull_struct_blob(&blob, talloc_tos(), &dosattrib,
1145 (ndr_pull_flags_fn_t)ndr_pull_xattr_DOSATTRIB);
1147 if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
1148 DEBUG(1, ("gpfs_set_xattr: bad ndr decode "
1149 "from EA on file %s: Error = %s\n",
1150 path, ndr_errstr(ndr_err)));
1151 return false;
1154 if (dosattrib.version != 3) {
1155 DEBUG(1, ("gpfs_set_xattr: expected dosattrib version 3, got "
1156 "%d\n", (int)dosattrib.version));
1157 return false;
1159 if (!(dosattrib.info.info3.valid_flags & XATTR_DOSINFO_ATTRIB)) {
1160 DEBUG(10, ("gpfs_set_xattr: XATTR_DOSINFO_ATTRIB not "
1161 "valid, ignoring\n"));
1162 return true;
1165 dosmode = dosattrib.info.info3.attrib;
1167 attrs.winAttrs = 0;
1168 /*Just map RD_ONLY, ARCHIVE, SYSTEM HIDDEN and SPARSE. Ignore the others*/
1169 if (dosmode & FILE_ATTRIBUTE_ARCHIVE){
1170 attrs.winAttrs |= GPFS_WINATTR_ARCHIVE;
1172 if (dosmode & FILE_ATTRIBUTE_HIDDEN){
1173 attrs.winAttrs |= GPFS_WINATTR_HIDDEN;
1175 if (dosmode & FILE_ATTRIBUTE_SYSTEM){
1176 attrs.winAttrs |= GPFS_WINATTR_SYSTEM;
1178 if (dosmode & FILE_ATTRIBUTE_READONLY){
1179 attrs.winAttrs |= GPFS_WINATTR_READONLY;
1181 if (dosmode & FILE_ATTRIBUTE_SPARSE) {
1182 attrs.winAttrs |= GPFS_WINATTR_SPARSE_FILE;
1186 ret = set_gpfs_winattrs(discard_const_p(char, path),
1187 GPFS_WINATTR_SET_ATTRS, &attrs);
1188 if ( ret == -1){
1189 if (errno == ENOSYS) {
1190 return SMB_VFS_NEXT_SETXATTR(handle, path, name, value,
1191 size, flags);
1194 DEBUG(1, ("gpfs_set_xattr:Set GPFS attributes failed %d\n",ret));
1195 return -1;
1198 DEBUG(10, ("gpfs_set_xattr:Set attributes: 0x%x\n",attrs.winAttrs));
1199 return 0;
1202 static ssize_t gpfs_get_xattr(struct vfs_handle_struct *handle, const char *path,
1203 const char *name, void *value, size_t size){
1204 char *attrstr = value;
1205 unsigned int dosmode = 0;
1206 struct gpfs_winattr attrs;
1207 int ret = 0;
1208 struct gpfs_config_data *config;
1210 SMB_VFS_HANDLE_GET_DATA(handle, config,
1211 struct gpfs_config_data,
1212 return -1);
1214 if (!config->winattr) {
1215 DEBUG(10, ("gpfs_get_xattr:name is %s -> next\n",name));
1216 return SMB_VFS_NEXT_GETXATTR(handle,path,name,value,size);
1219 DEBUG(10, ("gpfs_get_xattr: %s \n",path));
1221 /* Only handle DOS Attributes */
1222 if (strcmp(name,SAMBA_XATTR_DOS_ATTRIB) != 0){
1223 DEBUG(5, ("gpfs_get_xattr:name is %s\n",name));
1224 return SMB_VFS_NEXT_GETXATTR(handle,path,name,value,size);
1227 ret = get_gpfs_winattrs(discard_const_p(char, path), &attrs);
1228 if ( ret == -1){
1229 if (errno == ENOSYS) {
1230 return SMB_VFS_NEXT_GETXATTR(handle, path, name, value,
1231 size);
1234 DEBUG(1, ("gpfs_get_xattr: Get GPFS attributes failed: "
1235 "%d (%s)\n", ret, strerror(errno)));
1236 return -1;
1239 DEBUG(10, ("gpfs_get_xattr:Got attributes: 0x%x\n",attrs.winAttrs));
1241 /*Just map RD_ONLY, ARCHIVE, SYSTEM, HIDDEN and SPARSE. Ignore the others*/
1242 if (attrs.winAttrs & GPFS_WINATTR_ARCHIVE){
1243 dosmode |= FILE_ATTRIBUTE_ARCHIVE;
1245 if (attrs.winAttrs & GPFS_WINATTR_HIDDEN){
1246 dosmode |= FILE_ATTRIBUTE_HIDDEN;
1248 if (attrs.winAttrs & GPFS_WINATTR_SYSTEM){
1249 dosmode |= FILE_ATTRIBUTE_SYSTEM;
1251 if (attrs.winAttrs & GPFS_WINATTR_READONLY){
1252 dosmode |= FILE_ATTRIBUTE_READONLY;
1254 if (attrs.winAttrs & GPFS_WINATTR_SPARSE_FILE) {
1255 dosmode |= FILE_ATTRIBUTE_SPARSE;
1258 snprintf(attrstr, size, "0x%2.2x",
1259 (unsigned int)(dosmode & SAMBA_ATTRIBUTES_MASK));
1260 DEBUG(10, ("gpfs_get_xattr: returning %s\n",attrstr));
1261 return 4;
1264 static int vfs_gpfs_stat(struct vfs_handle_struct *handle,
1265 struct smb_filename *smb_fname)
1267 struct gpfs_winattr attrs;
1268 char *fname = NULL;
1269 NTSTATUS status;
1270 int ret;
1271 struct gpfs_config_data *config;
1273 SMB_VFS_HANDLE_GET_DATA(handle, config,
1274 struct gpfs_config_data,
1275 return -1);
1277 ret = SMB_VFS_NEXT_STAT(handle, smb_fname);
1278 if (ret == -1) {
1279 return -1;
1282 if (!config->winattr) {
1283 return 0;
1286 status = get_full_smb_filename(talloc_tos(), smb_fname, &fname);
1287 if (!NT_STATUS_IS_OK(status)) {
1288 errno = map_errno_from_nt_status(status);
1289 return -1;
1291 ret = get_gpfs_winattrs(discard_const_p(char, fname), &attrs);
1292 TALLOC_FREE(fname);
1293 if (ret == 0) {
1294 smb_fname->st.st_ex_calculated_birthtime = false;
1295 smb_fname->st.st_ex_btime.tv_sec = attrs.creationTime.tv_sec;
1296 smb_fname->st.st_ex_btime.tv_nsec = attrs.creationTime.tv_nsec;
1297 smb_fname->st.vfs_private = attrs.winAttrs;
1299 return 0;
1302 static int vfs_gpfs_fstat(struct vfs_handle_struct *handle,
1303 struct files_struct *fsp, SMB_STRUCT_STAT *sbuf)
1305 struct gpfs_winattr attrs;
1306 int ret;
1307 struct gpfs_config_data *config;
1309 SMB_VFS_HANDLE_GET_DATA(handle, config,
1310 struct gpfs_config_data,
1311 return -1);
1313 ret = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf);
1314 if (ret == -1) {
1315 return -1;
1317 if ((fsp->fh == NULL) || (fsp->fh->fd == -1)) {
1318 return 0;
1320 if (!config->winattr) {
1321 return 0;
1324 ret = smbd_fget_gpfs_winattrs(fsp->fh->fd, &attrs);
1325 if (ret == 0) {
1326 sbuf->st_ex_calculated_birthtime = false;
1327 sbuf->st_ex_btime.tv_sec = attrs.creationTime.tv_sec;
1328 sbuf->st_ex_btime.tv_nsec = attrs.creationTime.tv_nsec;
1330 return 0;
1333 static int vfs_gpfs_lstat(struct vfs_handle_struct *handle,
1334 struct smb_filename *smb_fname)
1336 struct gpfs_winattr attrs;
1337 char *path = NULL;
1338 NTSTATUS status;
1339 int ret;
1340 struct gpfs_config_data *config;
1342 SMB_VFS_HANDLE_GET_DATA(handle, config,
1343 struct gpfs_config_data,
1344 return -1);
1346 ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname);
1347 if (ret == -1) {
1348 return -1;
1350 if (!config->winattr) {
1351 return 0;
1354 status = get_full_smb_filename(talloc_tos(), smb_fname, &path);
1355 if (!NT_STATUS_IS_OK(status)) {
1356 errno = map_errno_from_nt_status(status);
1357 return -1;
1359 ret = get_gpfs_winattrs(discard_const_p(char, path), &attrs);
1360 TALLOC_FREE(path);
1361 if (ret == 0) {
1362 smb_fname->st.st_ex_calculated_birthtime = false;
1363 smb_fname->st.st_ex_btime.tv_sec = attrs.creationTime.tv_sec;
1364 smb_fname->st.st_ex_btime.tv_nsec = attrs.creationTime.tv_nsec;
1365 smb_fname->st.vfs_private = attrs.winAttrs;
1367 return 0;
1370 static int vfs_gpfs_ntimes(struct vfs_handle_struct *handle,
1371 const struct smb_filename *smb_fname,
1372 struct smb_file_time *ft)
1375 struct gpfs_winattr attrs;
1376 int ret;
1377 char *path = NULL;
1378 NTSTATUS status;
1379 struct gpfs_config_data *config;
1381 SMB_VFS_HANDLE_GET_DATA(handle, config,
1382 struct gpfs_config_data,
1383 return -1);
1385 ret = SMB_VFS_NEXT_NTIMES(handle, smb_fname, ft);
1386 if(ret == -1){
1387 /* don't complain if access was denied */
1388 if (errno != EPERM && errno != EACCES) {
1389 DEBUG(1,("vfs_gpfs_ntimes: SMB_VFS_NEXT_NTIMES failed:"
1390 "%s", strerror(errno)));
1392 return -1;
1395 if(null_timespec(ft->create_time)){
1396 DEBUG(10,("vfs_gpfs_ntimes:Create Time is NULL\n"));
1397 return 0;
1400 if (!config->winattr) {
1401 return 0;
1404 status = get_full_smb_filename(talloc_tos(), smb_fname, &path);
1405 if (!NT_STATUS_IS_OK(status)) {
1406 errno = map_errno_from_nt_status(status);
1407 return -1;
1410 attrs.winAttrs = 0;
1411 attrs.creationTime.tv_sec = ft->create_time.tv_sec;
1412 attrs.creationTime.tv_nsec = ft->create_time.tv_nsec;
1414 ret = set_gpfs_winattrs(discard_const_p(char, path),
1415 GPFS_WINATTR_SET_CREATION_TIME, &attrs);
1416 if(ret == -1 && errno != ENOSYS){
1417 DEBUG(1,("vfs_gpfs_ntimes: set GPFS ntimes failed %d\n",ret));
1418 return -1;
1420 return 0;
1424 static int vfs_gpfs_fallocate(struct vfs_handle_struct *handle,
1425 struct files_struct *fsp, enum vfs_fallocate_mode mode,
1426 off_t offset, off_t len)
1428 int ret;
1429 struct gpfs_config_data *config;
1431 SMB_VFS_HANDLE_GET_DATA(handle, config,
1432 struct gpfs_config_data,
1433 return -1);
1435 if (!config->prealloc) {
1436 /* you should better not run fallocate() on GPFS at all */
1437 errno = ENOTSUP;
1438 return -1;
1441 if (mode == VFS_FALLOCATE_KEEP_SIZE) {
1442 DEBUG(10, ("Unsupported VFS_FALLOCATE_KEEP_SIZE\n"));
1443 errno = ENOTSUP;
1444 return -1;
1447 ret = smbd_gpfs_prealloc(fsp->fh->fd, offset, len);
1449 if (ret == -1 && errno != ENOSYS) {
1450 DEBUG(0, ("GPFS prealloc failed: %s\n", strerror(errno)));
1451 } else if (ret == -1 && errno == ENOSYS) {
1452 DEBUG(10, ("GPFS prealloc not supported.\n"));
1453 } else {
1454 DEBUG(10, ("GPFS prealloc succeeded.\n"));
1457 return ret;
1460 static int vfs_gpfs_ftruncate(vfs_handle_struct *handle, files_struct *fsp,
1461 off_t len)
1463 int result;
1464 struct gpfs_config_data *config;
1466 SMB_VFS_HANDLE_GET_DATA(handle, config,
1467 struct gpfs_config_data,
1468 return -1);
1470 if (!config->ftruncate) {
1471 return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
1474 result = smbd_gpfs_ftruncate(fsp->fh->fd, len);
1475 if ((result == -1) && (errno == ENOSYS)) {
1476 return SMB_VFS_NEXT_FTRUNCATE(handle, fsp, len);
1478 return result;
1481 static bool vfs_gpfs_is_offline(struct vfs_handle_struct *handle,
1482 const struct smb_filename *fname,
1483 SMB_STRUCT_STAT *sbuf)
1485 struct gpfs_winattr attrs;
1486 char *path = NULL;
1487 NTSTATUS status;
1488 struct gpfs_config_data *config;
1490 SMB_VFS_HANDLE_GET_DATA(handle, config,
1491 struct gpfs_config_data,
1492 return -1);
1494 if (!config->winattr) {
1495 return SMB_VFS_NEXT_IS_OFFLINE(handle, fname, sbuf);
1498 status = get_full_smb_filename(talloc_tos(), fname, &path);
1499 if (!NT_STATUS_IS_OK(status)) {
1500 errno = map_errno_from_nt_status(status);
1501 return -1;
1504 if (VALID_STAT(*sbuf)) {
1505 attrs.winAttrs = sbuf->vfs_private;
1506 } else {
1507 int ret;
1508 ret = get_gpfs_winattrs(path, &attrs);
1510 if (ret == -1) {
1511 TALLOC_FREE(path);
1512 return false;
1515 if ((attrs.winAttrs & GPFS_WINATTR_OFFLINE) != 0) {
1516 DEBUG(10, ("%s is offline\n", path));
1517 TALLOC_FREE(path);
1518 return true;
1520 DEBUG(10, ("%s is online\n", path));
1521 TALLOC_FREE(path);
1522 return SMB_VFS_NEXT_IS_OFFLINE(handle, fname, sbuf);
1525 static bool vfs_gpfs_aio_force(struct vfs_handle_struct *handle,
1526 struct files_struct *fsp)
1528 return vfs_gpfs_is_offline(handle, fsp->fsp_name, &fsp->fsp_name->st);
1531 static ssize_t vfs_gpfs_sendfile(vfs_handle_struct *handle, int tofd,
1532 files_struct *fsp, const DATA_BLOB *hdr,
1533 off_t offset, size_t n)
1535 if ((fsp->fsp_name->st.vfs_private & GPFS_WINATTR_OFFLINE) != 0) {
1536 errno = ENOSYS;
1537 return -1;
1539 return SMB_VFS_NEXT_SENDFILE(handle, tofd, fsp, hdr, offset, n);
1542 static int vfs_gpfs_connect(struct vfs_handle_struct *handle,
1543 const char *service, const char *user)
1545 struct gpfs_config_data *config;
1546 int ret;
1548 smbd_gpfs_lib_init();
1550 ret = SMB_VFS_NEXT_CONNECT(handle, service, user);
1552 if (ret < 0) {
1553 return ret;
1556 config = talloc_zero(handle->conn, struct gpfs_config_data);
1557 if (!config) {
1558 SMB_VFS_NEXT_DISCONNECT(handle);
1559 DEBUG(0, ("talloc_zero() failed\n"));
1560 return -1;
1563 config->sharemodes = lp_parm_bool(SNUM(handle->conn), "gpfs",
1564 "sharemodes", true);
1566 config->leases = lp_parm_bool(SNUM(handle->conn), "gpfs",
1567 "leases", true);
1569 config->hsm = lp_parm_bool(SNUM(handle->conn), "gpfs",
1570 "hsm", false);
1572 config->syncio = lp_parm_bool(SNUM(handle->conn), "gpfs",
1573 "syncio", false);
1575 config->winattr = lp_parm_bool(SNUM(handle->conn), "gpfs",
1576 "winattr", false);
1578 config->ftruncate = lp_parm_bool(SNUM(handle->conn), "gpfs",
1579 "ftruncate", true);
1581 config->getrealfilename = lp_parm_bool(SNUM(handle->conn), "gpfs",
1582 "getrealfilename", true);
1584 config->dfreequota = lp_parm_bool(SNUM(handle->conn), "gpfs",
1585 "dfreequota", false);
1587 config->prealloc = lp_parm_bool(SNUM(handle->conn), "gpfs",
1588 "prealloc", true);
1590 config->acl = lp_parm_bool(SNUM(handle->conn), "gpfs", "acl", true);
1592 SMB_VFS_HANDLE_SET_DATA(handle, config,
1593 NULL, struct gpfs_config_data,
1594 return -1);
1596 if (config->leases) {
1598 * GPFS lease code is based on kernel oplock code
1599 * so make sure it is turned on
1601 if (!lp_kernel_oplocks(SNUM(handle->conn))) {
1602 DEBUG(5, ("Enabling kernel oplocks for "
1603 "gpfs:leases to work\n"));
1604 lp_do_parameter(SNUM(handle->conn), "kernel oplocks",
1605 "true");
1609 * as the kernel does not properly support Level II oplocks
1610 * and GPFS leases code is based on kernel infrastructure, we
1611 * need to turn off Level II oplocks if gpfs:leases is enabled
1613 if (lp_level2_oplocks(SNUM(handle->conn))) {
1614 DEBUG(5, ("gpfs:leases are enabled, disabling "
1615 "Level II oplocks\n"));
1616 lp_do_parameter(SNUM(handle->conn), "level2 oplocks",
1617 "false");
1621 return 0;
1624 static int vfs_gpfs_get_quotas(const char *path, uid_t uid, gid_t gid,
1625 int *fset_id,
1626 struct gpfs_quotaInfo *qi_user,
1627 struct gpfs_quotaInfo *qi_group,
1628 struct gpfs_quotaInfo *qi_fset)
1630 int err;
1631 char *dir_path;
1632 bool b;
1635 * We want to always use the directory to get the fileset id,
1636 * because files might have a share mode. We also do not want
1637 * to get the parent directory when there is already a
1638 * directory to avoid stepping in a different fileset. The
1639 * path passed here is currently either "." or a filename, so
1640 * this is ok. The proper solution would be having a way to
1641 * query the fileset id without opening the file.
1643 b = parent_dirname(talloc_tos(), path, &dir_path, NULL);
1644 if (!b) {
1645 errno = ENOMEM;
1646 return -1;
1649 DEBUG(10, ("path %s, directory %s\n", path, dir_path));
1651 err = get_gpfs_fset_id(dir_path, fset_id);
1652 if (err) {
1653 DEBUG(0, ("Get fset id failed path %s, dir %s, errno %d.\n",
1654 path, dir_path, errno));
1655 return err;
1658 err = get_gpfs_quota(path, GPFS_USRQUOTA, uid, qi_user);
1659 if (err) {
1660 return err;
1663 err = get_gpfs_quota(path, GPFS_GRPQUOTA, gid, qi_group);
1664 if (err) {
1665 return err;
1668 err = get_gpfs_quota(path, GPFS_FILESETQUOTA, *fset_id, qi_fset);
1669 if (err) {
1670 return err;
1673 return 0;
1676 static void vfs_gpfs_disk_free_quota(struct gpfs_quotaInfo qi, time_t cur_time,
1677 uint64_t *dfree, uint64_t *dsize)
1679 uint64_t usage, limit;
1682 * The quota reporting is done in units of 1024 byte blocks, but
1683 * sys_fsusage uses units of 512 byte blocks, adjust the block number
1684 * accordingly. Also filter possibly negative usage counts from gpfs.
1686 usage = qi.blockUsage < 0 ? 0 : (uint64_t)qi.blockUsage * 2;
1687 limit = (uint64_t)qi.blockHardLimit * 2;
1690 * When the grace time for the exceeded soft block quota has been
1691 * exceeded, the soft block quota becomes an additional hard limit.
1693 if (qi.blockSoftLimit &&
1694 qi.blockGraceTime && cur_time > qi.blockGraceTime) {
1695 /* report disk as full */
1696 *dfree = 0;
1697 *dsize = MIN(*dsize, usage);
1700 if (!qi.blockHardLimit)
1701 return;
1703 if (usage >= limit) {
1704 /* report disk as full */
1705 *dfree = 0;
1706 *dsize = MIN(*dsize, usage);
1708 } else {
1709 /* limit has not been reached, determine "free space" */
1710 *dfree = MIN(*dfree, limit - usage);
1711 *dsize = MIN(*dsize, limit);
1715 static uint64_t vfs_gpfs_disk_free(vfs_handle_struct *handle, const char *path,
1716 bool small_query, uint64_t *bsize,
1717 uint64_t *dfree, uint64_t *dsize)
1719 struct security_unix_token *utok;
1720 struct gpfs_quotaInfo qi_user, qi_group, qi_fset;
1721 struct gpfs_config_data *config;
1722 int err, fset_id;
1723 time_t cur_time;
1725 SMB_VFS_HANDLE_GET_DATA(handle, config, struct gpfs_config_data,
1726 return (uint64_t)-1);
1727 if (!config->dfreequota) {
1728 return SMB_VFS_NEXT_DISK_FREE(handle, path, small_query,
1729 bsize, dfree, dsize);
1732 err = sys_fsusage(path, dfree, dsize);
1733 if (err) {
1734 DEBUG (0, ("Could not get fs usage, errno %d\n", errno));
1735 return SMB_VFS_NEXT_DISK_FREE(handle, path, small_query,
1736 bsize, dfree, dsize);
1739 /* sys_fsusage returns units of 512 bytes */
1740 *bsize = 512;
1742 DEBUG(10, ("fs dfree %llu, dsize %llu\n",
1743 (unsigned long long)*dfree, (unsigned long long)*dsize));
1745 utok = handle->conn->session_info->unix_token;
1746 err = vfs_gpfs_get_quotas(path, utok->uid, utok->gid, &fset_id,
1747 &qi_user, &qi_group, &qi_fset);
1748 if (err) {
1749 return SMB_VFS_NEXT_DISK_FREE(handle, path, small_query,
1750 bsize, dfree, dsize);
1753 cur_time = time(NULL);
1755 /* Adjust free space and size according to quota limits. */
1756 vfs_gpfs_disk_free_quota(qi_user, cur_time, dfree, dsize);
1757 vfs_gpfs_disk_free_quota(qi_group, cur_time, dfree, dsize);
1759 /* Id 0 indicates the default quota, not an actual quota */
1760 if (fset_id != 0) {
1761 vfs_gpfs_disk_free_quota(qi_fset, cur_time, dfree, dsize);
1764 disk_norm(small_query, bsize, dfree, dsize);
1765 return *dfree;
1768 static uint32_t vfs_gpfs_capabilities(struct vfs_handle_struct *handle,
1769 enum timestamp_set_resolution *p_ts_res)
1771 struct gpfs_config_data *config;
1772 uint32_t next;
1774 next = SMB_VFS_NEXT_FS_CAPABILITIES(handle, p_ts_res);
1776 SMB_VFS_HANDLE_GET_DATA(handle, config,
1777 struct gpfs_config_data,
1778 return next);
1780 if (config->hsm) {
1781 next |= FILE_SUPPORTS_REMOTE_STORAGE;
1783 return next;
1786 static int vfs_gpfs_open(struct vfs_handle_struct *handle,
1787 struct smb_filename *smb_fname, files_struct *fsp,
1788 int flags, mode_t mode)
1790 struct gpfs_config_data *config;
1792 SMB_VFS_HANDLE_GET_DATA(handle, config,
1793 struct gpfs_config_data,
1794 return -1);
1796 if (config->syncio) {
1797 flags |= O_SYNC;
1799 return SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
1802 static ssize_t vfs_gpfs_pread(vfs_handle_struct *handle, files_struct *fsp,
1803 void *data, size_t n, off_t offset)
1805 ssize_t ret;
1807 ret = SMB_VFS_NEXT_PREAD(handle, fsp, data, n, offset);
1809 DEBUG(10, ("vfs_private = %x\n",
1810 (unsigned int)fsp->fsp_name->st.vfs_private));
1812 if ((ret != -1) &&
1813 ((fsp->fsp_name->st.vfs_private & GPFS_WINATTR_OFFLINE) != 0)) {
1814 fsp->fsp_name->st.vfs_private &= ~GPFS_WINATTR_OFFLINE;
1815 notify_fname(handle->conn, NOTIFY_ACTION_MODIFIED,
1816 FILE_NOTIFY_CHANGE_ATTRIBUTES,
1817 fsp->fsp_name->base_name);
1820 return ret;
1823 struct vfs_gpfs_pread_state {
1824 struct files_struct *fsp;
1825 ssize_t ret;
1826 int err;
1829 static void vfs_gpfs_pread_done(struct tevent_req *subreq);
1831 static struct tevent_req *vfs_gpfs_pread_send(struct vfs_handle_struct *handle,
1832 TALLOC_CTX *mem_ctx,
1833 struct tevent_context *ev,
1834 struct files_struct *fsp,
1835 void *data, size_t n,
1836 off_t offset)
1838 struct tevent_req *req, *subreq;
1839 struct vfs_gpfs_pread_state *state;
1841 req = tevent_req_create(mem_ctx, &state, struct vfs_gpfs_pread_state);
1842 if (req == NULL) {
1843 return NULL;
1845 state->fsp = fsp;
1846 subreq = SMB_VFS_NEXT_PREAD_SEND(state, ev, handle, fsp, data,
1847 n, offset);
1848 if (tevent_req_nomem(subreq, req)) {
1849 return tevent_req_post(req, ev);
1851 tevent_req_set_callback(subreq, vfs_gpfs_pread_done, req);
1852 return req;
1855 static void vfs_gpfs_pread_done(struct tevent_req *subreq)
1857 struct tevent_req *req = tevent_req_callback_data(
1858 subreq, struct tevent_req);
1859 struct vfs_gpfs_pread_state *state = tevent_req_data(
1860 req, struct vfs_gpfs_pread_state);
1862 state->ret = SMB_VFS_PREAD_RECV(subreq, &state->err);
1863 TALLOC_FREE(subreq);
1864 tevent_req_done(req);
1867 static ssize_t vfs_gpfs_pread_recv(struct tevent_req *req, int *err)
1869 struct vfs_gpfs_pread_state *state = tevent_req_data(
1870 req, struct vfs_gpfs_pread_state);
1871 struct files_struct *fsp = state->fsp;
1873 if (tevent_req_is_unix_error(req, err)) {
1874 return -1;
1876 *err = state->err;
1878 DEBUG(10, ("vfs_private = %x\n",
1879 (unsigned int)fsp->fsp_name->st.vfs_private));
1881 if ((state->ret != -1) &&
1882 ((fsp->fsp_name->st.vfs_private & GPFS_WINATTR_OFFLINE) != 0)) {
1883 fsp->fsp_name->st.vfs_private &= ~GPFS_WINATTR_OFFLINE;
1884 DEBUG(10, ("sending notify\n"));
1885 notify_fname(fsp->conn, NOTIFY_ACTION_MODIFIED,
1886 FILE_NOTIFY_CHANGE_ATTRIBUTES,
1887 fsp->fsp_name->base_name);
1890 return state->ret;
1893 static ssize_t vfs_gpfs_pwrite(vfs_handle_struct *handle, files_struct *fsp,
1894 const void *data, size_t n, off_t offset)
1896 ssize_t ret;
1898 ret = SMB_VFS_NEXT_PWRITE(handle, fsp, data, n, offset);
1900 DEBUG(10, ("vfs_private = %x\n",
1901 (unsigned int)fsp->fsp_name->st.vfs_private));
1903 if ((ret != -1) &&
1904 ((fsp->fsp_name->st.vfs_private & GPFS_WINATTR_OFFLINE) != 0)) {
1905 fsp->fsp_name->st.vfs_private &= ~GPFS_WINATTR_OFFLINE;
1906 notify_fname(handle->conn, NOTIFY_ACTION_MODIFIED,
1907 FILE_NOTIFY_CHANGE_ATTRIBUTES,
1908 fsp->fsp_name->base_name);
1911 return ret;
1914 struct vfs_gpfs_pwrite_state {
1915 struct files_struct *fsp;
1916 ssize_t ret;
1917 int err;
1920 static void vfs_gpfs_pwrite_done(struct tevent_req *subreq);
1922 static struct tevent_req *vfs_gpfs_pwrite_send(
1923 struct vfs_handle_struct *handle,
1924 TALLOC_CTX *mem_ctx,
1925 struct tevent_context *ev,
1926 struct files_struct *fsp,
1927 const void *data, size_t n,
1928 off_t offset)
1930 struct tevent_req *req, *subreq;
1931 struct vfs_gpfs_pwrite_state *state;
1933 req = tevent_req_create(mem_ctx, &state, struct vfs_gpfs_pwrite_state);
1934 if (req == NULL) {
1935 return NULL;
1937 state->fsp = fsp;
1938 subreq = SMB_VFS_NEXT_PWRITE_SEND(state, ev, handle, fsp, data,
1939 n, offset);
1940 if (tevent_req_nomem(subreq, req)) {
1941 return tevent_req_post(req, ev);
1943 tevent_req_set_callback(subreq, vfs_gpfs_pwrite_done, req);
1944 return req;
1947 static void vfs_gpfs_pwrite_done(struct tevent_req *subreq)
1949 struct tevent_req *req = tevent_req_callback_data(
1950 subreq, struct tevent_req);
1951 struct vfs_gpfs_pwrite_state *state = tevent_req_data(
1952 req, struct vfs_gpfs_pwrite_state);
1954 state->ret = SMB_VFS_PWRITE_RECV(subreq, &state->err);
1955 TALLOC_FREE(subreq);
1956 tevent_req_done(req);
1959 static ssize_t vfs_gpfs_pwrite_recv(struct tevent_req *req, int *err)
1961 struct vfs_gpfs_pwrite_state *state = tevent_req_data(
1962 req, struct vfs_gpfs_pwrite_state);
1963 struct files_struct *fsp = state->fsp;
1965 if (tevent_req_is_unix_error(req, err)) {
1966 return -1;
1968 *err = state->err;
1970 DEBUG(10, ("vfs_private = %x\n",
1971 (unsigned int)fsp->fsp_name->st.vfs_private));
1973 if ((state->ret != -1) &&
1974 ((fsp->fsp_name->st.vfs_private & GPFS_WINATTR_OFFLINE) != 0)) {
1975 fsp->fsp_name->st.vfs_private &= ~GPFS_WINATTR_OFFLINE;
1976 DEBUG(10, ("sending notify\n"));
1977 notify_fname(fsp->conn, NOTIFY_ACTION_MODIFIED,
1978 FILE_NOTIFY_CHANGE_ATTRIBUTES,
1979 fsp->fsp_name->base_name);
1982 return state->ret;
1986 static struct vfs_fn_pointers vfs_gpfs_fns = {
1987 .connect_fn = vfs_gpfs_connect,
1988 .disk_free_fn = vfs_gpfs_disk_free,
1989 .fs_capabilities_fn = vfs_gpfs_capabilities,
1990 .kernel_flock_fn = vfs_gpfs_kernel_flock,
1991 .linux_setlease_fn = vfs_gpfs_setlease,
1992 .get_real_filename_fn = vfs_gpfs_get_real_filename,
1993 .fget_nt_acl_fn = gpfsacl_fget_nt_acl,
1994 .get_nt_acl_fn = gpfsacl_get_nt_acl,
1995 .fset_nt_acl_fn = gpfsacl_fset_nt_acl,
1996 .sys_acl_get_file_fn = gpfsacl_sys_acl_get_file,
1997 .sys_acl_get_fd_fn = gpfsacl_sys_acl_get_fd,
1998 .sys_acl_blob_get_file_fn = gpfsacl_sys_acl_blob_get_file,
1999 .sys_acl_blob_get_fd_fn = gpfsacl_sys_acl_blob_get_fd,
2000 .sys_acl_set_file_fn = gpfsacl_sys_acl_set_file,
2001 .sys_acl_set_fd_fn = gpfsacl_sys_acl_set_fd,
2002 .sys_acl_delete_def_file_fn = gpfsacl_sys_acl_delete_def_file,
2003 .chmod_fn = vfs_gpfs_chmod,
2004 .fchmod_fn = vfs_gpfs_fchmod,
2005 .close_fn = vfs_gpfs_close,
2006 .setxattr_fn = gpfs_set_xattr,
2007 .getxattr_fn = gpfs_get_xattr,
2008 .stat_fn = vfs_gpfs_stat,
2009 .fstat_fn = vfs_gpfs_fstat,
2010 .lstat_fn = vfs_gpfs_lstat,
2011 .ntimes_fn = vfs_gpfs_ntimes,
2012 .is_offline_fn = vfs_gpfs_is_offline,
2013 .aio_force_fn = vfs_gpfs_aio_force,
2014 .sendfile_fn = vfs_gpfs_sendfile,
2015 .fallocate_fn = vfs_gpfs_fallocate,
2016 .open_fn = vfs_gpfs_open,
2017 .pread_fn = vfs_gpfs_pread,
2018 .pread_send_fn = vfs_gpfs_pread_send,
2019 .pread_recv_fn = vfs_gpfs_pread_recv,
2020 .pwrite_fn = vfs_gpfs_pwrite,
2021 .pwrite_send_fn = vfs_gpfs_pwrite_send,
2022 .pwrite_recv_fn = vfs_gpfs_pwrite_recv,
2023 .ftruncate_fn = vfs_gpfs_ftruncate
2026 NTSTATUS vfs_gpfs_init(void);
2027 NTSTATUS vfs_gpfs_init(void)
2029 init_gpfs();
2031 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "gpfs",
2032 &vfs_gpfs_fns);