s3:registry: create regdb_store_keys_internal() with db_context argument
[kai/samba.git] / source3 / modules / vfs_catia.c
index d0c341fdd389cadef07056b1545033f23d8020f3..1fd101282cda4579e7f2f46385d7575df052a749 100644 (file)
@@ -105,11 +105,12 @@ static SMB_STRUCT_DIR *catia_opendir(vfs_handle_struct *handle,
 static SMB_STRUCT_DIRENT *catia_readdir(vfs_handle_struct *handle,
                                        SMB_STRUCT_DIR *dirp)
 {
-       SMB_STRUCT_DIRENT *result = SMB_VFS_NEXT_READDIR(handle, dirp);
-       SMB_STRUCT_DIRENT *newdirent;
+       SMB_STRUCT_DIRENT *result = NULL;
+       SMB_STRUCT_DIRENT *newdirent = NULL;
        char *newname;
        size_t newnamelen;
 
+       result = SMB_VFS_NEXT_READDIR(handle, dirp, NULL);
        if (result == NULL) {
                return result;
        }
@@ -132,70 +133,159 @@ static SMB_STRUCT_DIRENT *catia_readdir(vfs_handle_struct *handle,
 }
 
 static int catia_open(vfs_handle_struct *handle,
-                     const char *fname,
+                     struct smb_filename *smb_fname,
                      files_struct *fsp,
                      int flags,
                      mode_t mode)
 {
-       char *name = to_unix(talloc_tos(), fname);
+       char *name;
+       char *tmp_base_name;
+       int ret;
 
+       name = to_unix(talloc_tos(), smb_fname->base_name);
        if (!name) {
                errno = ENOMEM;
                return -1;
        }
-        return SMB_VFS_NEXT_OPEN(handle, name, fsp, flags, mode);
+
+       tmp_base_name = smb_fname->base_name;
+       smb_fname->base_name = name;
+
+       ret = SMB_VFS_NEXT_OPEN(handle, smb_fname, fsp, flags, mode);
+
+       smb_fname->base_name = tmp_base_name;
+       TALLOC_FREE(name);
+
+       return ret;
 }
 
 static int catia_rename(vfs_handle_struct *handle,
-                       const char *oldname, const char *newname)
+                       const struct smb_filename *smb_fname_src,
+                       const struct smb_filename *smb_fname_dst)
 {
        TALLOC_CTX *ctx = talloc_tos();
-       char *oname = to_unix(ctx, oldname);
-       char *nname = to_unix(ctx, newname);
-
+       char *oname = NULL;
+       char *nname = NULL;
+       struct smb_filename *smb_fname_src_tmp = NULL;
+       struct smb_filename *smb_fname_dst_tmp = NULL;
+       NTSTATUS status;
+       int ret = -1;
+
+       oname = to_unix(ctx, smb_fname_src->base_name);
+       nname = to_unix(ctx, smb_fname_dst->base_name);
        if (!oname || !nname) {
                errno = ENOMEM;
-               return -1;
+               goto out;
        }
-       DEBUG(10, ("converted old name: %s\n", oname));
-       DEBUG(10, ("converted new name: %s\n", nname));
 
-        return SMB_VFS_NEXT_RENAME(handle, oname, nname);
+       /* Setup temporary smb_filename structs. */
+       status = copy_smb_filename(talloc_tos(), smb_fname_src,
+                                  &smb_fname_src_tmp);
+       if (!NT_STATUS_IS_OK(status)) {
+               errno = map_errno_from_nt_status(status);
+               goto out;
+       }
+       status = copy_smb_filename(talloc_tos(), smb_fname_dst,
+                                  &smb_fname_dst_tmp);
+       if (!NT_STATUS_IS_OK(status)) {
+               errno = map_errno_from_nt_status(status);
+               goto out;
+       }
+
+       smb_fname_src_tmp->base_name = oname;
+       smb_fname_dst_tmp->base_name = nname;
+
+       DEBUG(10, ("converted old name: %s\n",
+                  smb_fname_str_dbg(smb_fname_src_tmp)));
+       DEBUG(10, ("converted new name: %s\n",
+                  smb_fname_str_dbg(smb_fname_dst_tmp)));
+
+        ret = SMB_VFS_NEXT_RENAME(handle, smb_fname_src_tmp,
+                                 smb_fname_dst_tmp);
+ out:
+       TALLOC_FREE(oname);
+       TALLOC_FREE(nname);
+       TALLOC_FREE(smb_fname_src_tmp);
+       TALLOC_FREE(smb_fname_dst_tmp);
+       return ret;
 }
 
 static int catia_stat(vfs_handle_struct *handle,
-                     const char *fname, SMB_STRUCT_STAT *sbuf)
+                     struct smb_filename *smb_fname)
 {
-       char *name = to_unix(talloc_tos(), fname);
+       char *name;
+       char *tmp_base_name;
+       int ret;
 
+       name = to_unix(talloc_tos(), smb_fname->base_name);
        if (!name) {
                errno = ENOMEM;
                return -1;
        }
-        return SMB_VFS_NEXT_STAT(handle, name, sbuf);
+
+       tmp_base_name = smb_fname->base_name;
+       smb_fname->base_name = name;
+
+       ret = SMB_VFS_NEXT_STAT(handle, smb_fname);
+
+       smb_fname->base_name = tmp_base_name;
+       TALLOC_FREE(name);
+
+       return ret;
 }
 
 static int catia_lstat(vfs_handle_struct *handle,
-                      const char *path, SMB_STRUCT_STAT *sbuf)
+                      struct smb_filename *smb_fname)
 {
-       char *name = to_unix(talloc_tos(), path);
+       char *name;
+       char *tmp_base_name;
+       int ret;
 
+       name = to_unix(talloc_tos(), smb_fname->base_name);
        if (!name) {
                errno = ENOMEM;
                return -1;
        }
-        return SMB_VFS_NEXT_LSTAT(handle, name, sbuf);
+
+       tmp_base_name = smb_fname->base_name;
+       smb_fname->base_name = name;
+
+       ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname);
+
+       smb_fname->base_name = tmp_base_name;
+       TALLOC_FREE(name);
+
+       return ret;
 }
 
-static int catia_unlink(vfs_handle_struct *handle, const char *path)
+static int catia_unlink(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname)
 {
-       char *name = to_unix(talloc_tos(), path);
+       struct smb_filename *smb_fname_tmp = NULL;
+       char *name = NULL;
+       NTSTATUS status;
+       int ret;
 
+       name = to_unix(talloc_tos(), smb_fname->base_name);
        if (!name) {
                errno = ENOMEM;
                return -1;
        }
-        return SMB_VFS_NEXT_UNLINK(handle, name);
+
+       /* Setup temporary smb_filename structs. */
+       status = copy_smb_filename(talloc_tos(), smb_fname,
+                                  &smb_fname_tmp);
+       if (!NT_STATUS_IS_OK(status)) {
+               errno = map_errno_from_nt_status(status);
+               return -1;
+       }
+
+       smb_fname_tmp->base_name = name;
+
+        ret = SMB_VFS_NEXT_UNLINK(handle, smb_fname_tmp);
+
+       TALLOC_FREE(smb_fname_tmp);
+       return ret;
 }
 
 static int catia_chmod(vfs_handle_struct *handle,
@@ -246,65 +336,6 @@ static int catia_chdir(vfs_handle_struct *handle,
         return SMB_VFS_NEXT_CHDIR(handle, name);
 }
 
-static char *catia_getwd(vfs_handle_struct *handle, char *buf)
-{
-        return SMB_VFS_NEXT_GETWD(handle, buf);
-}
-
-static int catia_ntimes(vfs_handle_struct *handle,
-                      const char *path, struct smb_file_time *ft)
-{
-        return SMB_VFS_NEXT_NTIMES(handle, path, ft);
-}
-
-static bool catia_symlink(vfs_handle_struct *handle,
-                         const char *oldpath, const char *newpath)
-{
-        return SMB_VFS_NEXT_SYMLINK(handle, oldpath, newpath);
-}
-
-static bool catia_readlink(vfs_handle_struct *handle,
-                          const char *path, char *buf, size_t bufsiz)
-{
-        return SMB_VFS_NEXT_READLINK(handle, path, buf, bufsiz);
-}
-
-static int catia_link(vfs_handle_struct *handle,
-                     const char *oldpath, const char *newpath)
-{
-        return SMB_VFS_NEXT_LINK(handle, oldpath, newpath);
-}
-
-static int catia_mknod(vfs_handle_struct *handle,
-                      const char *path, mode_t mode, SMB_DEV_T dev)
-{
-        return SMB_VFS_NEXT_MKNOD(handle, path, mode, dev);
-}
-
-static char *catia_realpath(vfs_handle_struct *handle,
-                           const char *path, char *resolved_path)
-{
-        return SMB_VFS_NEXT_REALPATH(handle, path, resolved_path);
-}
-
-static NTSTATUS catia_get_nt_acl(vfs_handle_struct *handle,
-                              const char *name, uint32 security_info,
-                              struct  security_descriptor **ppdesc)
-{
-        return SMB_VFS_NEXT_GET_NT_ACL(handle, name, security_info, ppdesc);
-}
-
-static int catia_chmod_acl(vfs_handle_struct *handle,
-                          const char *name, mode_t mode)
-{
-        /* If the underlying VFS doesn't have ACL support... */
-        if (!handle->vfs_next.ops.chmod_acl) {
-                errno = ENOSYS;
-                return -1;
-        }
-        return SMB_VFS_NEXT_CHMOD_ACL(handle, name, mode);
-}
-
 /* VFS operations structure */
 
 static vfs_op_tuple catia_op_tuples[] = {
@@ -336,31 +367,6 @@ SMB_VFS_LAYER_TRANSPARENT},
 SMB_VFS_LAYER_TRANSPARENT},
         {SMB_VFS_OP(catia_chdir),                       SMB_VFS_OP_CHDIR,
 SMB_VFS_LAYER_TRANSPARENT},
-        {SMB_VFS_OP(catia_getwd),                       SMB_VFS_OP_GETWD,
-SMB_VFS_LAYER_TRANSPARENT},
-        {SMB_VFS_OP(catia_ntimes),                       SMB_VFS_OP_NTIMES,
-SMB_VFS_LAYER_TRANSPARENT},
-        {SMB_VFS_OP(catia_symlink), SMB_VFS_OP_SYMLINK,
-SMB_VFS_LAYER_TRANSPARENT},
-        {SMB_VFS_OP(catia_readlink), SMB_VFS_OP_READLINK,
-SMB_VFS_LAYER_TRANSPARENT},
-        {SMB_VFS_OP(catia_link), SMB_VFS_OP_LINK,
-SMB_VFS_LAYER_TRANSPARENT},
-        {SMB_VFS_OP(catia_mknod),                       SMB_VFS_OP_MKNOD,
-SMB_VFS_LAYER_TRANSPARENT},
-        {SMB_VFS_OP(catia_realpath), SMB_VFS_OP_REALPATH,
-SMB_VFS_LAYER_TRANSPARENT},
-
-        /* NT File ACL operations */
-
-        {SMB_VFS_OP(catia_get_nt_acl), SMB_VFS_OP_GET_NT_ACL,
-SMB_VFS_LAYER_TRANSPARENT},
-
-        /* POSIX ACL operations */
-
-        {SMB_VFS_OP(catia_chmod_acl), SMB_VFS_OP_CHMOD_ACL,
-SMB_VFS_LAYER_TRANSPARENT},
-
 
         {NULL,                                          SMB_VFS_OP_NOOP,
 SMB_VFS_LAYER_NOOP}