]> git.tuebingen.mpg.de Git - dss.git/commitdiff
Merge branch 'refs/heads/t/prune'
authorAndre Noll <maan@tuebingen.mpg.de>
Thu, 7 Nov 2019 11:31:02 +0000 (12:31 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Thu, 7 Nov 2019 11:31:02 +0000 (12:31 +0100)
A couple of cleanups and unifications for the snapshot pruning code,
which is executed by the prune and run subcommands. With the patches
applied, both subcommands behave identically, i.e. they consider
the same set of snapshots as candidates for pruning. Also the prune
command gained the new --disk-space option to force it to act as if
disk space was high or low.

Cooking for six weeks.

* refs/heads/t/prune:
  Introduce prune --disk-space.
  Revamp com_prune().
  Factor out find_removable_snapshot().
  prune Simplify rm exit code logic.
  find_oldest_removable_snapshot(): Improve log message.
  prune: Print a message if there is nothing to prune.
  get_snapshot_list(): Add comment about sorting.
  prune: Fail gracefully if pre-rm hook fails.

.gitignore
Makefile
daemon.c
dss.c
dss.svg [new file with mode: 0644]
exec.c
index.html.in
mklogo [deleted file]
str.c
str.h

index 1bb2a256e58d29073cf553ece92b355f5bf2ef7b..4aafb488c3fc2f1196e67b58c20b7998684a5126 100644 (file)
@@ -5,5 +5,4 @@ dss.lsg.*
 dss
 dss.1
 dss.1.html
-dss.png
 index.html
index 2d0a6bb64e6a4094081b6efc9779fcfc1156a153..ef00f50cffdec1fdf36b24f8fa0f4b5f0adb8035 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -38,9 +38,6 @@ dss: $(dss_objects)
 %.o: %.c Makefile
        $(CC) -c $(DSS_CPPFLAGS) $(CPPFLAGS) $(DSS_CFLAGS) $(CFLAGS) $<
 
-dss.png: mklogo
-       ./mklogo > $@
-
 %.lsg.h: %.suite
        lopsubgen --gen-h=$@ < $<
 %.lsg.c: %.suite
@@ -52,7 +49,7 @@ dss.png: mklogo
        groff -m man -Thtml -P -l -P -r $< | sed -e '1,/^<body>/d; /^<\/body>/,$$d' > $@
 
 clean:
-       rm -f *.o dss dss.1 dss.1.html Makefile.deps *.png *~ index.html dss.lsg.h dss.lsg.c
+       rm -f *.o dss dss.1 dss.1.html Makefile.deps *~ index.html dss.lsg.h dss.lsg.c
 
 ifneq ($(findstring strip, $(MAKECMDGOALS)),)
        strip_option := -s
index 709785b437041654e3cacd2fd4f252aea8fa4173..ad73061c14ec5916284f2ab67438306d6484827d 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -60,7 +60,6 @@ int daemon_init(void)
        /* become session leader */
        if (setsid() < 0)
                goto err;
-       umask(0);
        null = open("/dev/null", O_RDWR);
        if (null < 0)
                goto err;
diff --git a/dss.c b/dss.c
index 4396e6e5975c79d2806aa39625fea99d23a2ee90..f61f33597d7863e236a804d6c0541934e6ced8d5 100644 (file)
--- a/dss.c
+++ b/dss.c
@@ -1458,7 +1458,7 @@ static void create_rsync_argv(char ***argv, int64_t *num)
                                        OPT_STRING_VAL(DSS, REMOTE_USER) : logname,
                                OPT_STRING_VAL(DSS, REMOTE_HOST),
                                lls_string_val(j, OPT_RESULT(DSS, SOURCE_DIR)),
-                               N == 1? "/" : ""
+                               OPT_GIVEN(DSS, SOURCE_DIR) == 1? "/" : ""
                        );
                }
        }
@@ -1581,7 +1581,7 @@ static void exit_hook(int exit_code)
 {
        pid_t pid;
        char **argv, *tmp = dss_strdup(OPT_STRING_VAL(DSS, EXIT_HOOK));
-       unsigned n = split_args(tmp, &argv, " \t");
+       unsigned n = split_args(tmp, &argv);
 
        n++;
        argv = dss_realloc(argv, (n + 1) * sizeof(char *));
diff --git a/dss.svg b/dss.svg
new file mode 100644 (file)
index 0000000..fb69bd7
--- /dev/null
+++ b/dss.svg
@@ -0,0 +1,65 @@
+<svg
+       xmlns="http://www.w3.org/2000/svg"
+       xmlns:xlink="http://www.w3.org/1999/xlink"
+       width="154"
+       height="100"
+>
+       <defs>
+               <rect id="rect"
+                       stroke-width="0"
+                       x="0"
+                       y="0"
+                       width="37"
+                       height="94"
+               />
+       </defs>
+       <defs>
+               <circle id="circle"
+                       stroke-width="1"
+                       stroke="black"
+                       fill="#a22"
+                       cx="0"
+                       cy="0"
+                       r="4"
+               />
+       </defs>
+       <marker
+               id="arrow"
+               stroke="white"
+               fill="white"
+               viewBox="0 0 10 10" refX="5" refY="5"
+               markerWidth="4" markerHeight="4"
+               orient="auto-start-reverse">
+               <path d="M 0 0 L 10 5 L 0 10 z" />
+       </marker>
+       <use fill="#bbf" xlink:href="#rect" transform="translate(0, 0)"/>
+       <use fill="#99f" xlink:href="#rect" transform="translate(36, 0)"/>
+       <use fill="#44f" xlink:href="#rect" transform="translate(72, 0)"/>
+       <use fill="#11f" xlink:href="#rect" transform="translate(108, 0)"/>
+
+       <text x="47" y="40" stroke="white" fill="white" font-size="25">DSS</text>
+
+       <line
+               x1="7" y1="50" x2="127" y2="50" stroke-width="3"
+               stroke="white"
+               marker-end="url(#arrow)"
+       />
+       <use xlink:href="#circle" x="18" y="77"/>
+
+       <use xlink:href="#circle" x="48" y="77"/>
+       <use xlink:href="#circle" x="60" y="77"/>
+
+       <use xlink:href="#circle" x="77" y="77"/>
+       <use xlink:href="#circle" x="86" y="77"/>
+       <use xlink:href="#circle" x="95" y="77"/>
+       <use xlink:href="#circle" x="104" y="77"/>
+
+       <use xlink:href="#circle" x="113" y="70"/>
+       <use xlink:href="#circle" x="122" y="70"/>
+       <use xlink:href="#circle" x="131" y="70"/>
+       <use xlink:href="#circle" x="140" y="70"/>
+       <use xlink:href="#circle" x="114" y="85"/>
+       <use xlink:href="#circle" x="122" y="85"/>
+       <use xlink:href="#circle" x="130" y="85"/>
+       <use xlink:href="#circle" x="138" y="85"/>
+</svg>
diff --git a/exec.c b/exec.c
index 9e0565dc5e08cd0905fd70de01ca0c9b8a100a0e..ece7ec29aa233051cf10bd5c4f3b1b6adfd14cfe 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -56,7 +56,7 @@ void dss_exec_cmdline_pid(pid_t *pid, const char *cmdline)
 {
        char **argv, *tmp = dss_strdup(cmdline);
 
-       split_args(tmp, &argv, " \t");
+       split_args(tmp, &argv);
        dss_exec(pid, argv[0], argv);
        free(argv);
        free(tmp);
index 42606cabd91b2e80a41a3c959ac4b683a53f5753..b505761997987f74dfe6a9d2fe73046e21a0e868 100644 (file)
@@ -12,7 +12,7 @@
        <table>
                <tr>
                        <td>
-                               <IMG SRC="dss.png" alt="dss">
+                               <img src="dss.svg" alt="dss">
                        </td>
                        <td>
                                <h1>The dyadic snapshot scheduler</h1>
diff --git a/mklogo b/mklogo
deleted file mode 100755 (executable)
index d4705ba..0000000
--- a/mklogo
+++ /dev/null
@@ -1,101 +0,0 @@
-#!/bin/bash
-# SPDX-License-Identifier: GPL-2.0
-
-# Script for Image Magick that writes the dss logo in png format
-# to stdout.
-
-set -u
-
-width=320
-height=110
-border=5
-radius1=4
-radius2=5
-circle_y=90
-arrow_y=70
-text_x=128
-text_y=55
-pointsize=36
-
-declare -a circle arrow rectangle text
-
-make_circles()
-{
-       local inner='stroke black fill red circle'
-       local outer='stroke black fill black circle'
-       local num=1
-       local idx=0
-       local y=$circle_y
-       local step x0 i j idx num
-
-       for ((i = 0; i < 4; i++)); do
-               step=$(((width / 4 + num) / (num + 1)))
-               x0=$((border + width / 4 * i))
-               for ((j = 1; j <= $num; j++)); do
-                       x=$((x0 + j * $step))
-                       circle[$idx]='-draw'; let idx++
-                       circle[$idx]="$outer $x,$y,$((x + radius2)),$y"; let idx++
-                       circle[$idx]='-draw'; let idx++
-                       circle[$idx]="$inner $x,$y,$((x + radius1)),$y"; let idx++
-               done
-               num=$((num * 2))
-       done
-       #echo "${circle[@]}"; exit 0
-}
-
-make_arrow()
-{
-       local arrow_head='l -15,-5  +5,+5  -5,+5  +15,-5 z'
-       local idx=0
-       local x0 x1 y
-
-       arrow[$idx]='-draw'; let idx++
-       x0=$((3 * border)); x1=$((width - 2 * border))
-       y=$arrow_y
-       arrow[$idx]="stroke white line $x0,$y $x1,$y"; let idx++
-       arrow[$idx]='-draw'; let idx++
-       x0=$((width - 2 * border))
-       arrow[$idx]="stroke white fill white path 'M $x0,$y $arrow_head'"
-       #echo "${arrow[@]}"; exit 0
-}
-
-make_rectangles()
-{
-       local idx=0
-       local x x0 x1 y y0 y1 i red_green color
-
-       rectangle[$idx]='-draw'; let idx++
-       x=$((width + 2 * border))
-       y=$((height + 2 * border))
-       rectangle[$idx]="stroke yellow fill yellow rectangle 0,0 $x,$y"; let idx++
-       for ((i = 0; i < 4; i++)); do
-               rectangle[$idx]='-draw'; let idx++
-               red_green="$(printf '%02x' $(((3 - i) * 60)))"
-               color="#${red_green}${red_green}ff"
-               x0=$((border + i * width / 4)); x1=$((x0 + width / 4 - 1))
-               y0=$border; y1=$((y0 + height))
-               rectangle[$idx]="stroke $color fill $color rectangle $x0,$y0 $x1,$y1"
-               let idx++
-       done
-       #echo "${rectangle[@]}"; exit 0
-}
-
-make_text()
-{
-       text=(-pointsize $pointsize -draw \
-               "fill white text $text_x,$text_y DSS")
-       #echo "${text[@]}"; exit 0
-}
-
-make_rectangles
-make_arrow
-make_circles
-make_text
-
-convert -size $((width + 2 * border))x$((height + 2 * border)) \
-       -background none xc: \
-       "${rectangle[@]}" \
-       "${arrow[@]}" \
-       "${circle[@]}" \
-       "${text[@]}" \
-       png:-
diff --git a/str.c b/str.c
index 623def1fd9b7aa7ee72f221aa6759fcf74b70948..13776300d6ca1aa62479df6be4428a5ba8d836a0 100644 (file)
--- a/str.c
+++ b/str.c
@@ -212,20 +212,21 @@ __must_check __malloc char *dss_logname(void)
  *
  * \param args The string to be split.
  * \param argv_ptr Pointer to the list of substrings.
- * \param delim Delimiter.
  *
- * This function modifies \a args by replacing each occurrence of \a delim by
- * zero. A \p NULL-terminated array of pointers to char* is allocated dynamically
- * and these pointers are initialized to point to the broken-up substrings
- * within \a args. A pointer to this array is returned via \a argv_ptr.
+ * This function modifies the string given by the first argument by replacing
+ * all occurrences of space and '\t' characters by '\0'. A NULL-terminated
+ * array of pointers to char * is allocated dynamically, and these pointers are
+ * initialized to point to the broken-up substrings.  A pointer to this array
+ * is returned via the last argument.
  *
- * \return The number of substrings found in \a args.
+ * \return The number of substrings found.
  */
-unsigned split_args(char *args, char *** const argv_ptr, const char *delim)
+unsigned split_args(char *args, char *** const argv_ptr)
 {
        char *p;
        char **argv;
        size_t n = 0, i, j;
+       const char delim[] = " \t";
 
        p = args + strspn(args, delim);
        for (;;) {
diff --git a/str.h b/str.h
index b7f26350ccb5941ced169d6b893ff18b38fcaee1..7b121efb00d1e19c5b92e1711b25c23cd29a8092 100644 (file)
--- a/str.h
+++ b/str.h
@@ -8,7 +8,7 @@ __must_check __malloc char *dss_strdup(const char *s);
 __must_check __malloc char *get_homedir(void);
 int dss_atoi64(const char *str, int64_t *value);
 __must_check __malloc char *dss_logname(void);
-unsigned split_args(char *args, char *** const argv_ptr, const char *delim);
+unsigned split_args(char *args, char *** const argv_ptr);
 
 
 /** \cond LLONG_MAX and LLONG_LIN might not be defined. */