]> git.tuebingen.mpg.de Git - dss.git/blobdiff - dss.c
ls: Print current duration of incomplete snapshots.
[dss.git] / dss.c
diff --git a/dss.c b/dss.c
index 5e2ef46f71251c6a157f2f9df02900c8e534a3a9..122472ec49a448e7166cdb0b70e1ea1e0b356931 100644 (file)
--- a/dss.c
+++ b/dss.c
@@ -1347,6 +1347,7 @@ static void create_rsync_argv(char ***argv, int64_t *num)
        char *logname;
        int i = 0, j, N = OPT_GIVEN(DSS, RSYNC_OPTION);
        struct snapshot_list sl;
+       static bool seeded;
 
        dss_get_snapshot_list(&sl);
        assert(!name_of_reference_snapshot);
@@ -1357,6 +1358,14 @@ static void create_rsync_argv(char ***argv, int64_t *num)
        (*argv)[i++] = dss_strdup("rsync");
        (*argv)[i++] = dss_strdup("-a");
        (*argv)[i++] = dss_strdup("--delete");
+       if (!seeded) {
+               srandom((unsigned)time(NULL)); /* no need to be fancy here */
+               seeded = true;
+       }
+       if (1000 * (random() / (RAND_MAX + 1.0)) < OPT_UINT32_VAL(DSS, CHECKSUM)) {
+               DSS_NOTICE_LOG(("adding --checksum to rsync options\n"));
+               (*argv)[i++] = dss_strdup("--checksum");
+       }
        for (j = 0; j < N; j++)
                (*argv)[i++] = dss_strdup(lls_string_val(j,
                        OPT_RESULT(DSS, RSYNC_OPTION)));
@@ -1674,13 +1683,17 @@ static int com_ls(void)
        int i;
        struct snapshot_list sl;
        struct snapshot *s;
+       int64_t now = get_current_time();
 
        dss_get_snapshot_list(&sl);
        FOR_EACH_SNAPSHOT(s, i, &sl) {
-               int64_t d = 0;
+               int64_t d;
                if (s->flags & SS_COMPLETE)
                        d = (s->completion_time - s->creation_time) / 60;
-               dss_msg("%u\t%s\t%3" PRId64 ":%02" PRId64 "\n", s->interval, s->name, d/60, d%60);
+               else
+                       d = (now - s->creation_time) / 60;
+               dss_msg("%u\t%s\t%3" PRId64 ":%02" PRId64 "\n", s->interval,
+                       s->name, d / 60, d % 60);
        }
        free_snapshot_list(&sl);
        return 1;