shadow_copy2: add comments explaining decisions in shadow_copy2_strip_snapshot()
authorMichael Adam <obnox@samba.org>
Wed, 29 May 2013 15:14:49 +0000 (17:14 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 4 Oct 2013 20:21:24 +0000 (09:21 +1300)
This should make it more easy to understand what the cases are.

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

index ec608849ccef7c2a8aac61eb53ff8c45e0f69cdc..ade8c28a12e03006d0864b79933bfe6176b6ae0a 100644 (file)
@@ -316,6 +316,7 @@ static bool shadow_copy2_strip_snapshot(TALLOC_CTX *mem_ctx,
                goto no_snapshot;
        }
        if ((p > name) && (p[-1] != '/')) {
+               /* the GMT-token does not start a path-component */
                goto no_snapshot;
        }
        q = strptime(p, GMT_FORMAT, &tm);
@@ -328,6 +329,7 @@ static bool shadow_copy2_strip_snapshot(TALLOC_CTX *mem_ctx,
                goto no_snapshot;
        }
        if ((p == name) && (q[0] == '\0')) {
+               /* the name consists of only the GMT token */
                if (pstripped != NULL) {
                        stripped = talloc_strdup(mem_ctx, "");
                        if (stripped == NULL) {
@@ -339,6 +341,14 @@ static bool shadow_copy2_strip_snapshot(TALLOC_CTX *mem_ctx,
                return true;
        }
        if (q[0] != '/') {
+               /*
+                * The GMT token is either at the end of the path
+                * or it is not a complete path component, i.e. the
+                * path component continues after the gmt-token.
+                *
+                * TODO: Is this correct? Or would the GMT tag as the
+                * last component be a valid input?
+                */
                goto no_snapshot;
        }
        q += 1;