s3: VFS: Change SMB_VFS_CHFLAGS to use const struct smb_filename * instead of const...
[kamenim/samba-autobuild/.git] / source3 / modules / vfs_unityed_media.c
index 3b3493d013f7bc7ff7d7a2e63657b5801956ccd1..aa06ea361fac4b0018cbefcd047cb333d83215ce 100644 (file)
@@ -1412,28 +1412,28 @@ err:
 }
 
 static int um_mknod(vfs_handle_struct *handle,
-                   const char *pathname,
+                   const struct smb_filename *smb_fname,
                    mode_t mode,
                    SMB_DEV_T dev)
 {
        int status;
-       char *client_path = NULL;
+       struct smb_filename *client_fname = NULL;
 
        DEBUG(10, ("Entering um_mknod\n"));
-       if (!is_in_media_files(pathname)) {
-               return SMB_VFS_NEXT_MKNOD(handle, pathname, mode, dev);
+       if (!is_in_media_files(smb_fname->base_name)) {
+               return SMB_VFS_NEXT_MKNOD(handle, smb_fname, mode, dev);
        }
 
-       status = alloc_get_client_path(handle, talloc_tos(),
-                                      pathname, &client_path);
+       status = alloc_get_client_smb_fname(handle, talloc_tos(),
+                                           smb_fname, &client_fname);
        if (status != 0) {
                goto err;
        }
 
-       status = SMB_VFS_NEXT_MKNOD(handle, client_path, mode, dev);
+       status = SMB_VFS_NEXT_MKNOD(handle, client_fname, mode, dev);
 
 err:
-       TALLOC_FREE(client_path);
+       TALLOC_FREE(client_fname);
        return status;
 }
 
@@ -1464,27 +1464,27 @@ err:
 }
 
 static int um_chflags(vfs_handle_struct *handle,
-                     const char *path,
-                     unsigned int flags)
+                       const struct smb_filename *smb_fname,
+                       unsigned int flags)
 {
        int status;
-       char *client_path = NULL;
-
-       DEBUG(10, ("Entering um_chflags\n"));
+       struct smb_filename *client_fname = NULL;
 
-       if (!is_in_media_files(path)) {
-               return SMB_VFS_NEXT_CHFLAGS(handle, path, flags);
+       DEBUG(10, ("Entering um_mknod\n"));
+       if (!is_in_media_files(smb_fname->base_name)) {
+               return SMB_VFS_NEXT_CHFLAGS(handle, smb_fname, flags);
        }
 
-       status = alloc_get_client_path(handle, talloc_tos(),
-                                      path, &client_path);
+       status = alloc_get_client_smb_fname(handle, talloc_tos(),
+                                           smb_fname, &client_fname);
        if (status != 0) {
                goto err;
        }
 
-       status = SMB_VFS_NEXT_CHFLAGS(handle, client_path, flags);
+       status = SMB_VFS_NEXT_CHFLAGS(handle, client_fname, flags);
+
 err:
-       TALLOC_FREE(client_path);
+       TALLOC_FREE(client_fname);
        return status;
 }
 
@@ -1609,251 +1609,236 @@ err:
 }
 
 static SMB_ACL_T um_sys_acl_get_file(vfs_handle_struct *handle,
-                                    const char *path_p,
-                                    SMB_ACL_TYPE_T type,
-                                    TALLOC_CTX *mem_ctx)
+                               const struct smb_filename *smb_fname,
+                               SMB_ACL_TYPE_T type,
+                               TALLOC_CTX *mem_ctx)
 {
        SMB_ACL_T ret;
-       char *client_path = NULL;
+       int saved_errno = 0;
+       struct smb_filename *client_fname = NULL;
        int status;
 
        DEBUG(10, ("Entering um_sys_acl_get_file\n"));
 
-       if (!is_in_media_files(path_p)) {
-               return SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, path_p,
+       if (!is_in_media_files(smb_fname->base_name)) {
+               return SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, smb_fname,
                                                     type, mem_ctx);
        }
 
-       status = alloc_get_client_path(handle, talloc_tos(),
-                                      path_p, &client_path);
+       status = alloc_get_client_smb_fname(handle,
+                               talloc_tos(),
+                               smb_fname,
+                               &client_fname);
        if (status != 0) {
-               ret = NULL;
+               ret = (SMB_ACL_T)NULL;
                goto err;
        }
 
-       ret = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, client_path, type, mem_ctx);
+       ret = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, client_fname,
+                               type, mem_ctx);
 
 err:
-       TALLOC_FREE(client_path);
+       if (ret == (SMB_ACL_T)NULL) {
+               saved_errno = errno;
+       }
+       TALLOC_FREE(client_fname);
+       if (saved_errno != 0) {
+               errno = saved_errno;
+       }
        return ret;
 }
 
 static int um_sys_acl_set_file(vfs_handle_struct *handle,
-                              const char *name,
+                              const struct smb_filename *smb_fname,
                               SMB_ACL_TYPE_T acltype,
                               SMB_ACL_T theacl)
 {
        int status;
-       char *client_path = NULL;
+       int saved_errno = 0;
+       struct smb_filename *client_fname = NULL;
 
        DEBUG(10, ("Entering um_sys_acl_set_file\n"));
 
-       if (!is_in_media_files(name)) {
-               return SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, name,
+       if (!is_in_media_files(smb_fname->base_name)) {
+               return SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, smb_fname,
                                                     acltype, theacl);
        }
 
-       status = alloc_get_client_path(handle, talloc_tos(),
-                                      name, &client_path);
+       status = alloc_get_client_smb_fname(handle,
+                               talloc_tos(),
+                               smb_fname,
+                               &client_fname);
        if (status != 0) {
                goto err;
        }
 
-       status = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, client_path,
+       status = SMB_VFS_NEXT_SYS_ACL_SET_FILE(handle, client_fname,
                                               acltype, theacl);
 
 err:
-       TALLOC_FREE(client_path);
+       if (status == -1) {
+               saved_errno = errno;
+       }
+       TALLOC_FREE(client_fname);
+       if (saved_errno != 0) {
+               errno = saved_errno;
+       }
        return status;
 }
 
 static int um_sys_acl_delete_def_file(vfs_handle_struct *handle,
-                                     const char *path)
+                               const struct smb_filename *smb_fname)
 {
        int status;
-       char *client_path = NULL;
+       int saved_errno = 0;
+       struct smb_filename *client_fname = NULL;
 
        DEBUG(10, ("Entering um_sys_acl_delete_def_file\n"));
 
-       if (!is_in_media_files(path)) {
-               return SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path);
+       if (!is_in_media_files(smb_fname->base_name)) {
+               return SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle,
+                               smb_fname);
        }
 
-       status = alloc_get_client_path(handle, talloc_tos(),
-                                           path, &client_path);
+       status = alloc_get_client_smb_fname(handle,
+                               talloc_tos(),
+                               smb_fname,
+                               &client_fname);
        if (status != 0) {
                goto err;
        }
 
-       status = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, client_path);
+       status = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, client_fname);
 
 err:
-       TALLOC_FREE(client_path);
+       if (status == -1) {
+               saved_errno = errno;
+       }
+       TALLOC_FREE(client_fname);
+       if (saved_errno != 0) {
+               errno = saved_errno;
+       }
        return status;
 }
 
 static ssize_t um_getxattr(struct vfs_handle_struct *handle,
-                          const char *path,
+                          const struct smb_filename *smb_fname,
                           const char *name,
                           void *value,
                           size_t size)
 {
        ssize_t ret;
-       char *client_path = NULL;
+       struct smb_filename *client_fname = NULL;
        int status;
 
        DEBUG(10, ("Entering um_getxattr\n"));
-       if (!is_in_media_files(path)) {
-               return SMB_VFS_NEXT_GETXATTR(handle, path, name, value, size);
+       if (!is_in_media_files(smb_fname->base_name)) {
+               return SMB_VFS_NEXT_GETXATTR(handle, smb_fname,
+                               name, value, size);
        }
 
-       status = alloc_get_client_path(handle, talloc_tos(),
-                                      path, &client_path);
+       status = alloc_get_client_smb_fname(handle,
+                               talloc_tos(),
+                               smb_fname,
+                               &client_fname);
        if (status != 0) {
                ret = -1;
                goto err;
        }
 
-       ret = SMB_VFS_NEXT_GETXATTR(handle, client_path, name, value, size);
+       ret = SMB_VFS_NEXT_GETXATTR(handle, client_fname, name, value, size);
 err:
-       TALLOC_FREE(client_path);
+       TALLOC_FREE(client_fname);
        return ret;
 }
 
 static ssize_t um_listxattr(struct vfs_handle_struct *handle,
-                           const char *path,
+                           const struct smb_filename *smb_fname,
                            char *list,
                            size_t size)
 {
        ssize_t ret;
-       char *client_path = NULL;
+       struct smb_filename *client_fname = NULL;
        int status;
 
        DEBUG(10, ("Entering um_listxattr\n"));
 
-       if (!is_in_media_files(path)) {
-               return SMB_VFS_NEXT_LISTXATTR(handle, path, list, size);
+       if (!is_in_media_files(smb_fname->base_name)) {
+               return SMB_VFS_NEXT_LISTXATTR(handle, smb_fname, list, size);
        }
 
-       status = alloc_get_client_path(handle, talloc_tos(),
-                                      path, &client_path);
+       status = alloc_get_client_smb_fname(handle,
+                               talloc_tos(),
+                               smb_fname,
+                               &client_fname);
        if (status != 0) {
                ret = -1;
                goto err;
        }
 
-       ret = SMB_VFS_NEXT_LISTXATTR(handle, client_path, list, size);
+       ret = SMB_VFS_NEXT_LISTXATTR(handle, client_fname, list, size);
 
 err:
-       TALLOC_FREE(client_path);
+       TALLOC_FREE(client_fname);
        return ret;
 }
 
 static int um_removexattr(struct vfs_handle_struct *handle,
-                         const char *path,
+                         const struct smb_filename *smb_fname,
                          const char *name)
 {
        int status;
-       char *client_path = NULL;
+       struct smb_filename *client_fname = NULL;
 
        DEBUG(10, ("Entering um_removexattr\n"));
 
-       if (!is_in_media_files(path)) {
-               return SMB_VFS_NEXT_REMOVEXATTR(handle, path, name);
+       if (!is_in_media_files(smb_fname->base_name)) {
+               return SMB_VFS_NEXT_REMOVEXATTR(handle, smb_fname, name);
        }
 
-       status = alloc_get_client_path(handle, talloc_tos(),
-                                      path, &client_path);
+       status = alloc_get_client_smb_fname(handle,
+                               talloc_tos(),
+                               smb_fname,
+                               &client_fname);
        if (status != 0) {
                goto err;
        }
 
-       status = SMB_VFS_NEXT_REMOVEXATTR(handle, client_path, name);
+       status = SMB_VFS_NEXT_REMOVEXATTR(handle, client_fname, name);
 
 err:
-       TALLOC_FREE(client_path);
+       TALLOC_FREE(client_fname);
        return status;
 }
 
 static int um_setxattr(struct vfs_handle_struct *handle,
-                      const char *path,
+                      const struct smb_filename *smb_fname,
                       const char *name,
                       const void *value,
                       size_t size,
                       int flags)
 {
        int status;
-       char *client_path = NULL;
+       struct smb_filename *client_fname = NULL;
 
        DEBUG(10, ("Entering um_setxattr\n"));
 
-       if (!is_in_media_files(path)) {
-               return SMB_VFS_NEXT_SETXATTR(handle, path, name, value,
+       if (!is_in_media_files(smb_fname->base_name)) {
+               return SMB_VFS_NEXT_SETXATTR(handle, smb_fname, name, value,
                                             size, flags);
        }
 
-       status = alloc_get_client_path(handle, talloc_tos(),
-                                      path, &client_path);
+       status = alloc_get_client_smb_fname(handle,
+                               talloc_tos(),
+                               smb_fname,
+                               &client_fname);
        if (status != 0) {
                goto err;
        }
 
-       status = SMB_VFS_NEXT_SETXATTR(handle, client_path, name, value,
+       status = SMB_VFS_NEXT_SETXATTR(handle, client_fname, name, value,
                                       size, flags);
 
-err:
-       TALLOC_FREE(client_path);
-       return status;
-}
-
-static bool um_is_offline(struct vfs_handle_struct *handle,
-                         const struct smb_filename *fname,
-                         SMB_STRUCT_STAT *sbuf)
-{
-       bool ret;
-       struct smb_filename *client_fname = NULL;
-       int status;
-
-       DEBUG(10, ("Entering um_is_offline\n"));
-
-       if (!is_in_media_files(fname->base_name)) {
-               return SMB_VFS_NEXT_IS_OFFLINE(handle, fname, sbuf);
-       }
-
-       status = alloc_get_client_smb_fname(handle, talloc_tos(),
-                                           fname, &client_fname);
-       if (status != 0) {
-               ret = false;
-               goto err;
-       }
-
-       ret = SMB_VFS_NEXT_IS_OFFLINE(handle, client_fname, sbuf);
-
-err:
-       TALLOC_FREE(client_fname);
-       return ret;
-}
-
-static int um_set_offline(struct vfs_handle_struct *handle,
-                         const struct smb_filename *fname)
-{
-       int status;
-       struct smb_filename *client_fname = NULL;
-
-       DEBUG(10, ("Entering um_set_offline\n"));
-
-       if (!is_in_media_files(fname->base_name)) {
-               return SMB_VFS_NEXT_SET_OFFLINE(handle, fname);
-       }
-
-       status = alloc_get_client_smb_fname(handle, talloc_tos(),
-                                           fname, &client_fname);
-       if (status != 0) {
-               goto err;
-       }
-
-       status = SMB_VFS_NEXT_SET_OFFLINE(handle, client_fname);
-
 err:
        TALLOC_FREE(client_fname);
        return status;
@@ -1956,16 +1941,10 @@ static struct vfs_fn_pointers vfs_um_fns = {
        .listxattr_fn = um_listxattr,
        .removexattr_fn = um_removexattr,
        .setxattr_fn = um_setxattr,
-
-       /* aio operations */
-
-       /* offline operations */
-       .is_offline_fn = um_is_offline,
-       .set_offline_fn = um_set_offline
 };
 
-NTSTATUS vfs_unityed_media_init(void);
-NTSTATUS vfs_unityed_media_init(void)
+NTSTATUS vfs_unityed_media_init(TALLOC_CTX *);
+NTSTATUS vfs_unityed_media_init(TALLOC_CTX *ctx)
 {
        NTSTATUS ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
                                        "unityed_media", &vfs_um_fns);