vfs_media_harmony: implement SMB_VFS_OPENAT()
authorRalph Boehme <slow@samba.org>
Wed, 20 May 2020 19:43:26 +0000 (21:43 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 21 May 2020 20:38:33 +0000 (20:38 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/modules/vfs_media_harmony.c

index fc4426754a11199c6ec5da00e8ace62f45aebf52..a4ff36768adbc34bf45c770072fcdcf0553ab98e 100644 (file)
@@ -1099,6 +1099,63 @@ out:
        return ret;
 }
 
+/*
+ * Success: return non-negative file descriptor
+ * Failure: set errno, return -1
+ */
+static int mh_openat(struct vfs_handle_struct *handle,
+                    const struct files_struct *dirfsp,
+                    const struct smb_filename *smb_fname,
+                    files_struct *fsp,
+                    int flags,
+                    mode_t mode)
+{
+       int ret;
+       struct smb_filename *clientFname;
+       TALLOC_CTX *ctx;
+
+       DEBUG(MH_INFO_DEBUG, ("Entering with smb_fname->base_name '%s'\n",
+                             smb_fname->base_name));
+
+       if (!is_in_media_files(smb_fname->base_name)) {
+               ret = SMB_VFS_NEXT_OPENAT(handle,
+                                         dirfsp,
+                                         smb_fname,
+                                         fsp,
+                                         flags,
+                                         mode);
+               goto out;
+       }
+
+       clientFname = NULL;
+       ctx = talloc_tos();
+
+       if (alloc_get_client_smb_fname(handle, ctx, smb_fname, &clientFname)) {
+               ret = -1;
+               goto err;
+       }
+
+       /*
+        * 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(MH_INFO_DEBUG, ("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, clientFname, fsp, flags, mode);
+err:
+       TALLOC_FREE(clientFname);
+out:
+       DEBUG(MH_INFO_DEBUG, ("Leaving with smb_fname->base_name '%s'\n",
+                               smb_fname->base_name));
+       return ret;
+}
+
 /*
  * Success: return non-negative file descriptor
  * Failure: set errno, return -1
@@ -2216,6 +2273,7 @@ static struct vfs_fn_pointers vfs_mh_fns = {
        /* File operations */
 
        .open_fn = mh_open,
+       .openat_fn = mh_openat,
        .create_file_fn = mh_create_file,
        .renameat_fn = mh_renameat,
        .stat_fn = mh_stat,