projects
/
dss.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix --config-file for relative paths.
[dss.git]
/
snap.c
diff --git
a/snap.c
b/snap.c
index 41dc3296531001d88e9beb709b66c47d2fd2090d..da95c1f342dc09bcc01d1eef58a075dd721472ef 100644
(file)
--- a/
snap.c
+++ b/
snap.c
@@
-1,8
+1,4
@@
-/*
- * Copyright (C) 2008-2010 Andre Noll <maan@systemlinux.org>
- *
- * Licensed under the GPL v2. For licencing details see COPYING.
- */
+/* SPDX-License-Identifier: GPL-2.0 */
#include <stdlib.h>
#include <assert.h>
#include <inttypes.h>
#include <stdlib.h>
#include <assert.h>
#include <inttypes.h>
@@
-14,11
+10,11
@@
#include <sys/time.h>
#include "gcc-compat.h"
#include <sys/time.h>
#include "gcc-compat.h"
-#include "err
or
.h"
+#include "err.h"
#include "snap.h"
#include "snap.h"
-#include "str
ing
.h"
-#include "t
ime
.h"
-#include "f
d
.h"
+#include "str.h"
+#include "t
v
.h"
+#include "f
ile
.h"
/**
* Wrapper for isdigit.
/**
* Wrapper for isdigit.
@@
-75,7
+71,6
@@
static int is_snapshot(const char *dirname, int64_t now, int unit_interval,
if (num > now)
return 0;
s->creation_time = num;
if (num > now)
return 0;
s->creation_time = num;
- //DSS_DEBUG_LOG("%s start time: %lli\n", dirname, (long long)s->creation_time);
s->interval = (long long) ((now - s->creation_time)
/ unit_interval / 24 / 3600);
if (!strcmp(dash + 1, "incomplete")) {
s->interval = (long long) ((now - s->creation_time)
/ unit_interval / 24 / 3600);
if (!strcmp(dash + 1, "incomplete")) {
@@
-85,7
+80,7
@@
static int is_snapshot(const char *dirname, int64_t now, int unit_interval,
}
if (!strcmp(dash + 1, "incomplete.being_deleted")) {
s->completion_time = -1;
}
if (!strcmp(dash + 1, "incomplete.being_deleted")) {
s->completion_time = -1;
- s->flags = SS_BEING_DELETED; /*
mot cp
mplete, being deleted */
+ s->flags = SS_BEING_DELETED; /*
not co
mplete, being deleted */
goto success;
}
tmp = dash + 1;
goto success;
}
tmp = dash + 1;
@@
-146,20
+141,19
@@
static int add_snapshot(const char *dirname, void *private)
static int compare_snapshots(const void *a, const void *b)
{
static int compare_snapshots(const void *a, const void *b)
{
- struct snapshot *s1 = *(struct snapshot **)a;
- struct snapshot *s2 = *(struct snapshot **)b;
+ struct snapshot *s1 = *(struct snapshot *
const
*)a;
+ struct snapshot *s2 = *(struct snapshot *
const
*)b;
return NUM_COMPARE(s2->creation_time, s1->creation_time);
}
return NUM_COMPARE(s2->creation_time, s1->creation_time);
}
-
+/* The returned snapshot list is sorted by creation time. */
void get_snapshot_list(struct snapshot_list *sl, int unit_interval,
int num_intervals)
{
void get_snapshot_list(struct snapshot_list *sl, int unit_interval,
int num_intervals)
{
- struct add_snapshot_data asd = {
- .unit_interval = unit_interval,
- .num_intervals = num_intervals,
- .sl = sl
- };
+ struct add_snapshot_data asd;
+ asd.unit_interval = unit_interval;
+ asd.num_intervals = num_intervals;
+ asd.sl = sl;
sl->now = get_current_time();
sl->num_snapshots = 0;
sl->array_size = 0;
sl->now = get_current_time();
sl->num_snapshots = 0;
sl->array_size = 0;
@@
-234,3
+228,13
@@
__malloc char *name_of_newest_complete_snapshot(struct snapshot_list *sl)
return name;
}
return name;
}
+int num_complete_snapshots(struct snapshot_list *sl)
+{
+ struct snapshot *s;
+ int i, ret = 0;
+
+ FOR_EACH_SNAPSHOT(s, i, sl)
+ if (s->flags & SS_COMPLETE)
+ ret++;
+ return ret;
+}