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/>.
27 #define DBGC_CLASS DBGC_VFS
30 #include "nfs4_acls.h"
33 static int vfs_gpfs_kernel_flock(vfs_handle_struct *handle, files_struct *fsp,
37 START_PROFILE(syscall_kernel_flock);
39 kernel_flock(fsp->fh->fd, share_mode);
41 if (!set_gpfs_sharemode(fsp, fsp->access_mask, fsp->share_access)) {
47 END_PROFILE(syscall_kernel_flock);
52 static int vfs_gpfs_setlease(vfs_handle_struct *handle, files_struct *fsp,
57 START_PROFILE(syscall_linux_setlease);
59 if ( linux_set_lease_sighandler(fsp->fh->fd) == -1)
62 ret = set_gpfs_lease(fsp->fh->fd,leasetype);
65 /* This must have come from GPFS not being available */
66 /* or some other error, hence call the default */
67 ret = linux_setlease(fsp->fh->fd, leasetype);
70 END_PROFILE(syscall_linux_setlease);
75 static int vfs_gpfs_get_real_filename(struct vfs_handle_struct *handle,
83 char real_pathname[PATH_MAX+1];
86 full_path = talloc_asprintf(talloc_tos(), "%s/%s", path, name);
87 if (full_path == NULL) {
92 buflen = sizeof(real_pathname) - 1;
94 result = smbd_gpfs_get_realfilename_path(full_path, real_pathname,
97 TALLOC_FREE(full_path);
100 DEBUG(10, ("smbd_gpfs_get_realfilename_path returned %s\n",
106 * GPFS does not necessarily null-terminate the returned path
107 * but instead returns the buffer length in buflen.
110 if (buflen < sizeof(real_pathname)) {
111 real_pathname[buflen] = '\0';
113 real_pathname[sizeof(real_pathname)-1] = '\0';
116 DEBUG(10, ("smbd_gpfs_get_realfilename_path: %s/%s -> %s\n",
117 path, name, real_pathname));
119 name = strrchr_m(real_pathname, '/');
125 *found_name = talloc_strdup(mem_ctx, name+1);
126 if (*found_name == NULL) {
134 static void gpfs_dumpacl(int level, struct gpfs_acl *gacl)
139 DEBUG(0, ("gpfs acl is NULL\n"));
143 DEBUG(level, ("gpfs acl: nace: %d, type:%d, version:%d, level:%d, len:%d\n",
144 gacl->acl_nace, gacl->acl_type, gacl->acl_version, gacl->acl_level, gacl->acl_len));
145 for(i=0; i<gacl->acl_nace; i++)
147 struct gpfs_ace_v4 *gace = gacl->ace_v4 + i;
148 DEBUG(level, ("\tace[%d]: type:%d, flags:0x%x, mask:0x%x, iflags:0x%x, who:%u\n",
149 i, gace->aceType, gace->aceFlags, gace->aceMask,
150 gace->aceIFlags, gace->aceWho));
154 static struct gpfs_acl *gpfs_getacl_alloc(const char *fname, gpfs_aclType_t type)
156 struct gpfs_acl *acl;
159 TALLOC_CTX *mem_ctx = talloc_tos();
161 acl = (struct gpfs_acl *)TALLOC_SIZE(mem_ctx, len);
169 acl->acl_version = 0;
170 acl->acl_type = type;
172 ret = smbd_gpfs_getacl((char *)fname, GPFS_GETACL_STRUCT | GPFS_ACL_SAMBA, acl);
173 if ((ret != 0) && (errno == ENOSPC)) {
174 struct gpfs_acl *new_acl = (struct gpfs_acl *)TALLOC_SIZE(
175 mem_ctx, acl->acl_len + sizeof(struct gpfs_acl));
176 if (new_acl == NULL) {
181 new_acl->acl_len = acl->acl_len;
182 new_acl->acl_level = acl->acl_level;
183 new_acl->acl_version = acl->acl_version;
184 new_acl->acl_type = acl->acl_type;
187 ret = smbd_gpfs_getacl((char *)fname, GPFS_GETACL_STRUCT | GPFS_ACL_SAMBA, acl);
191 DEBUG(8, ("smbd_gpfs_getacl failed with %s\n",strerror(errno)));
198 /* Tries to get nfs4 acls and returns SMB ACL allocated.
199 * On failure returns 1 if it got non-NFSv4 ACL to prompt
200 * retry with POSIX ACL checks.
201 * On failure returns -1 if there is system (GPFS) error, check errno.
202 * Returns 0 on success
204 static int gpfs_get_nfs4_acl(const char *fname, SMB4ACL_T **ppacl)
207 struct gpfs_acl *gacl = NULL;
208 DEBUG(10, ("gpfs_get_nfs4_acl invoked for %s\n", fname));
210 /* First get the real acl length */
211 gacl = gpfs_getacl_alloc(fname, 0);
213 DEBUG(9, ("gpfs_getacl failed for %s with %s\n",
214 fname, strerror(errno)));
218 if (gacl->acl_type != GPFS_ACL_TYPE_NFS4) {
219 DEBUG(10, ("Got non-nfsv4 acl\n"));
220 /* Retry with POSIX ACLs check */
224 *ppacl = smb_create_smb4acl();
226 DEBUG(10, ("len: %d, level: %d, version: %d, nace: %d\n",
227 gacl->acl_len, gacl->acl_level, gacl->acl_version,
230 for (i=0; i<gacl->acl_nace; i++) {
231 struct gpfs_ace_v4 *gace = &gacl->ace_v4[i];
232 SMB_ACE4PROP_T smbace;
233 DEBUG(10, ("type: %d, iflags: %x, flags: %x, mask: %x, "
234 "who: %d\n", gace->aceType, gace->aceIFlags,
235 gace->aceFlags, gace->aceMask, gace->aceWho));
238 if (gace->aceIFlags & ACE4_IFLAG_SPECIAL_ID) {
239 smbace.flags |= SMB_ACE4_ID_SPECIAL;
240 switch (gace->aceWho) {
241 case ACE4_SPECIAL_OWNER:
242 smbace.who.special_id = SMB_ACE4_WHO_OWNER;
244 case ACE4_SPECIAL_GROUP:
245 smbace.who.special_id = SMB_ACE4_WHO_GROUP;
247 case ACE4_SPECIAL_EVERYONE:
248 smbace.who.special_id = SMB_ACE4_WHO_EVERYONE;
251 DEBUG(8, ("invalid special gpfs id %d "
252 "ignored\n", gace->aceWho));
253 continue; /* don't add it */
256 if (gace->aceFlags & ACE4_FLAG_GROUP_ID)
257 smbace.who.gid = gace->aceWho;
259 smbace.who.uid = gace->aceWho;
262 /* remove redundent deny entries */
263 if (i > 0 && gace->aceType == SMB_ACE4_ACCESS_DENIED_ACE_TYPE) {
264 struct gpfs_ace_v4 *prev = &gacl->ace_v4[i-1];
265 if (prev->aceType == SMB_ACE4_ACCESS_ALLOWED_ACE_TYPE &&
266 prev->aceFlags == gace->aceFlags &&
267 prev->aceIFlags == gace->aceIFlags &&
268 (gace->aceMask & prev->aceMask) == 0 &&
269 gace->aceWho == prev->aceWho) {
270 /* its redundent - skip it */
275 smbace.aceType = gace->aceType;
276 smbace.aceFlags = gace->aceFlags;
277 smbace.aceMask = gace->aceMask;
278 smb_add_ace4(*ppacl, &smbace);
284 static NTSTATUS gpfsacl_fget_nt_acl(vfs_handle_struct *handle,
285 files_struct *fsp, uint32 security_info,
288 SMB4ACL_T *pacl = NULL;
292 result = gpfs_get_nfs4_acl(fsp->fsp_name, &pacl);
295 return smb_fget_nt_acl_nfs4(fsp, security_info, ppdesc, pacl);
298 DEBUG(10, ("retrying with posix acl...\n"));
299 return posix_fget_nt_acl(fsp, security_info, ppdesc);
302 /* GPFS ACL was not read, something wrong happened, error code is set in errno */
303 return map_nt_error_from_unix(errno);
306 static NTSTATUS gpfsacl_get_nt_acl(vfs_handle_struct *handle,
308 uint32 security_info, SEC_DESC **ppdesc)
310 SMB4ACL_T *pacl = NULL;
314 result = gpfs_get_nfs4_acl(name, &pacl);
317 return smb_get_nt_acl_nfs4(handle->conn, name, security_info, ppdesc, pacl);
320 DEBUG(10, ("retrying with posix acl...\n"));
321 return posix_get_nt_acl(handle->conn, name, security_info, ppdesc);
324 /* GPFS ACL was not read, something wrong happened, error code is set in errno */
325 return map_nt_error_from_unix(errno);
328 static bool gpfsacl_process_smbacl(files_struct *fsp, SMB4ACL_T *smbacl)
331 gpfs_aclLen_t gacl_len;
333 struct gpfs_acl *gacl;
334 TALLOC_CTX *mem_ctx = talloc_tos();
336 gacl_len = sizeof(struct gpfs_acl) +
337 (smb_get_naces(smbacl)-1)*sizeof(gpfs_ace_v4_t);
339 gacl = TALLOC_SIZE(mem_ctx, gacl_len);
341 DEBUG(0, ("talloc failed\n"));
346 gacl->acl_len = gacl_len;
348 gacl->acl_version = GPFS_ACL_VERSION_NFS4;
349 gacl->acl_type = GPFS_ACL_TYPE_NFS4;
350 gacl->acl_nace = 0; /* change later... */
352 for (smbace=smb_first_ace4(smbacl); smbace!=NULL; smbace = smb_next_ace4(smbace)) {
353 struct gpfs_ace_v4 *gace = &gacl->ace_v4[gacl->acl_nace];
354 SMB_ACE4PROP_T *aceprop = smb_get_ace4(smbace);
356 gace->aceType = aceprop->aceType;
357 gace->aceFlags = aceprop->aceFlags;
358 gace->aceMask = aceprop->aceMask;
361 * GPFS can't distinguish between WRITE and APPEND on
362 * files, so one being set without the other is an
363 * error. Sorry for the many ()'s :-)
366 if (!fsp->is_directory
368 ((((gace->aceMask & ACE4_MASK_WRITE) == 0)
369 && ((gace->aceMask & ACE4_MASK_APPEND) != 0))
371 (((gace->aceMask & ACE4_MASK_WRITE) != 0)
372 && ((gace->aceMask & ACE4_MASK_APPEND) == 0)))
374 lp_parm_bool(fsp->conn->params->service, "gpfs",
375 "merge_writeappend", True)) {
376 DEBUG(2, ("vfs_gpfs.c: file [%s]: ACE contains "
377 "WRITE^APPEND, setting WRITE|APPEND\n",
379 gace->aceMask |= ACE4_MASK_WRITE|ACE4_MASK_APPEND;
382 gace->aceIFlags = (aceprop->flags&SMB_ACE4_ID_SPECIAL) ? ACE4_IFLAG_SPECIAL_ID : 0;
384 if (aceprop->flags&SMB_ACE4_ID_SPECIAL)
386 switch(aceprop->who.special_id)
388 case SMB_ACE4_WHO_EVERYONE:
389 gace->aceWho = ACE4_SPECIAL_EVERYONE;
391 case SMB_ACE4_WHO_OWNER:
392 gace->aceWho = ACE4_SPECIAL_OWNER;
394 case SMB_ACE4_WHO_GROUP:
395 gace->aceWho = ACE4_SPECIAL_GROUP;
398 DEBUG(8, ("unsupported special_id %d\n", aceprop->who.special_id));
399 continue; /* don't add it !!! */
402 /* just only for the type safety... */
403 if (aceprop->aceFlags&SMB_ACE4_IDENTIFIER_GROUP)
404 gace->aceWho = aceprop->who.gid;
406 gace->aceWho = aceprop->who.uid;
412 ret = smbd_gpfs_putacl(fsp->fsp_name, GPFS_PUTACL_STRUCT | GPFS_ACL_SAMBA, gacl);
414 DEBUG(8, ("gpfs_putacl failed with %s\n", strerror(errno)));
415 gpfs_dumpacl(8, gacl);
419 DEBUG(10, ("gpfs_putacl succeeded\n"));
423 static NTSTATUS gpfsacl_set_nt_acl_internal(files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd)
425 struct gpfs_acl *acl;
426 NTSTATUS result = NT_STATUS_ACCESS_DENIED;
428 acl = gpfs_getacl_alloc(fsp->fsp_name, 0);
432 if (acl->acl_version&GPFS_ACL_VERSION_NFS4)
434 result = smb_set_nt_acl_nfs4(
435 fsp, security_info_sent, psd,
436 gpfsacl_process_smbacl);
437 } else { /* assume POSIX ACL - by default... */
438 result = set_nt_acl(fsp, security_info_sent, psd);
444 static NTSTATUS gpfsacl_fset_nt_acl(vfs_handle_struct *handle, files_struct *fsp, uint32 security_info_sent, SEC_DESC *psd)
446 return gpfsacl_set_nt_acl_internal(fsp, security_info_sent, psd);
449 static SMB_ACL_T gpfs2smb_acl(const struct gpfs_acl *pacl)
454 result = sys_acl_init(pacl->acl_nace);
455 if (result == NULL) {
460 result->count = pacl->acl_nace;
462 for (i=0; i<pacl->acl_nace; i++) {
463 struct smb_acl_entry *ace = &result->acl[i];
464 const struct gpfs_ace_v1 *g_ace = &pacl->ace_v1[i];
466 DEBUG(10, ("Converting type %d id %lu perm %x\n",
467 (int)g_ace->ace_type, (unsigned long)g_ace->ace_who,
468 (int)g_ace->ace_perm));
470 switch (g_ace->ace_type) {
472 ace->a_type = SMB_ACL_USER;
473 ace->uid = (uid_t)g_ace->ace_who;
475 case GPFS_ACL_USER_OBJ:
476 ace->a_type = SMB_ACL_USER_OBJ;
479 ace->a_type = SMB_ACL_GROUP;
480 ace->gid = (gid_t)g_ace->ace_who;
482 case GPFS_ACL_GROUP_OBJ:
483 ace->a_type = SMB_ACL_GROUP_OBJ;
486 ace->a_type = SMB_ACL_OTHER;
489 ace->a_type = SMB_ACL_MASK;
492 DEBUG(10, ("Got invalid ace_type: %d\n",
500 ace->a_perm |= (g_ace->ace_perm & ACL_PERM_READ) ?
502 ace->a_perm |= (g_ace->ace_perm & ACL_PERM_WRITE) ?
504 ace->a_perm |= (g_ace->ace_perm & ACL_PERM_EXECUTE) ?
507 DEBUGADD(10, ("Converted to %d perm %x\n",
508 ace->a_type, ace->a_perm));
514 static SMB_ACL_T gpfsacl_get_posix_acl(const char *path, gpfs_aclType_t type)
516 struct gpfs_acl *pacl;
517 SMB_ACL_T result = NULL;
519 pacl = gpfs_getacl_alloc(path, type);
522 DEBUG(10, ("gpfs_getacl failed for %s with %s\n",
523 path, strerror(errno)));
530 if (pacl->acl_version != GPFS_ACL_VERSION_POSIX) {
531 DEBUG(10, ("Got acl version %d, expected %d\n",
532 pacl->acl_version, GPFS_ACL_VERSION_POSIX));
537 DEBUG(10, ("len: %d, level: %d, version: %d, nace: %d\n",
538 pacl->acl_len, pacl->acl_level, pacl->acl_version,
541 result = gpfs2smb_acl(pacl);
542 if (result == NULL) {
554 SMB_ACL_T gpfsacl_sys_acl_get_file(vfs_handle_struct *handle,
558 gpfs_aclType_t gpfs_type;
561 case SMB_ACL_TYPE_ACCESS:
562 gpfs_type = GPFS_ACL_TYPE_ACCESS;
564 case SMB_ACL_TYPE_DEFAULT:
565 gpfs_type = GPFS_ACL_TYPE_DEFAULT;
568 DEBUG(0, ("Got invalid type: %d\n", type));
569 smb_panic("exiting");
572 return gpfsacl_get_posix_acl(path_p, gpfs_type);
575 SMB_ACL_T gpfsacl_sys_acl_get_fd(vfs_handle_struct *handle,
578 return gpfsacl_get_posix_acl(fsp->fsp_name, GPFS_ACL_TYPE_ACCESS);
581 static struct gpfs_acl *smb2gpfs_acl(const SMB_ACL_T pacl,
585 struct gpfs_acl *result;
589 gpfs_ace_v1_t ace_v1[1]; /* when GPFS_ACL_VERSION_POSIX */
590 gpfs_ace_v4_t ace_v4[1]; /* when GPFS_ACL_VERSION_NFS4 */
593 DEBUG(10, ("smb2gpfs_acl: Got ACL with %d entries\n", pacl->count));
595 len = sizeof(struct gpfs_acl) - sizeof(union gpfs_ace_union) +
596 (pacl->count)*sizeof(gpfs_ace_v1_t);
598 result = SMB_MALLOC(len);
599 if (result == NULL) {
604 result->acl_len = len;
605 result->acl_level = 0;
606 result->acl_version = GPFS_ACL_VERSION_POSIX;
607 result->acl_type = (type == SMB_ACL_TYPE_DEFAULT) ?
608 GPFS_ACL_TYPE_DEFAULT : GPFS_ACL_TYPE_ACCESS;
609 result->acl_nace = pacl->count;
611 for (i=0; i<pacl->count; i++) {
612 const struct smb_acl_entry *ace = &pacl->acl[i];
613 struct gpfs_ace_v1 *g_ace = &result->ace_v1[i];
615 DEBUG(10, ("Converting type %d perm %x\n",
616 (int)ace->a_type, (int)ace->a_perm));
620 switch(ace->a_type) {
622 g_ace->ace_type = GPFS_ACL_USER;
623 g_ace->ace_who = (gpfs_uid_t)ace->uid;
625 case SMB_ACL_USER_OBJ:
626 g_ace->ace_type = GPFS_ACL_USER_OBJ;
627 g_ace->ace_perm |= ACL_PERM_CONTROL;
631 g_ace->ace_type = GPFS_ACL_GROUP;
632 g_ace->ace_who = (gpfs_uid_t)ace->gid;
634 case SMB_ACL_GROUP_OBJ:
635 g_ace->ace_type = GPFS_ACL_GROUP_OBJ;
639 g_ace->ace_type = GPFS_ACL_MASK;
640 g_ace->ace_perm = 0x8f;
644 g_ace->ace_type = GPFS_ACL_OTHER;
648 DEBUG(10, ("Got invalid ace_type: %d\n", ace->a_type));
654 g_ace->ace_perm |= (ace->a_perm & SMB_ACL_READ) ?
656 g_ace->ace_perm |= (ace->a_perm & SMB_ACL_WRITE) ?
658 g_ace->ace_perm |= (ace->a_perm & SMB_ACL_EXECUTE) ?
659 ACL_PERM_EXECUTE : 0;
661 DEBUGADD(10, ("Converted to %d id %d perm %x\n",
662 g_ace->ace_type, g_ace->ace_who, g_ace->ace_perm));
668 int gpfsacl_sys_acl_set_file(vfs_handle_struct *handle,
673 struct gpfs_acl *gpfs_acl;
676 gpfs_acl = smb2gpfs_acl(theacl, type);
677 if (gpfs_acl == NULL) {
681 result = smbd_gpfs_putacl((char *)name, GPFS_PUTACL_STRUCT | GPFS_ACL_SAMBA, gpfs_acl);
687 int gpfsacl_sys_acl_set_fd(vfs_handle_struct *handle,
691 return gpfsacl_sys_acl_set_file(handle, fsp->fsp_name, SMB_ACL_TYPE_ACCESS, theacl);
694 int gpfsacl_sys_acl_delete_def_file(vfs_handle_struct *handle,
702 * Assumed: mode bits are shiftable and standard
703 * Output: the new aceMask field for an smb nfs4 ace
705 static uint32 gpfsacl_mask_filter(uint32 aceType, uint32 aceMask, uint32 rwx)
707 const uint32 posix_nfs4map[3] = {
708 SMB_ACE4_EXECUTE, /* execute */
709 SMB_ACE4_WRITE_DATA | SMB_ACE4_APPEND_DATA, /* write; GPFS specific */
710 SMB_ACE4_READ_DATA /* read */
713 uint32_t posix_mask = 0x01;
718 nfs4_bits = posix_nfs4map[i];
719 posix_bit = rwx & posix_mask;
721 if (aceType==SMB_ACE4_ACCESS_ALLOWED_ACE_TYPE) {
723 aceMask |= nfs4_bits;
725 aceMask &= ~nfs4_bits;
727 /* add deny bits when suitable */
729 aceMask |= nfs4_bits;
731 aceMask &= ~nfs4_bits;
732 } /* other ace types are unexpected */
740 static int gpfsacl_emu_chmod(const char *path, mode_t mode)
742 SMB4ACL_T *pacl = NULL;
744 bool haveAllowEntry[SMB_ACE4_WHO_EVERYONE + 1] = {False, False, False, False};
746 files_struct fake_fsp; /* TODO: rationalize parametrization */
749 DEBUG(10, ("gpfsacl_emu_chmod invoked for %s mode %o\n", path, mode));
751 result = gpfs_get_nfs4_acl(path, &pacl);
755 if (mode & ~(S_IRWXU | S_IRWXG | S_IRWXO)) {
756 DEBUG(2, ("WARNING: cutting extra mode bits %o on %s\n", mode, path));
759 for (smbace=smb_first_ace4(pacl); smbace!=NULL; smbace = smb_next_ace4(smbace)) {
760 SMB_ACE4PROP_T *ace = smb_get_ace4(smbace);
761 uint32_t specid = ace->who.special_id;
763 if (ace->flags&SMB_ACE4_ID_SPECIAL &&
764 ace->aceType<=SMB_ACE4_ACCESS_DENIED_ACE_TYPE &&
765 specid <= SMB_ACE4_WHO_EVERYONE) {
769 if (ace->aceType==SMB_ACE4_ACCESS_ALLOWED_ACE_TYPE)
770 haveAllowEntry[specid] = True;
772 /* mode >> 6 for @owner, mode >> 3 for @group,
773 * mode >> 0 for @everyone */
774 newMask = gpfsacl_mask_filter(ace->aceType, ace->aceMask,
775 mode >> ((SMB_ACE4_WHO_EVERYONE - specid) * 3));
776 if (ace->aceMask!=newMask) {
777 DEBUG(10, ("ace changed for %s (%o -> %o) id=%d\n",
778 path, ace->aceMask, newMask, specid));
780 ace->aceMask = newMask;
784 /* make sure we have at least ALLOW entries
785 * for all the 3 special ids (@EVERYONE, @OWNER, @GROUP)
788 for(i = SMB_ACE4_WHO_OWNER; i<=SMB_ACE4_WHO_EVERYONE; i++) {
791 if (haveAllowEntry[i]==True)
795 ace.aceType = SMB_ACE4_ACCESS_ALLOWED_ACE_TYPE;
796 ace.flags |= SMB_ACE4_ID_SPECIAL;
797 ace.who.special_id = i;
799 if (i==SMB_ACE4_WHO_GROUP) /* not sure it's necessary... */
800 ace.aceFlags |= SMB_ACE4_IDENTIFIER_GROUP;
802 ace.aceMask = gpfsacl_mask_filter(ace.aceType, ace.aceMask,
803 mode >> ((SMB_ACE4_WHO_EVERYONE - i) * 3));
805 /* don't add unnecessary aces */
809 /* we add it to the END - as windows expects allow aces */
810 smb_add_ace4(pacl, &ace);
811 DEBUG(10, ("Added ALLOW ace for %s, mode=%o, id=%d, aceMask=%x\n",
812 path, mode, i, ace.aceMask));
815 /* don't add complementary DENY ACEs here */
816 ZERO_STRUCT(fake_fsp);
817 fake_fsp.fsp_name = (char *)path; /* no file_new is needed here */
820 if (gpfsacl_process_smbacl(&fake_fsp, pacl) == False)
822 return 0; /* ok for [f]chmod */
825 static int vfs_gpfs_chmod(vfs_handle_struct *handle, const char *path, mode_t mode)
830 if (SMB_VFS_NEXT_STAT(handle, path, &st) != 0) {
834 /* avoid chmod() if possible, to preserve acls */
835 if ((st.st_mode & ~S_IFMT) == mode) {
839 rc = gpfsacl_emu_chmod(path, mode);
841 return SMB_VFS_NEXT_CHMOD(handle, path, mode);
845 static int vfs_gpfs_fchmod(vfs_handle_struct *handle, files_struct *fsp, mode_t mode)
850 if (SMB_VFS_NEXT_FSTAT(handle, fsp, &st) != 0) {
854 /* avoid chmod() if possible, to preserve acls */
855 if ((st.st_mode & ~S_IFMT) == mode) {
859 rc = gpfsacl_emu_chmod(fsp->fsp_name, mode);
861 return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);
865 /* VFS operations structure */
867 static vfs_op_tuple gpfs_op_tuples[] = {
869 { SMB_VFS_OP(vfs_gpfs_kernel_flock),
870 SMB_VFS_OP_KERNEL_FLOCK,
871 SMB_VFS_LAYER_OPAQUE },
873 { SMB_VFS_OP(vfs_gpfs_setlease),
874 SMB_VFS_OP_LINUX_SETLEASE,
875 SMB_VFS_LAYER_OPAQUE },
877 { SMB_VFS_OP(vfs_gpfs_get_real_filename),
878 SMB_VFS_OP_GET_REAL_FILENAME,
879 SMB_VFS_LAYER_OPAQUE },
881 { SMB_VFS_OP(gpfsacl_fget_nt_acl),
882 SMB_VFS_OP_FGET_NT_ACL,
883 SMB_VFS_LAYER_TRANSPARENT },
885 { SMB_VFS_OP(gpfsacl_get_nt_acl),
886 SMB_VFS_OP_GET_NT_ACL,
887 SMB_VFS_LAYER_TRANSPARENT },
889 { SMB_VFS_OP(gpfsacl_fset_nt_acl),
890 SMB_VFS_OP_FSET_NT_ACL,
891 SMB_VFS_LAYER_TRANSPARENT },
893 { SMB_VFS_OP(gpfsacl_sys_acl_get_file),
894 SMB_VFS_OP_SYS_ACL_GET_FILE,
895 SMB_VFS_LAYER_TRANSPARENT },
897 { SMB_VFS_OP(gpfsacl_sys_acl_get_fd),
898 SMB_VFS_OP_SYS_ACL_GET_FD,
899 SMB_VFS_LAYER_TRANSPARENT },
901 { SMB_VFS_OP(gpfsacl_sys_acl_set_file),
902 SMB_VFS_OP_SYS_ACL_SET_FILE,
903 SMB_VFS_LAYER_TRANSPARENT },
905 { SMB_VFS_OP(gpfsacl_sys_acl_set_fd),
906 SMB_VFS_OP_SYS_ACL_SET_FD,
907 SMB_VFS_LAYER_TRANSPARENT },
909 { SMB_VFS_OP(gpfsacl_sys_acl_delete_def_file),
910 SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE,
911 SMB_VFS_LAYER_TRANSPARENT },
913 { SMB_VFS_OP(vfs_gpfs_chmod),
915 SMB_VFS_LAYER_TRANSPARENT },
917 { SMB_VFS_OP(vfs_gpfs_fchmod),
919 SMB_VFS_LAYER_TRANSPARENT },
921 { SMB_VFS_OP(NULL), SMB_VFS_OP_NOOP, SMB_VFS_LAYER_NOOP }
926 NTSTATUS vfs_gpfs_init(void);
927 NTSTATUS vfs_gpfs_init(void)
931 return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "gpfs",