VFS: Modify opendir to take a const struct smb_filename * instead of const char *
[kai/samba-autobuild/.git] / source3 / modules / vfs_media_harmony.c
index 65673e17fa4c927e1dc0d3c06ca8fb64ec4c4148..786cee9288ef1c910349087f5a70306444407b6c 100644 (file)
@@ -760,15 +760,16 @@ err:
  * Failure: set errno, return NULL
  */
 static DIR *mh_opendir(vfs_handle_struct *handle,
-               const char *fname,
+               const struct smb_filename *smb_fname,
                const char *mask,
                uint32_t attr)
 {
        struct mh_dirinfo_struct *dirInfo;
 
-       DEBUG(MH_INFO_DEBUG, ("Entering with fname '%s'\n", fname));
+       DEBUG(MH_INFO_DEBUG, ("Entering with fname '%s'\n",
+               smb_fname->base_name));
 
-       if (alloc_set_client_dirinfo(handle, fname, &dirInfo))
+       if (alloc_set_client_dirinfo(handle, smb_fname->base_name, &dirInfo))
        {
                goto err;
        }
@@ -776,10 +777,20 @@ static DIR *mh_opendir(vfs_handle_struct *handle,
        if (!dirInfo->isInMediaFiles)
        {
                dirInfo->dirstream = SMB_VFS_NEXT_OPENDIR(handle,
-                       fname, mask, attr);
+                       smb_fname, mask, attr);
        } else {
+               struct smb_filename *smb_fname_clientpath =
+                               synthetic_smb_fname(talloc_tos(),
+                                       dirInfo->clientPath,
+                                       NULL,
+                                       NULL);
+               if (smb_fname_clientpath == NULL) {
+                       goto err;
+               }
+
                dirInfo->dirstream = SMB_VFS_NEXT_OPENDIR(handle,
-                       dirInfo->clientPath, mask, attr);
+                       smb_fname_clientpath, mask, attr);
+               TALLOC_FREE(smb_fname_clientpath);
        }
 
        if (dirInfo->dirstream == NULL) {
@@ -794,7 +805,8 @@ static DIR *mh_opendir(vfs_handle_struct *handle,
        return (DIR*)dirInfo;
 err:
        /* Failure is freed here. */
-       DEBUG(MH_ERR_DEBUG, ("Failing with fname '%s'\n", fname));
+       DEBUG(MH_ERR_DEBUG, ("Failing with fname '%s'\n",
+               smb_fname->base_name));
        TALLOC_FREE(dirInfo);
        return NULL;
 }
@@ -1033,35 +1045,32 @@ static void mh_rewinddir(vfs_handle_struct *handle,
  * Failure: set errno, return -1
  */
 static int mh_mkdir(vfs_handle_struct *handle,
-               const char *path,
+               const struct smb_filename *smb_fname,
                mode_t mode)
 {
        int status;
-       char *clientPath;
-       TALLOC_CTX *ctx;
-
+       struct smb_filename *clientFname = NULL;
+       const char *path = smb_fname->base_name;
 
        DEBUG(MH_INFO_DEBUG, ("Entering with path '%s'\n", path));
 
        if (!is_in_media_files(path))
        {
-               status = SMB_VFS_NEXT_MKDIR(handle, path, mode);
+               status = SMB_VFS_NEXT_MKDIR(handle, smb_fname, mode);
                goto out;
        }
 
-       clientPath = NULL;
-       ctx = talloc_tos();
-
-       if ((status = alloc_get_client_path(handle, ctx,
-                               path,
-                               &clientPath)))
-       {
+       status = alloc_get_client_smb_fname(handle,
+                               talloc_tos(),
+                               smb_fname,
+                               &clientFname);
+       if (status != 0) {
                goto err;
        }
 
-       status = SMB_VFS_NEXT_MKDIR(handle, clientPath, mode);
+       status = SMB_VFS_NEXT_MKDIR(handle, clientFname, mode);
 err:
-       TALLOC_FREE(clientPath);
+       TALLOC_FREE(clientFname);
 out:
        DEBUG(MH_INFO_DEBUG, ("Leaving with path '%s'\n", path));
        return status;
@@ -1072,34 +1081,31 @@ out:
  * Failure: set errno, return -1
  */
 static int mh_rmdir(vfs_handle_struct *handle,
-               const char *path)
+               const struct smb_filename *smb_fname)
 {
        int status;
-       char *clientPath;
-       TALLOC_CTX *ctx;
-
+       struct smb_filename *clientFname = NULL;
+       const char *path = smb_fname->base_name;
 
        DEBUG(MH_INFO_DEBUG, ("Entering with path '%s'\n", path));
 
        if (!is_in_media_files(path))
        {
-               status = SMB_VFS_NEXT_RMDIR(handle, path);
+               status = SMB_VFS_NEXT_RMDIR(handle, smb_fname);
                goto out;
        }
 
-       clientPath = NULL;
-       ctx = talloc_tos();
-
-       if ((status = alloc_get_client_path(handle, ctx,
-                               path,
-                               &clientPath)))
-       {
+       status = alloc_get_client_smb_fname(handle,
+                               talloc_tos(),
+                               smb_fname,
+                               &clientFname);
+       if (status != 0) {
                goto err;
        }
 
-       status = SMB_VFS_NEXT_RMDIR(handle, clientPath);
+       status = SMB_VFS_NEXT_RMDIR(handle, clientFname);
 err:
-       TALLOC_FREE(clientPath);
+       TALLOC_FREE(clientFname);
 out:
        DEBUG(MH_INFO_DEBUG, ("Leaving with path '%s'\n", path));
        return status;