Add section "Commands" to dss help text.
[dss.git] / dss.c
diff --git a/dss.c b/dss.c
index 744efaf0965f5a44c68d53d43163ae8dcbb6b209..cd69c27d85a5066a49c00817621db6371c01d31e 100644 (file)
--- a/dss.c
+++ b/dss.c
@@ -1,3 +1,8 @@
+/*
+ * Copyright (C) 2008 Andre Noll <maan@systemlinux.org>
+ *
+ * Licensed under the GPL v2. For licencing details see COPYING.
+ */
 #include <string.h>
 #include <stdlib.h>
 #include <stdarg.h>
@@ -119,7 +124,6 @@ static __printf_1_2 void dss_msg(const char* fmt,...)
        va_end(argp);
 }
 
-/* TODO: Also consider number of inodes. */
 static int disk_space_low(void)
 {
        struct disk_space ds;
@@ -214,7 +218,7 @@ static int remove_redundant_snapshot(struct snapshot_list *sl)
        struct snapshot *s;
        unsigned missing = 0;
 
-       DSS_INFO_LOG("looking for intervals containing too many snapshots\n");
+       DSS_DEBUG_LOG("looking for intervals containing too many snapshots\n");
        for (interval = conf.num_intervals_arg - 1; interval >= 0; interval--) {
                unsigned keep = desired_number_of_snapshots(interval, conf.num_intervals_arg);
                unsigned num = sl->interval_count[interval];
@@ -271,7 +275,7 @@ static int remove_outdated_snapshot(struct snapshot_list *sl)
        int i, ret;
        struct snapshot *s;
 
-       DSS_INFO_LOG("looking for snapshots belonging to intervals greater than %d\n",
+       DSS_DEBUG_LOG("looking for snapshots belonging to intervals greater than %d\n",
                conf.num_intervals_arg);
        FOR_EACH_SNAPSHOT(s, i, sl) {
                if (s->interval <= conf.num_intervals_arg)
@@ -341,7 +345,7 @@ static int try_to_free_disk_space(int low_disk_space)
        if (ret)
                goto out;
        DSS_CRIT_LOG("uhuhu: not enough disk space for a single snapshot\n");
-       ret= -ENOSPC;
+       ret = -ERRNO_TO_DSS_ERROR(ENOSPC);
 out:
        free_snapshot_list(&sl);
        return ret;
@@ -746,21 +750,25 @@ static int create_snapshot(char **argv)
 static int select_loop(void)
 {
        int ret;
-       struct timeval tv = {.tv_sec = 0, .tv_usec = 0};
+       /* check every 60 seconds for free disk space */
+       struct timeval tv;
 
        for (;;) {
                fd_set rfds;
                int low_disk_space;
                char **rsync_argv;
-               struct timeval now, *tvp = &tv;
+               struct timeval now, *tvp;
 
-               if (rsync_pid)
-                       tv.tv_sec = 60; /* check every 60 seconds for free disk space */
-               else if (rm_pid)
+               if (rm_pid)
                        tvp = NULL; /* sleep until rm process dies */
+               else { /* sleep one minute */
+                       tv.tv_sec = 60;
+                       tv.tv_usec = 0;
+                       tvp = &tv;
+               }
                FD_ZERO(&rfds);
                FD_SET(signal_pipe, &rfds);
-               DSS_DEBUG_LOG("tvp: %p, tv_sec: %lu\n", tvp, (long unsigned) tv.tv_sec);
+               DSS_DEBUG_LOG("tvp: %p, tv_sec : %lu\n", tvp, (long unsigned) tv.tv_sec);
                ret = dss_select(signal_pipe + 1, &rfds, NULL, tvp);
                if (ret < 0)
                        return ret;
@@ -781,7 +789,7 @@ static int select_loop(void)
                }
                restart_rsync_process();
                gettimeofday(&now, NULL);
-               if (tv_diff(&next_snapshot_time, &now, &tv) > 0)
+               if (tv_diff(&next_snapshot_time, &now, NULL) > 0)
                        continue;
                switch (snapshot_creation_status) {
                case SCS_READY: