dss.git
6 years agoRevert "ipc.c: Use ftok() instead of SuperFastHash."
Andre Noll [Wed, 6 Sep 2017 12:57:28 +0000 (14:57 +0200)]
Revert "ipc.c: Use ftok() instead of SuperFastHash."

This reverts commit c92370affe722f38a85a41d1b5524e4a102b8f4d.

This was not a good idea because ftok(3) hashes, among other
information, the inode number of the file, and this number changes
every time the configuration file is edited.

The revert conflicted slightly to the commit which renamed
get_key_or_die() to get_key() and changed the type of the return
value to key_t, but the conflict was easy to resolve.

6 years agoipc: Improve error diagnostics for kill.
Andre Noll [Sun, 16 Apr 2017 10:48:58 +0000 (12:48 +0200)]
ipc: Improve error diagnostics for kill.

If dss is not running, the kill command prints "No such file or
directory" because the call to semget(2) fails with ENOENT. This
message is a bit misleading, so let's return -E_NOT_RUNNING in this
case instead.

6 years agoipc: Combine mutex_lock() and lock_dss().
Andre Noll [Sun, 16 Apr 2017 10:37:01 +0000 (12:37 +0200)]
ipc: Combine mutex_lock() and lock_dss().

The former function is only called by the latter, and both are short,
so let's combine them.

6 years agoipc: Prefer key_t over int for System V IPC keys.
Andre Noll [Fri, 17 Feb 2017 14:40:58 +0000 (15:40 +0100)]
ipc: Prefer key_t over int for System V IPC keys.

get_key() calls ftok(3), which returns a key_t value. key_t is also
the type which semget(2), the only function which receives the key via
mutex_get(), expects. It's stupid to convert the key_t from ftok(3)
into an int, only to convert it back to key_t later.

This patch changes ipc.c to use key_t everywhere. However, in
mutex_get() we print a log message containing the value of the key,
so the format string must be adjusted accordingly. Unfortunately,
on Linux, key_t is the same as int while on FreeBSD and NetBSD it is
defined as long. To avoid a warning from the compiler we use "%lx"
in the format string and cast the value to long.

6 years agoipc.c: Use ftok() instead of SuperFastHash.
Andre Noll [Fri, 17 Feb 2017 14:29:52 +0000 (15:29 +0100)]
ipc.c: Use ftok() instead of SuperFastHash.

ftok(3) uses the identity of the named file to generate a key_t type
System V IPC key, which is easier than computing the key by hashing
the (resolved) pathname of the config file. This change allows to
get rid of the realpath() and the super_fast_hash() implementation.

If ftok(3) fails, presumably because the underlying call to stat(2)
fails, we now simply return a phony identifier, similar to what we did
before in this case. This eliminates the only possible failure path
in get_key_or_die(), so this function is renamed to get_key().

7 years agodss-0.1.7. v0.1.7
Andre Noll [Sun, 16 Apr 2017 11:43:20 +0000 (13:43 +0200)]
dss-0.1.7.

A couple of fixes and improvements have accumulated over the last
year, so here's dss-0.1.7. Most likely this is going to be the last
0.1.x release.

7 years agoDon't shadow cmdline_parser_params in main().
Andre Noll [Sun, 16 Apr 2017 11:25:10 +0000 (13:25 +0200)]
Don't shadow cmdline_parser_params in main().

This avoids

dss.c:1519:32: warning: declaration of 'params' shadows a previous local [-Wshadow]

The warning is harmless, though.

7 years agoipc.c: Uninline get_key_or_die().
Andre Noll [Fri, 17 Feb 2017 14:36:50 +0000 (15:36 +0100)]
ipc.c: Uninline get_key_or_die().

This function is rather big, so it's not clear whether it should
be inlined or not. Without the inline attribute, that's up to the
compiler to decide.

7 years agoipc.c: Constify parameter of get_key_or_die().
Andre Noll [Fri, 17 Feb 2017 14:15:10 +0000 (15:15 +0100)]
ipc.c: Constify parameter of get_key_or_die().

The function only reads from the location pointed at by the config_file
variable.

7 years agoipc: Fix error code returned by mutex_lock().
Andre Noll [Sun, 16 Apr 2017 10:18:11 +0000 (12:18 +0200)]
ipc: Fix error code returned by mutex_lock().

In the error case do_semop() already returns the error code which
corresponds to errno.

7 years agoImprove log message for snapshot creation.
Andre Noll [Tue, 23 Aug 2016 11:26:25 +0000 (13:26 +0200)]
Improve log message for snapshot creation.

The log message that prints the name of the snapshot which is going to
be recycled is kind of interesting and deserves the "notice" severity.

The "creating new snapshot" message is a bit misleading in case we
decided to recycle a snapshot, so drop the word "new".

7 years agoipc: Simplify mutex_try_lock().
Andre Noll [Fri, 17 Jun 2016 07:18:40 +0000 (09:18 +0200)]
ipc: Simplify mutex_try_lock().

There is no need to actually obtain the lock. A single semaphore
operation will do just fine. With sem_op equal to zero and IPC_NOWAIT
the semop() call returns immediately, and the return value tells
whether the semaphore value was zero.

Rename the (static) function to mutex_is_locked() to indicate that
it performs only read-only operations on the semaphore set.

7 years agoipc: Make pid pointer optional.
Andre Noll [Thu, 16 Jun 2016 21:06:29 +0000 (23:06 +0200)]
ipc: Make pid pointer optional.

This changes get_dss_pid() to handle the case where the caller passed
a NULL pid pointer. Conversely, if pid is not NULL, we now make sure
to initialize the given address in all cases.

The single caller currently never passes NULL, so this change is just
defensive programming, protecting against future users. Be liberal
in what you accept, be strict in what you return..

7 years agodaemon: Do not change to /.
Andre Noll [Tue, 14 Jun 2016 08:40:22 +0000 (10:40 +0200)]
daemon: Do not change to /.

This is pointless because we immediately cd back into the destination
dir anyway.

7 years agobuild: Add two more warning options.
Andre Noll [Tue, 7 Jun 2016 14:23:36 +0000 (16:23 +0200)]
build: Add two more warning options.

Both -Wunused-parameter and -Wshadow were added to gcc long ago. In
particular gcc-4.6.3, which ships with Ubuntu-12.04, supports them. It
should thus be safe to enable both warnings unconditionally.

7 years agodss.c: Add missing inclusion of <stdio.h>.
Andre Noll [Tue, 7 Jun 2016 14:29:38 +0000 (16:29 +0200)]
dss.c: Add missing inclusion of <stdio.h>.

This is required for example for rename(2). Compilation succeeds without
the include only because the gengetopt header includes stdio.h as well and
we happen to include this header before fd.h.

7 years agodss: Make argument of parse_config_file() a boolean.
Andre Noll [Mon, 16 May 2016 12:55:28 +0000 (14:55 +0200)]
dss: Make argument of parse_config_file() a boolean.

It is used as such, so there is no point to have an int here. Also
rename the argument from override to sighup to indicate that we
need to distinguish whether the function is called at startup or
because the dss process received SIGHUP.

7 years agoMerge branch 'refs/heads/t/shadow-fix'
Andre Noll [Sun, 21 Aug 2016 19:10:56 +0000 (21:10 +0200)]
Merge branch 'refs/heads/t/shadow-fix'

started 6 weeks ago, cooking for two weeks.

* refs/heads/t/shadow-fix:
  dss: Do not shadow a global declaration.

7 years agodss: Do not shadow a global declaration.
Andre Noll [Fri, 17 Jun 2016 08:17:28 +0000 (10:17 +0200)]
dss: Do not shadow a global declaration.

num_complete_snapshots is a local variable in
compute_next_snapshot_time(), but also the name of a public function
declared in snap.h, causing a warning on some (old) gcc versions.

This patch avoids the ambiguity and thus the warning by renaming the
variable. It was unusually long anyway.

7 years agoCreate html version of the man page with groff.
Andre Noll [Mon, 20 Jun 2016 14:34:37 +0000 (16:34 +0200)]
Create html version of the man page with groff.

The html post processor of groff can directly create html, which is
expected to be of higher quality than the html generated by man2html. A
brief look at the "official" web site of man2html (as mentioned in the
description of the Ubuntu-14.04 package)

http://users.actrix.gen.nz/michael/vhman2html.html

shows why.

7 years agoConvert INSTALL and NEWS to markdown format.
Andre Noll [Mon, 20 Jun 2016 14:05:31 +0000 (16:05 +0200)]
Convert INSTALL and NEWS to markdown format.

The grutatxt project is dead, so we have to switch to something else
eventually. Fortunately, there are only three files in grutatxt format,
one of which (README) does not need any changes. The other two are
converted to markdown format in this commit. This is a rather simple
matter since only section headings, links and preformatted text need
slight adjustments.

The commands in the Makefile are modified to run markdown(1) instead
of grutatxt(1).

7 years agoFix rsync exit handling in create mode.
Andre Noll [Mon, 13 Jun 2016 15:54:37 +0000 (17:54 +0200)]
Fix rsync exit handling in create mode.

The logic in handle_rsync_exit() is horribly broken in case dss is
run in create mode and the rsync process terminates unsuccessfully.

First we claim to restart rsync, which is wrong. Next we call the
post-create hook despite the documentation says that this hook is
only run on *successful* termination. Finally, we dereference a NULL
pointer to print the path of the snapshot.

Fortunately, all three issues are easy to fix by special casing create
mode in handle_rsync_exit().

7 years agodss.c: Remove pointless comment for main().
Andre Noll [Sat, 11 Jun 2016 13:01:07 +0000 (15:01 +0200)]
dss.c: Remove pointless comment for main().

Clear case of "stating the obvious".

8 years agoRemove orphaned snapshots even if disk space is not low.
Andre Noll [Tue, 29 Dec 2015 15:33:11 +0000 (15:33 +0000)]
Remove orphaned snapshots even if disk space is not low.

Due to the previous patch, this is only executed if we have too many
snapshot anyway.

8 years agoAlways try to keep one snapshot for recycling.
Andre Noll [Tue, 29 Dec 2015 15:28:02 +0000 (15:28 +0000)]
Always try to keep one snapshot for recycling.

Currently, if --keep-redundant is not given, we try to get rid of
outdated and redundant snapshots quickly, even if there is plenty of
free disk space available. However, as these snapshots can be used
for recycling, it seems to be worth to keep them around as long as
there are fewer snapshots available as configured.

This commit changes try_to_free_disk_space() to not remove snapshots
any more in this case. This patch should reduce disk I/O in the common
case where no snapshots need to be removed due to low disk space.

8 years agotry_to_free_disk_space(): Explain what is going on.
Andre Noll [Tue, 29 Dec 2015 15:27:06 +0000 (15:27 +0000)]
try_to_free_disk_space(): Explain what is going on.

This adds a comment which explains the conditions that must be
satisfied to get to this point in the function.

8 years agoAllow to run in daemon mode without log file.
Andre Noll [Tue, 29 Dec 2015 16:10:05 +0000 (16:10 +0000)]
Allow to run in daemon mode without log file.

It's kind of silly to insist in having a log file in daemon mode.

This commit removes the dependency of --daemon on --logfile and makes
/dev/null the default log file. Consequently, running dss --daemon
--run without specifying --logfile no longer fails, and nothing will
be logged by default.

The documentation is updated accordingly.

8 years agoImprove documentation of --keep-redundant.
Andre Noll [Tue, 29 Dec 2015 16:42:18 +0000 (16:42 +0000)]
Improve documentation of --keep-redundant.

The help text for --keep-redundant was rather convoluted. This commit
shortens the text with no essential semantic change.

The patch also removes the sentence that encourages to specify this
option if the destination directory is only used for snapshots. After
all, most file systems allow to create an insane number of files,
so keeping snapshots around forever can result in a file system that
can no longer be checked or repaired due to the excessive number of
used inodes.

8 years agoImprove documentation of interval-related args.
Andre Noll [Tue, 29 Dec 2015 15:52:32 +0000 (15:52 +0000)]
Improve documentation of interval-related args.

Minor rewording of the help text for the --unit-interval option and
a new sentence which explains that the total number of snapshots
doubles if --num-intervals is increased by one.

8 years agoREADME: Explain that there are no incremental backups.
Andre Noll [Wed, 16 Dec 2015 13:52:54 +0000 (14:52 +0100)]
README: Explain that there are no incremental backups.

This was unclear to an admin who had used dss for several years! So
maybe it is a good idea to explain the idea behind hardlink-based
backups a bit more.

This commit adds two new sentences to README, one for the admin and
another one for the user.

8 years agodss-0.1.6. v0.1.6
Andre Noll [Wed, 5 Aug 2015 11:06:10 +0000 (13:06 +0200)]
dss-0.1.6.

8 years agoMerge branch 'refs/heads/t/signal_handler_improvement'
Andre Noll [Wed, 5 Aug 2015 10:52:47 +0000 (12:52 +0200)]
Merge branch 'refs/heads/t/signal_handler_improvement'

A single commit that was cooking for over a month.

8 years agoMerge branch 'refs/heads/t/nullrw'
Andre Noll [Sun, 10 May 2015 11:59:19 +0000 (13:59 +0200)]
Merge branch 'refs/heads/t/nullrw'

9 years agoINSTALL: Reword sentence about gengetopt.
Andre Noll [Fri, 24 Apr 2015 14:42:03 +0000 (16:42 +0200)]
INSTALL: Reword sentence about gengetopt.

The latest version of gengetopt is two years old, so it hardly makes
sense to talk about a "recent version".

Also link to the gengetopt web page rather than to the FTP server.

9 years agodaemon.c: Open /dev/null read-write.
Andre Noll [Mon, 30 Mar 2015 16:20:16 +0000 (16:20 +0000)]
daemon.c: Open /dev/null read-write.

While daemonizing we redirect stdin, stdout and stderr to /dev/null,
which is considered good practice. We should, however, open these
two devices in read-write mode rather than read-only, since not being
able to write to stdout/stderr might confuse rsync and the hooks.

9 years agoNEWS: Fix typo.
Andre Noll [Mon, 23 Mar 2015 13:32:15 +0000 (14:32 +0100)]
NEWS: Fix typo.

This typo was introduced in commit 34653268 (Add NEWS file) years ago,
apparently by pasting the content from the freshmeat web page to the
NEWS file.

9 years agoMerge branch 'refs/heads/t/max-errors'
Andre Noll [Wed, 25 Feb 2015 12:23:56 +0000 (13:23 +0100)]
Merge branch 'refs/heads/t/max-errors'

The topic branch was cooking for about a week, and it was tested with
no problems on several multi-terabyte file systems.

* Rework restart logic, introduce --max-errors.
* Fix typo in help text of --daemon.

9 years agoImprove signal handler.
Andre Noll [Wed, 25 Feb 2015 10:15:33 +0000 (11:15 +0100)]
Improve signal handler.

The signal handler of dss has two issues: (a) it does not check the
return value of the write(2) call, and (b) it does not restore errno
on exit. The second issue might cause problems on systems where
write(2) sets errno also on success. Those problems would be very
hard to reproduce and debug. So it is probably a good idea to be
conservative here.

This commit fixes (a) by printing an error message and calling exit(3)
if the write to the signal pipe failed or resulted in a short write.
As for (b), we now save a copy of errno before the write(2) call,
and restore the old value on success.

9 years agoRework restart logic, introduce --max-errors.
Andre Noll [Fri, 12 Dec 2014 14:05:21 +0000 (15:05 +0100)]
Rework restart logic, introduce --max-errors.

It has happened several times in the past that dss made no progress
because the underlying rsync command terminates with exit code 13
(Errors with program diagnostics). Currently dss special cases this
exit code as a non-fatal error, i.e. it does not terminate but restarts
the rsync command after 60 seconds. If the problem is permanent,
no new snapshots will be created, but the exit hook is not called
either, which is unfortunate.

This commit tries to improve on this. With this patch applied, the
only non-fatal exit code from rsync is 24 (Partial transfer due
to vanished source files), which is actually considered success.
All other non-zero exit codes cause dss to restart the rsync command,
but only at most N times, where N is the argument given to the new
--max-rsync-errors option.

9 years agoFix typo in help text of --daemon.
Andre Noll [Tue, 27 Jan 2015 09:47:19 +0000 (10:47 +0100)]
Fix typo in help text of --daemon.

9 years agostr.c: Remove vsnprintf() workaround for old glibc.
Andre Noll [Tue, 6 Jan 2015 16:12:33 +0000 (17:12 +0100)]
str.c: Remove vsnprintf() workaround for old glibc.

Since glibc-2.1 was released 16 years ago, the workaround for glibc-2.0
is no longer necessary. Even the example code of printf(3) dropped it.

9 years agostr.c: Get rid of VSPRINTF macro.
Andre Noll [Sat, 3 Jan 2015 16:54:36 +0000 (16:54 +0000)]
str.c: Get rid of VSPRINTF macro.

It has only one user, make_message(), so it's simpler to include the
code there.

9 years agoAssorted typo fixes in comments.
Andre Noll [Sat, 3 Jan 2015 16:34:48 +0000 (16:34 +0000)]
Assorted typo fixes in comments.

9 years agoFix typo in documentation of --logfile.
Andre Noll [Sat, 3 Jan 2015 16:23:55 +0000 (16:23 +0000)]
Fix typo in documentation of --logfile.

9 years agoShut down the signal subsystem on exit.
Andre Noll [Sat, 3 Jan 2015 16:16:02 +0000 (16:16 +0000)]
Shut down the signal subsystem on exit.

No biggy since we exit anyway a few lines later, but still..

9 years agotv.c: Remove unused functions.
Andre Noll [Sat, 3 Jan 2015 16:11:06 +0000 (16:11 +0000)]
tv.c: Remove unused functions.

Quite a few public functions of tv.c are not used anywhere in dss,
so let's get rid of them. We can easily add them back in case they
are neeed in the future.

Found by cppcheck.

9 years agostr.c: Remove pointless initialization.
Andre Noll [Sat, 3 Jan 2015 16:08:00 +0000 (16:08 +0000)]
str.c: Remove pointless initialization.

The variable p is initialized to a different value a few lines later
and the value set in the definition is not used in between.

Found by cppcheck.

9 years agoRemove non-functional SEE ALSO links from index.html.
Andre Noll [Sat, 3 Jan 2015 16:05:58 +0000 (16:05 +0000)]
Remove non-functional SEE ALSO links from index.html.

It's nice to have references to ssh and rsync in the SEE ALSO section
of the man page. On the web page, however, they do not add much value
since the links generated by man2html do not work. This patch omits
the broken links.

9 years agoNEWS update
Andre Noll [Tue, 6 Jan 2015 19:54:55 +0000 (20:54 +0100)]
NEWS update

9 years agoChange background color of web pages to white.
Andre Noll [Mon, 18 Aug 2014 12:01:34 +0000 (14:01 +0200)]
Change background color of web pages to white.

The old colors looked a little like the 90s ;)

9 years agoMerge branch 'refs/heads/t/min-complete'
Andre Noll [Fri, 12 Dec 2014 13:21:53 +0000 (14:21 +0100)]
Merge branch 'refs/heads/t/min-complete'

9 years agoNEWS: Fix indentation of 0.1.5 items.
Andre Noll [Wed, 24 Sep 2014 13:39:41 +0000 (15:39 +0200)]
NEWS: Fix indentation of 0.1.5 items.

The generated html looked terrible. No real changes.

9 years agoindex.html.in: Fix gitweb link.
Andre Noll [Wed, 24 Sep 2014 13:28:39 +0000 (15:28 +0200)]
index.html.in: Fix gitweb link.

Apparently the symlink workaround for the gitweb pages on
git.tuebingen.mpg.de does not work any more although the symlink
dss->dss.git is still in place.

This commit changes the link on the web page to include the .git
suffix.

9 years agoIntroduce --min-complete.
Andre Noll [Tue, 18 Feb 2014 13:16:02 +0000 (14:16 +0100)]
Introduce --min-complete.

Currently dss cowardly refuses to remove the last complete snapshot
even if disk space is low, and fails if there is not enough disk space
left for a second snapshot. However, in some situations it is more
important to have a recent snapshot and to to keep dss up and running.

This commit introduces a new integer option, --min-complete, which
defaults to one to resemble the old behaviour.

If it is set to zero, dss will happily remove the last complete
snapshot, even if it is used as the reference directory for rsync's
--link-dest option. This is dangerous, but it's the only way to keep
dss going.

Conversely, --min-complete may be set to a value greater than one
to guarantee there is always a certain number of complete snapshots
available.

9 years agoChange email address and URLs.
Andre Noll [Sat, 16 Aug 2014 10:00:18 +0000 (12:00 +0200)]
Change email address and URLs.

The web and email service of systemlinux.org was down for two
weeks. Meanwhile the dss web pages found a new home at the MPI campus
of Tübingen.

This commit changes the email addresses and the home page URL.

10 years agoSilence clang warnings.
Andre Noll [Tue, 21 Jan 2014 15:56:37 +0000 (16:56 +0100)]
Silence clang warnings.

The -Wno-sign-compare option is supposed to not print the noisy
warnings for comparisons between signed and unsigned values.
Currently, in DEBUG_CFLAGS this option is followed by -W which causes
clang (but not gcc) to turn on these warnings again. As CFLAGS contains
-Wall, the -W option was redundant anyway, so this patch removes it.

10 years agodss-0.1.5. v0.1.5
Andre Noll [Tue, 14 Jan 2014 14:22:04 +0000 (15:22 +0100)]
dss-0.1.5.

10 years agoMerge branch 't/exit_fix'
Andre Noll [Tue, 14 Jan 2014 14:15:38 +0000 (15:15 +0100)]
Merge branch 't/exit_fix'

Was cooking since 2013-10.

10 years agoMerge branch 't/dia'
Andre Noll [Wed, 16 Oct 2013 12:35:46 +0000 (14:35 +0200)]
Merge branch 't/dia'

The single commit of this branch is more than one year old. I totally
forgot about it, but here it is:

311ec5 Switch logo from skencil to dia.

The web page has been updated to contain the new image.

10 years agoKill children on fatal errors.
Andre Noll [Wed, 16 Oct 2013 12:17:46 +0000 (14:17 +0200)]
Kill children on fatal errors.

If dss is about to die because it received SIGINT or SIGTERM, we first
restart the rsync process by sending SIGCONT, then send SIGTERM to
both the rsync and the rm process to get rid of any child processes.

This works fine, but there are other fatal errors for which we miss
to clean up as thoroughly, most importantly if there is not enough
free disk space for a single snapshot.

This patch moves the signal-related cleanup part to the new function
kill_children(), and changes handle_signal() and com_run() to call
this function right before the exit hook is invoked.

10 years agoTrivial: Remove trailing semicolon.
Andre Noll [Wed, 16 Oct 2013 12:28:23 +0000 (14:28 +0200)]
Trivial: Remove trailing semicolon.

11 years agorsync: Remove hardcoded --quiet option.
Andre Noll [Thu, 20 Dec 2012 13:38:41 +0000 (14:38 +0100)]
rsync: Remove hardcoded --quiet option.

When running in daemon mode, the stdout and stderr stream of dss and
all its child processes are redirected to /dev/null. In particular any
output from the rsync process is discarded. Therefore, whenever a new
snapshot is created, dss currently passes --quiet to the underlying
rsync command, along with --archive and --delete.

However, as was pointed out by Sebastian Schultheiß, if the rsync
command fails for unknown reasons, the --quiet option complicates
debugging for the questionable benefit of saving the I/O for a few
writes to /dev/null.

This patch removes the --quiet option.

11 years agoMerge branch 't/zero-rsync-fix'
Andre Noll [Thu, 20 Dec 2012 13:36:42 +0000 (14:36 +0100)]
Merge branch 't/zero-rsync-fix'

11 years agoReject insane number of intervals.
Andre Noll [Sun, 28 Oct 2012 19:11:16 +0000 (20:11 +0100)]
Reject insane number of intervals.

Nobody needs more than 2^30 snapshots. More importantly, values
larger than 32 for --num_intervals cause an integer overflow in
desired_number_of_snapshots() because the number of snapshots in
interval zero does not fit in an unsigned int in this case.

This patch adds a test to check_config() that rejects values larger
than 30 for the --num_intervals option.

Many thanks to Klaus Kopec for pointing out this bug.

11 years agoDon't create two snapshots in the same second.
Andre Noll [Mon, 1 Oct 2012 17:10:02 +0000 (19:10 +0200)]
Don't create two snapshots in the same second.

This can only happen if all of the follwing are true:

(a) source and destination directories are small
(b) rsync completes successfully within one second
(c) At most two snapshots are missing

In this case the rename() call which changes the snapshot name from
*-incomplete to the proper name fails for the second snapshot with
EEXIST. This is because the previous snapshot name coincides with
the name of the second snapshot.

The fix is a bit ugly but also non-invasive and simple: Just sleep
one second in this case.

11 years agoMerge branch 't/rename_system_files'
Andre Noll [Sun, 16 Sep 2012 11:34:07 +0000 (13:34 +0200)]
Merge branch 't/rename_system_files'

Has been cooking for several weeks. The conflicts

daemon.c
exec.c
file.c
ipc.c
sig.c

are trivial and can be resolved easily.

11 years agoSwitch logo from skencil to dia.
Andre Noll [Wed, 8 Aug 2012 19:47:56 +0000 (21:47 +0200)]
Switch logo from skencil to dia.

The sketch/skencil project appears to be inactive for years, and
it is no longer shipped on recent Linux distributions. This commit
replaces the sketch source file dss.sk by dss.dia, a source file for
dia, an GTK+ based diagram creation program. The new logo looks very
similar to the old one but was created from scratch.

dia allows to convert a .dia file to PNG image data. This patch also
adjusts the Makefile to produce the dss.png logo from dss.dia.

11 years agoRename source files which also exist as system headers.
Andre Noll [Sat, 11 Aug 2012 18:32:19 +0000 (20:32 +0200)]
Rename source files which also exist as system headers.

As pointed out by Daniel Richard G. some of the dss header files
are named the same as system header files.

This patch renames these headers as well as their corresponding .c
files. Specifically, error.h, fd.h, signal.h, string.h and time.h
become err.h, file.h, sig.h, str.h and tv.h.

11 years agoMake the dss log facility C89 conform.
Daniel Richard G [Fri, 10 Aug 2012 12:41:22 +0000 (14:41 +0200)]
Make the dss log facility C89 conform.

Variadic macros were introduced in C99, so they are not supported on
ANSI C compilers. Since currently all DSS_*_LOG macros are variadic,
we need a replacement for these. Moreover, since not all compilers
support __func__ or an equivalent, we need to check for this feature
as well and provide a workaround if necessary.

This patch introduces the new public function dss_log_set_params()
which saves the given log level, filename, line number and the
function name in global variables. The DSS_*_LOG macros are changed
to receive a single argument only, which is the usual variadic list,
enclosed in additional parentheses.

The new DSS_*_LOG macros first set the log parameters by calling
dss_log_set_params(), then call dss_log() with the variadic list as
the argument. dss_log() is patched to print the function name only
if __func__ is supported and fall back to file name and the line
number otherwise.

All DSS_*_LOG() calls are changed to the new syntax.

11 years agoipc.c: Eliminate per-field struct initializations.
Daniel Richard G [Fri, 10 Aug 2012 12:20:57 +0000 (14:20 +0200)]
ipc.c: Eliminate per-field struct initializations.

This replaces the C99-only initializations in mutex_lock() and
mutex_try_lock() by equivalent but portable code.

11 years agoHave foo.c #include foo.h.
Daniel Richard G [Fri, 10 Aug 2012 12:16:22 +0000 (14:16 +0200)]
Have foo.c #include foo.h.

This is both to ensure function signature consistency, and to
eliminate GCC's "no previous declaration for _____" warnings.

11 years agoMark find_oldest_removable_snapshot() as static.
Daniel Richard G [Fri, 10 Aug 2012 12:10:55 +0000 (14:10 +0200)]
Mark find_oldest_removable_snapshot() as static.

It is not used outside the source file in which it is defined.

11 years agoMerge branch 't/gcc-compat_fix'
Andre Noll [Wed, 15 Aug 2012 09:34:48 +0000 (11:34 +0200)]
Merge branch 't/gcc-compat_fix'

* e1f886 Only define gcc function attributes on gcc.

11 years agoMerge branch 't/cleanups'
Andre Noll [Wed, 15 Aug 2012 09:32:10 +0000 (11:32 +0200)]
Merge branch 't/cleanups'

The changes in this branch are an attempt to make dss compile cleanly
with the more strict compiler flags (GCC 4.6 on Linux).

    -pedantic -fno-common -W -Wall -Wcast-align -Wformat=2
    -Wpointer-arith -Wundef -Waggregate-return -Wcast-qual
    -Wmissing-declarations -Wnested-externs -Wstrict-prototypes

This is only a first step that addresses the easier warnings. Some,
like the ones stemming from the variadic macros, have yet to be fixed.

* 9e6c2f Remove some debug messages.
* 899f88 string.c: Fix a statement-before-declaration issue.
* 83ebb4 Remove trailing commas.
* 2ed0d7 snap.h: Fix HSA_ITEM.
* 508350 Fix "comma after last element" warning.
* 97fbf4 compare_snapshots(): Add const keyword.
* b28495 Avoid per-element initializers.
* 9528cf dss.c: Fix initialization of argv[].
* 4526f9 dss.c: Remove redundant const.
* 2183c6 Makefile: Split CPPFLAGS.

Conflicts:
error.h

11 years agoMerge branch 't/ipc'
Andre Noll [Fri, 10 Aug 2012 11:49:54 +0000 (13:49 +0200)]
Merge branch 't/ipc'

4d9f41 mutex_get(): Change parameter from key_t to int.
55c90e Implement --reload.
492928 Add the --kill subcommand.
dd42f7 Use semaphore locking to avoid starting dss multiple times.
17eea8 Introduce get_config_file_name().

That topic was cooking in next for a quite some time now.

11 years agoOnly define gcc function attributes on gcc.
Daniel Richard G [Mon, 6 Aug 2012 18:39:53 +0000 (20:39 +0200)]
Only define gcc function attributes on gcc.

These gcc extensions help the compiler optimize function calls,
but are unavailable if dss is not compiled with gcc.

This patch defines the corresponding macros to empty if __GNUC__
is not defined, or if the gcc version is too old to support the
particular function attribute.

11 years agoRemove some debug messages.
Daniel Richard G [Thu, 2 Aug 2012 18:04:42 +0000 (20:04 +0200)]
Remove some debug messages.

These were only helpful during development and are commented out
for quite some time now. Remove them.

11 years agostring.c: Fix a statement-before-declaration issue.
Daniel Richard G [Thu, 2 Aug 2012 18:00:29 +0000 (20:00 +0200)]
string.c: Fix a statement-before-declaration issue.

11 years agoRemove trailing commas.
Daniel Richard G [Sat, 4 Aug 2012 11:22:53 +0000 (13:22 +0200)]
Remove trailing commas.

11 years agosnap.h: Fix HSA_ITEM.
Daniel Richard G [Sat, 4 Aug 2012 11:22:45 +0000 (13:22 +0200)]
snap.h: Fix HSA_ITEM.

This changes the second definition of HSA_ITEM to avoid C99
subscripted element initializers.

11 years agoFix "comma after last element" warning.
Daniel Richard G [Thu, 2 Aug 2012 17:53:12 +0000 (19:53 +0200)]
Fix "comma after last element" warning.

This changes the definition of DSS_ERRORS so that it includes the commas,
and removes the comma from both definitions of DSS_ERROR. This
avoids "comma after last element" warnings, which on some compilers
produces an error.

11 years agocompare_snapshots(): Add const keyword.
Daniel Richard G [Sat, 4 Aug 2012 11:20:17 +0000 (13:20 +0200)]
compare_snapshots(): Add const keyword.

This fixes a "cast drops const qualifier" warning.

11 years agoAvoid per-element initializers.
Daniel Richard G [Sat, 4 Aug 2012 11:16:20 +0000 (13:16 +0200)]
Avoid per-element initializers.

Per-element struct initializers are not supported in ANSI C. This
construct doesn't gain much in terms of readability, and breaks
compatibility with older/stricter compilers.

11 years agodss.c: Fix initialization of argv[].
Daniel Richard G [Thu, 2 Aug 2012 17:45:38 +0000 (19:45 +0200)]
dss.c: Fix initialization of argv[].

argv[] can't be declared in this way because the initializers are not
computable at compile time. GCC allows this construct, but stricter
compilers don't.

11 years agodss.c: Remove redundant const.
Daniel Richard G [Thu, 2 Aug 2012 17:37:23 +0000 (19:37 +0200)]
dss.c: Remove redundant const.

hook_status_description[] had a redundant const keyword, per GCC.

11 years agoMakefile: Split CPPFLAGS.
Daniel Richard G [Thu, 2 Aug 2012 17:30:46 +0000 (19:30 +0200)]
Makefile: Split CPPFLAGS.

-W*/-O*/-g options belong in CFLAGS, not CPPFLAGS. CPPFLAGS is for
preprocessor-specific (-D*/-I*) options.

11 years agomutex_get(): Change parameter from key_t to int.
Andre Noll [Fri, 3 Aug 2012 08:45:10 +0000 (10:45 +0200)]
mutex_get(): Change parameter from key_t to int.

The two callers obtain the key from get_key_or_die(), which
returns int. So pass an int anyway. This fixes a warning on
NetBSD:

ipc.c:263: warning: format '%x' expects type 'unsigned int', but argument 4 has type 'key_t'

11 years agoerror.h: Remove is_errno().
Andre Noll [Fri, 3 Aug 2012 08:25:11 +0000 (10:25 +0200)]
error.h: Remove is_errno().

This inline function is unused.

11 years agoMerge branch 't/exec_cleanups'
Andre Noll [Fri, 20 Jul 2012 14:05:41 +0000 (16:05 +0200)]
Merge branch 't/exec_cleanups'

06a23c Simplify exec functions.

Was cooking quite long and no problems showed up.

11 years agoImplement --reload.
Andre Noll [Sat, 26 Mar 2011 14:37:06 +0000 (15:37 +0100)]
Implement --reload.

This is literally the same as --kill, the only difference being that
SIGHUP rather than SIGTERM is sent.

11 years agoAdd the --kill subcommand.
Andre Noll [Sat, 13 Nov 2010 19:51:28 +0000 (20:51 +0100)]
Add the --kill subcommand.

It works as follows: Whenever a semaphore operation is performed, the
PID of the process is stored in the sempid field of the semaphore.
This PID can be obtained from a different process by calling semctl
with the GETPID command.

com_kill() first tries to acquire the lock by calling the new
mutex_try_lock() function of ipc.c. In contrast to mutex_lock(),
mutex_try_lock() only operates on the first semaphore in the semaphore
set, leaving the sempid field of the second semaphore unchanged. If
mutex_try_lock() succeeds, no running dss process is holding the lock
and the kill command fails. Otherwise, some dss process is running
whose PID can be obtained by calling semctl() on the second semaphore.

11 years agoUse semaphore locking to avoid starting dss multiple times.
Andre Noll [Sat, 13 Nov 2010 19:31:10 +0000 (20:31 +0100)]
Use semaphore locking to avoid starting dss multiple times.

It's trickier than one might expect but it is hopefully also much
better than any pidfile-based approach.

This patch adds ipc.c and ipc.h containing the public lock_dss()
function which acquires a semaphore-based lock whose key is based
on the hash of the resolved path name of the dss config file. This
allows different instances of dss to coexist.

All semaphore operations are called with both the SEM_UNDO and the
IPC_NOWAIT flag. SEM_UNDO guarantees that no stale lock remains after
dss was killed by SIGKIlL while IPC_NOWAIT makes the call to lock_dss()
fail if another process is already holding the lock.

The prune/create/run commands simply take the lock at startup and
exit if it could not be acquired.

The underlying semaphore set contains two semaphores. This is necessary
to implement the --kill subcommand which is done in a subsequent patch.

11 years agoIntroduce get_config_file_name().
Andre Noll [Sat, 13 Nov 2010 19:21:04 +0000 (20:21 +0100)]
Introduce get_config_file_name().

ATM, the config file name is computed in parse_config(). However, for the ipc
stuff we'll need that information as well, so move the computation to a separate
helper function().

11 years agodoc: Add a second example config file.
Andre Noll [Mon, 30 Apr 2012 19:30:35 +0000 (21:30 +0200)]
doc: Add a second example config file.

This commit provides another example for the INSTALL file. It
illustrates the use of some more sophisticated config options of dss.

Many thanks to Ivo Welch who suggested this change.

12 years agoSimplify exec functions.
Andre Noll [Sat, 18 Jun 2011 12:31:11 +0000 (14:31 +0200)]
Simplify exec functions.

These were copied from elsewhere long ago and are more general
than what is needed for dss.

13 years agoNEWS update.
Andre Noll [Thu, 31 Mar 2011 21:54:37 +0000 (23:54 +0200)]
NEWS update.

13 years agoNEWS update
Andre Noll [Mon, 7 Feb 2011 16:58:58 +0000 (17:58 +0100)]
NEWS update

13 years agoMerge branch 't/recycling'
Andre Noll [Mon, 7 Feb 2011 16:57:40 +0000 (17:57 +0100)]
Merge branch 't/recycling'

13 years agoMerge branch 't/logfile_only_for_daemon'
Andre Noll [Mon, 7 Feb 2011 16:56:36 +0000 (17:56 +0100)]
Merge branch 't/logfile_only_for_daemon'

13 years agoMinor documentation improvements.
Andre Noll [Sun, 14 Nov 2010 11:17:38 +0000 (12:17 +0100)]
Minor documentation improvements.