shadow_copy2: introduce shadow_copy2_snapshot_path()
authorMichael Adam <obnox@samba.org>
Thu, 30 May 2013 22:18:52 +0000 (00:18 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 4 Oct 2013 20:21:22 +0000 (09:21 +1300)
This builds the posix snapshot path for the connection
at the provided timestamp. For the non-snapdirseverywhere case.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/modules/vfs_shadow_copy2.c

index ac6cdbb42d6db430e39bebb77249775a2bb62d87..ec608849ccef7c2a8aac61eb53ff8c45e0f69cdc 100644 (file)
@@ -252,6 +252,43 @@ static char *shadow_copy2_insert_string(TALLOC_CTX *mem_ctx,
        return result;
 }
 
+/**
+ * Build the posix snapshot path for the connection
+ * at the given timestamp, i.e. the absolute posix path
+ * that contains the snapshot for this file system.
+ *
+ * This only applies to classical case, i.e. not
+ * to the "snapdirseverywhere" mode.
+ */
+static char *shadow_copy2_snapshot_path(TALLOC_CTX *mem_ctx,
+                                       struct vfs_handle_struct *handle,
+                                       time_t snapshot)
+{
+       fstring snaptime_string;
+       size_t snaptime_len = 0;
+       char *result = NULL;
+       struct shadow_copy2_config *config;
+
+       SMB_VFS_HANDLE_GET_DATA(handle, config, struct shadow_copy2_config,
+                               return NULL);
+
+       snaptime_len = shadow_copy2_posix_gmt_string(handle,
+                                                    snapshot,
+                                                    snaptime_string,
+                                                    sizeof(snaptime_string));
+       if (snaptime_len <= 0) {
+               return NULL;
+       }
+
+       result = talloc_asprintf(mem_ctx, "%s/%s",
+                                config->snapshot_basepath, snaptime_string);
+       if (result == NULL) {
+               DEBUG(1, (__location__ " talloc_asprintf failed\n"));
+       }
+
+       return result;
+}
+
 /**
  * Strip a snapshot component from an filename as
  * handed in via the smb layer.