s3: VFS: Change SMB_VFS_SYS_ACL_GET_FILE to use const struct smb_filename * instead...
[samba.git] / source3 / modules / vfs_aixacl.c
index a60470ffc9528537f98c91c0b7e51ff1cc95e747..024c9aa2691081d878990ef0278d04102e0c6838 100644 (file)
 */
 
 #include "includes.h"
-
-extern SMB_ACL_T aixacl_to_smbacl( struct acl *file_acl);
-extern struct acl *aixacl_smb_to_aixacl(SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl);
+#include "system/filesys.h"
+#include "smbd/smbd.h"
+#include "vfs_aixacl_util.h"
 
 SMB_ACL_T aixacl_sys_acl_get_file(vfs_handle_struct *handle,
-                                   const char *path_p,
-                                   SMB_ACL_TYPE_T type)
+                                 const struct smb_filename *smb_fname,
+                                 SMB_ACL_TYPE_T type,
+                                 TALLOC_CTX *mem_ctx)
 {
+       const char *path_p = smb_fname->base_name;
        struct acl *file_acl = (struct acl *)NULL;
        struct smb_acl_t *result = (struct smb_acl_t *)NULL;
        
@@ -71,7 +73,7 @@ SMB_ACL_T aixacl_sys_acl_get_file(vfs_handle_struct *handle,
        DEBUG(10,("Got facl and returned it\n"));
 
        
-       result = aixacl_to_smbacl(file_acl);
+       result = aixacl_to_smbacl(file_acl, mem_ctx);
        SAFE_FREE(file_acl);
        return result;
        
@@ -80,8 +82,8 @@ SMB_ACL_T aixacl_sys_acl_get_file(vfs_handle_struct *handle,
 }
 
 SMB_ACL_T aixacl_sys_acl_get_fd(vfs_handle_struct *handle,
-                                 files_struct *fsp,
-                                 int fd)
+                               files_struct *fsp,
+                               TALLOC_CTX *mem_ctx)
 {
 
        struct acl *file_acl = (struct acl *)NULL;
@@ -93,7 +95,7 @@ SMB_ACL_T aixacl_sys_acl_get_fd(vfs_handle_struct *handle,
        /* Get the acl using fstatacl */
    
        DEBUG(10,("Entering AIX sys_acl_get_fd\n"));
-       DEBUG(10,("fd is %d\n",fd));
+       DEBUG(10,("fd is %d\n",fsp->fh->fd));
        file_acl = (struct acl *)SMB_MALLOC(BUFSIZ);
 
        if(file_acl == NULL) {
@@ -104,7 +106,7 @@ SMB_ACL_T aixacl_sys_acl_get_fd(vfs_handle_struct *handle,
 
        memset(file_acl,0,BUFSIZ);
 
-       rc = fstatacl(fd,0,file_acl,BUFSIZ);
+       rc = fstatacl(fsp->fh->fd,0,file_acl,BUFSIZ);
        if( (rc == -1) && (errno == ENOSPC)) {
                struct acl *new_acl = SMB_MALLOC(file_acl->acl_len + sizeof(struct acl));
                if( new_acl == NULL) {
@@ -113,7 +115,7 @@ SMB_ACL_T aixacl_sys_acl_get_fd(vfs_handle_struct *handle,
                        return NULL;
                }
                file_acl = new_acl;
-               rc = fstatacl(fd,0,file_acl,file_acl->acl_len + sizeof(struct acl));
+               rc = fstatacl(fsp->fh->fd,0,file_acl,file_acl->acl_len + sizeof(struct acl));
                if( rc == -1) {
                        DEBUG(0,("fstatacl returned %d with errno %d\n",rc,errno));
                        SAFE_FREE(file_acl);
@@ -123,7 +125,7 @@ SMB_ACL_T aixacl_sys_acl_get_fd(vfs_handle_struct *handle,
 
        DEBUG(10,("Got facl and returned it\n"));
 
-       result = aixacl_to_smbacl(file_acl);
+       result = aixacl_to_smbacl(file_acl, mem_ctx);
        SAFE_FREE(file_acl);
        return result;
        
@@ -154,7 +156,7 @@ int aixacl_sys_acl_set_file(vfs_handle_struct *handle,
 
 int aixacl_sys_acl_set_fd(vfs_handle_struct *handle,
                            files_struct *fsp,
-                           int fd, SMB_ACL_T theacl)
+                           SMB_ACL_T theacl)
 {
        struct acl *file_acl = NULL;
        unsigned int rc;
@@ -163,7 +165,7 @@ int aixacl_sys_acl_set_fd(vfs_handle_struct *handle,
        if (!file_acl)
                return -1;
 
-       rc = fchacl(fd,file_acl,file_acl->acl_len);
+       rc = fchacl(fsp->fh->fd,file_acl,file_acl->acl_len);
        DEBUG(10,("errno is %d\n",errno));
        DEBUG(10,("return code is %d\n",rc));
        SAFE_FREE(file_acl);
@@ -173,43 +175,24 @@ int aixacl_sys_acl_set_fd(vfs_handle_struct *handle,
 }
 
 int aixacl_sys_acl_delete_def_file(vfs_handle_struct *handle,
-                                    const char *path)
+                               const struct smb_filename *smb_fname)
 {
        return 0; /* otherwise you can't set acl at upper level */
 }
 
-/* VFS operations structure */
-
-static vfs_op_tuple aixacl_op_tuples[] = {
-       /* Disk operations */
-  {SMB_VFS_OP(aixacl_sys_acl_get_file),
-   SMB_VFS_OP_SYS_ACL_GET_FILE,
-   SMB_VFS_LAYER_TRANSPARENT},
-
-  {SMB_VFS_OP(aixacl_sys_acl_get_fd),
-   SMB_VFS_OP_SYS_ACL_GET_FD,
-   SMB_VFS_LAYER_TRANSPARENT},
-
-  {SMB_VFS_OP(aixacl_sys_acl_set_file),
-   SMB_VFS_OP_SYS_ACL_SET_FILE,
-   SMB_VFS_LAYER_TRANSPARENT},
-
-  {SMB_VFS_OP(aixacl_sys_acl_set_fd),
-   SMB_VFS_OP_SYS_ACL_SET_FD,
-   SMB_VFS_LAYER_TRANSPARENT},
-
-  {SMB_VFS_OP(aixacl_sys_acl_delete_def_file),
-   SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE,
-   SMB_VFS_LAYER_TRANSPARENT},
-
-  {SMB_VFS_OP(NULL),
-   SMB_VFS_OP_NOOP,
-   SMB_VFS_LAYER_NOOP}
+static struct vfs_fn_pointers vfs_aixacl_fns = {
+       .sys_acl_get_file_fn = aixacl_sys_acl_get_file,
+       .sys_acl_get_fd_fn = aixacl_sys_acl_get_fd,
+       .sys_acl_blob_get_file_fn = posix_sys_acl_blob_get_file,
+       .sys_acl_blob_get_fd_fn = posix_sys_acl_blob_get_fd,
+       .sys_acl_set_file_fn = aixacl_sys_acl_set_file,
+       .sys_acl_set_fd_fn = aixacl_sys_acl_set_fd,
+       .sys_acl_delete_def_file_fn = aixacl_sys_acl_delete_def_file,
 };
 
-NTSTATUS vfs_aixacl_init(void);
-NTSTATUS vfs_aixacl_init(void)
+NTSTATUS vfs_aixacl_init(TALLOC_CTX *);
+NTSTATUS vfs_aixacl_init(TALLOC_CTX *ctx)
 {
        return smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "aixacl",
-                               aixacl_op_tuples);
+                               &vfs_aixacl_fns);
 }