s3: VFS: Change SMB_VFS_GET_QUOTA to use const struct smb_filename * instead of const...
[kamenim/samba-autobuild/.git] / source3 / modules / vfs_snapper.c
index 774f7ee3c69e9e65516346e3294830e6436df21d..41800bf7a3aca1ecd66cb6a930046ce7d1a6de23 100644 (file)
@@ -3032,22 +3032,25 @@ static uint64_t snapper_gmt_disk_free(vfs_handle_struct *handle,
        return ret;
 }
 
-static int snapper_gmt_get_quota(vfs_handle_struct *handle, const char *path,
-                                enum SMB_QUOTA_TYPE qtype, unid_t id,
-                                SMB_DISK_QUOTA *dq)
+static int snapper_gmt_get_quota(vfs_handle_struct *handle,
+                       const struct smb_filename *smb_fname,
+                       enum SMB_QUOTA_TYPE qtype,
+                       unid_t id,
+                       SMB_DISK_QUOTA *dq)
 {
-       time_t timestamp;
-       char *stripped;
+       time_t timestamp = 0;
+       char *stripped = NULL;
        int ret;
-       int saved_errno;
-       char *conv;
+       int saved_errno = 0;
+       char *conv = NULL;
+       struct smb_filename *conv_smb_fname = NULL;
 
-       if (!snapper_gmt_strip_snapshot(talloc_tos(), handle, path, &timestamp,
-                                       &stripped)) {
+       if (!snapper_gmt_strip_snapshot(talloc_tos(), handle,
+                               smb_fname->base_name, &timestamp, &stripped)) {
                return -1;
        }
        if (timestamp == 0) {
-               return SMB_VFS_NEXT_GET_QUOTA(handle, path, qtype, id, dq);
+               return SMB_VFS_NEXT_GET_QUOTA(handle, smb_fname, qtype, id, dq);
        }
 
        conv = snapper_gmt_convert(talloc_tos(), handle, stripped, timestamp);
@@ -3055,13 +3058,26 @@ static int snapper_gmt_get_quota(vfs_handle_struct *handle, const char *path,
        if (conv == NULL) {
                return -1;
        }
-
-       ret = SMB_VFS_NEXT_GET_QUOTA(handle, conv, qtype, id, dq);
-
-       saved_errno = errno;
+       conv_smb_fname = synthetic_smb_fname(talloc_tos(),
+                                       conv,
+                                       NULL,
+                                       NULL,
+                                       smb_fname->flags);
        TALLOC_FREE(conv);
-       errno = saved_errno;
+       if (conv_smb_fname == NULL) {
+               errno = ENOMEM;
+               return -1;
+       }
 
+       ret = SMB_VFS_NEXT_GET_QUOTA(handle, conv_smb_fname, qtype, id, dq);
+
+       if (ret == -1) {
+               saved_errno = errno;
+       }
+       TALLOC_FREE(conv_smb_fname);
+       if (saved_errno != 0) {
+               errno = saved_errno;
+       }
        return ret;
 }