]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: VFS: ceph_snapshots: In ceph_snap_fill_label(), use ceph_snap_get_btime_fsp(...
authorJeremy Allison <jra@samba.org>
Wed, 23 Jun 2021 18:29:18 +0000 (11:29 -0700)
committerRalph Boehme <slow@samba.org>
Fri, 25 Jun 2021 15:53:31 +0000 (15:53 +0000)
Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/modules/vfs_ceph_snapshots.c

index 0ed79920064ad6217de9bb1b0d55bd6fe654db3e..13b9dfa64e811bcc124878019b43be1c0475b8ba 100644 (file)
@@ -113,7 +113,6 @@ static int ceph_snap_get_btime(struct vfs_handle_struct *handle,
        return 0;
 }
 
-#if 0
 static int ceph_snap_get_btime_fsp(struct vfs_handle_struct *handle,
                                   struct files_struct *fsp,
                                   time_t *_snap_secs)
@@ -181,7 +180,6 @@ static int ceph_snap_get_btime_fsp(struct vfs_handle_struct *handle,
 
        return 0;
 }
-#endif
 
 /*
  * XXX Ceph snapshots can be created with sub-second granularity, which means
@@ -198,12 +196,14 @@ static int ceph_snap_fill_label(struct vfs_handle_struct *handle,
 {
        const char *parent_snapsdir = dirfsp->fsp_name->base_name;
        struct smb_filename *smb_fname;
+       struct smb_filename *atname = NULL;
        time_t snap_secs;
        struct tm gmt_snap_time;
        struct tm *tm_ret;
        size_t str_sz;
        char snap_path[PATH_MAX + 1];
        int ret;
+       NTSTATUS status;
 
        /*
         * CephFS snapshot creation times are available via a special
@@ -225,11 +225,40 @@ static int ceph_snap_fill_label(struct vfs_handle_struct *handle,
                return -ENOMEM;
        }
 
-       ret = ceph_snap_get_btime(handle, smb_fname, &snap_secs);
+       ret = vfs_stat(handle->conn, smb_fname);
        if (ret < 0) {
+               ret = -errno;
+               TALLOC_FREE(smb_fname);
                return ret;
        }
 
+       atname = synthetic_smb_fname(tmp_ctx,
+                                    subdir,
+                                    NULL,
+                                    &smb_fname->st,
+                                    0,
+                                    0);
+       if (atname == NULL) {
+               TALLOC_FREE(smb_fname);
+               return -ENOMEM;
+       }
+
+       status = openat_pathref_fsp(dirfsp, atname);
+       if (!NT_STATUS_IS_OK(status)) {
+               TALLOC_FREE(smb_fname);
+               TALLOC_FREE(atname);
+               return -map_errno_from_nt_status(status);
+       }
+
+       ret = ceph_snap_get_btime_fsp(handle, atname->fsp, &snap_secs);
+       if (ret < 0) {
+               TALLOC_FREE(smb_fname);
+               TALLOC_FREE(atname);
+               return ret;
+       }
+       TALLOC_FREE(smb_fname);
+       TALLOC_FREE(atname);
+
        tm_ret = gmtime_r(&snap_secs, &gmt_snap_time);
        if (tm_ret == NULL) {
                return -EINVAL;