vfs_unityed_media: implement SMB_VFS_OPENAT()
authorRalph Boehme <slow@samba.org>
Wed, 20 May 2020 20:24:37 +0000 (22:24 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 21 May 2020 20:38:34 +0000 (20:38 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_unityed_media.c

index e026f9e9398c1ff7f8044e65d3d53a1ecf7508df..bffa60b718132421e19bba78c33a8757ab266b54 100644 (file)
@@ -824,6 +824,61 @@ err:
        return ret;
 }
 
+static int um_openat(struct vfs_handle_struct *handle,
+                    const struct files_struct *dirfsp,
+                    const struct smb_filename *smb_fname,
+                    struct files_struct *fsp,
+                    int flags,
+                    mode_t mode)
+{
+       struct smb_filename *client_fname = NULL;
+       int ret;
+
+       DBG_DEBUG("Entering with smb_fname->base_name '%s'\n",
+                 smb_fname->base_name);
+
+       if (!is_in_media_files(smb_fname->base_name)) {
+               return SMB_VFS_NEXT_OPENAT(handle,
+                                          dirfsp,
+                                          smb_fname,
+                                          fsp,
+                                          flags,
+                                          mode);
+       }
+
+       if (alloc_get_client_smb_fname(handle, talloc_tos(),
+                                      smb_fname,
+                                      &client_fname)) {
+               ret = -1;
+               goto err;
+       }
+
+       /*
+        * FIXME:
+        * What about fsp->fsp_name?  We also have to get correct stat
+        * info into fsp and smb_fname for DB files, don't we?
+        */
+
+       DEBUG(10, ("Leaving with smb_fname->base_name '%s' "
+                  "smb_fname->st.st_ex_mtime %s"
+                  "fsp->fsp_name->st.st_ex_mtime %s",
+                  smb_fname->base_name,
+                  ctime(&(smb_fname->st.st_ex_mtime.tv_sec)),
+                  ctime(&(fsp->fsp_name->st.st_ex_mtime.tv_sec))));
+
+       ret = SMB_VFS_NEXT_OPENAT(handle,
+                                 dirfsp,
+                                 client_fname,
+                                 fsp,
+                                 flags,
+                                 mode);
+err:
+       TALLOC_FREE(client_fname);
+       DEBUG(10, ("Leaving with smb_fname->base_name '%s'\n",
+                             smb_fname->base_name));
+       return ret;
+}
+
 static NTSTATUS um_create_file(vfs_handle_struct *handle,
                               struct smb_request *req,
                               struct files_struct **dirfsp,
@@ -1839,6 +1894,7 @@ static struct vfs_fn_pointers vfs_um_fns = {
        /* File operations */
 
        .open_fn = um_open,
+       .openat_fn = um_openat,
        .create_file_fn = um_create_file,
        .renameat_fn = um_renameat,
        .stat_fn = um_stat,