vfs: Implement ceph_snap_gmt_get_real_filename_at()
authorVolker Lendecke <vl@samba.org>
Tue, 15 Mar 2022 11:06:08 +0000 (12:06 +0100)
committerRalph Boehme <slow@samba.org>
Thu, 28 Apr 2022 13:12:33 +0000 (13:12 +0000)
Copy the logic from ceph_snap_gmt_get_real_filename(). This is
untested in autobuild, but as ceph is broken anyway due to
812cb602e3be, we need to talk to the ceph developers before 4.17.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/modules/vfs_ceph_snapshots.c

index 2878eb7041ef4c819692bb4cf241ef1fbae26cf2..d86f7fe061055341492f6c053991322e4296f73d 100644 (file)
@@ -1358,8 +1358,48 @@ static NTSTATUS ceph_snap_gmt_get_real_filename_at(
        TALLOC_CTX *mem_ctx,
        char **found_name)
 {
-       NTSTATUS status = ceph_snap_gmt_get_real_filename(
-               handle, dirfsp->fsp_name, name, mem_ctx, found_name);
+       time_t timestamp = 0;
+       char stripped[PATH_MAX + 1];
+       char conv[PATH_MAX + 1];
+       struct smb_filename *conv_fname = NULL;
+       int ret;
+       NTSTATUS status;
+
+       ret = ceph_snap_gmt_strip_snapshot(
+               handle,
+               dirfsp->fsp_name,
+               &timestamp,
+               stripped,
+               sizeof(stripped));
+       if (ret < 0) {
+               return map_nt_error_from_unix(-ret);
+       }
+       if (timestamp == 0) {
+               return SMB_VFS_NEXT_GET_REAL_FILENAME_AT(
+                       handle, dirfsp, name, mem_ctx, found_name);
+       }
+       ret = ceph_snap_gmt_convert_dir(handle, stripped,
+                                       timestamp, conv, sizeof(conv));
+       if (ret < 0) {
+               return map_nt_error_from_unix(-ret);
+       }
+
+       status = synthetic_pathref(
+               talloc_tos(),
+               dirfsp->conn->cwd_fsp,
+               conv,
+               NULL,
+               NULL,
+               0,
+               0,
+               &conv_fname);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
+       status = SMB_VFS_NEXT_GET_REAL_FILENAME_AT(
+               handle, conv_fname->fsp, name, mem_ctx, found_name);
+       TALLOC_FREE(conv_fname);
        return status;
 }