| Commit message (Collapse) | Author | Age |
| ... | |
| | | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
We needed two sets of flags for gengetopt because the C code generated
by gengetopt would not compile cleanly with our rather strict set of
flags. With lopsub this is no longer necessary.
Moreover, it is considered good practice to not set CFLAGS at all but
to append the contents of this variable to the compile command. This
way the user may set the variable to override some of the options.
This commit gets rid of CFLAGS in favor of DSS_CFLAGS, which is just
the union of the CFLAGS and the DEBUG_CFLAGS variables we had before.
|
| | | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
It is considered good practice to run rsync with --checksum from time
to time. This patch implements the feature via the new --checksum
option.
The probabilistic approach was chosen so that dss does not need to
remember which snapshots were created with --checksum.
|
| | | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
In run mode, if the destination directory does not exist, dss prints
"No such file or directory" and exits, without telling the user (a)
it was a failed chdir(2) call that caused the error, and (b) the name
of the directory. This patch adds an error message containing this
information.
Since there is only one caller of dss_chdir(), let's get rid
of this public function in file.c and call chdir() directly from
change_to_dest_dir() of dss.c.
|
| | | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
The current error message, "child terminated unexpectedly", is not
very comprehensive.
The most likely reason for the child to terminate is that it could not
obtain the semaphore lock because another dss process is running. This
commit adds a test to com_run() that check this condition in the
parent before the child process is born. This way, if another process
is holding the lock, we can fail with a nice error message that also
includes the pid of the process that holds the lock.
|
| | | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
In daemon mode, we must acquire the semaphore lock in the child process
because the child does not inherit semaphore adjustments. Currently
the parent exits successfully after the fork, so the command appears
to succeed even if the child dies immediately because it was unable
to acquire the lock because another dss process is holding the lock.
This commit introduces a mechanism which enables the parent to tell
whether the child completed its setup successfully. We create a
pipe prior to calling fork(2), and let the child write to one end
of the pipe after setup is complete and just before it enters the
main select loop. The parent reads from the other end of the pipe
and exits once the read(2) call returns. If the child dies early,
read(2) returns zero, indicating failure.
|
| | | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
It has always been a bit clumsy to copy the executable and the
manual page to their proper locations by hand, so this commit adds
the two standard targets "install" and "install-strip" which install
both files.
The installation prefix defaults to /usr/local and can be set with
PREFIX. Moreover, there is DESTDIR which may be given to prepend
another directory (useful for for "staged installs", where the
installed files are not placed directly into their expected location
but are instead copied into a temporary location).
|
| | | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
This commit ditches gengetopt for the command line and config file
parsers in favor of the lopsub library. Hence from now on, lopsub
must be installed in order to compile dss while gengetopt is no
longer needed.
The mutually exclusive gengetopt group options --create, --prune, --ls,
--run, --kill and --reload are replaced by lopsub subcommands. However,
the --reload and --kill options have been combined to the new "kill"
subcommand which allows to send arbitrary signals to a running dss
process.
Due to the conversion, the syntax of the dss command changes
slightly. For example,
dss --run
becomes
dss run
while
dss -Rdc foo
needs to be spelled as
dss -c foo -- run -d
so that -d is regarded as an option to the "run" subcommand rather
than an option to dss.
With lopsub each subcommand has its own command line and config file
parser. Options to subcommands can be added to the configuration file
like this:
[run]
daemon
logfile=/var/log/dss.log
As for the implementation, the bulk of the changes is the conversion
of dss.ggo to the new dss.suite. The necessary adjustments to the
code are relatively simple. In particular, only dss.c needs to be
changed while all other .c files don't require any modifications.
The examples in INSTALL are adjusted to the new syntax. The commit also
drops support for Mac OS and Solaris, since lopsub is not supported
on these platforms yet.
|
| | |/
| |
| |
| |
| |
| | |
There is no real reason for this option. Resuming a previously
cancelled snapshot is generally a very good idea, so the option is
kind of pointless. Remove it.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| | |
| |
| |
| |
| |
| |
| | |
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.
|
| | |
| |
| |
| |
| | |
The former function is only called by the latter, and both are short,
so let's combine them.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |/
|
|
|
|
|
|
|
|
|
|
| |
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().
|
| |
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
| |
This avoids
dss.c:1519:32: warning: declaration of 'params' shadows a previous local [-Wshadow]
The warning is harmless, though.
|
| |
|
|
|
|
| |
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.
|
| |
|
|
|
| |
The function only reads from the location pointed at by the config_file
variable.
|
| |
|
|
|
| |
In the error case do_semop() already returns the error code which
corresponds to errno.
|
| |
|
|
|
|
|
|
| |
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".
|
| |
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
| |
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..
|
| |
|
|
|
| |
This is pointless because we immediately cd back into the destination
dir anyway.
|
| |
|
|
|
|
| |
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.
|
| |
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
| |
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.
|
| |\
| |
| |
| |
| |
| |
| | |
started 6 weeks ago, cooking for two weeks.
* refs/heads/t/shadow-fix:
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.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |/
|
|
|
|
|
|
|
|
|
|
| |
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).
|
| |
|
|
|
|
|
|
|
|
|
|
|
| |
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().
|
| |
|
|
| |
Clear case of "stating the obvious".
|
| |
|
|
|
| |
Due to the previous patch, this is only executed if we have too many
snapshot anyway.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
| |
This adds a comment which explains the conditions that must be
satisfied to get to this point in the function.
|
| |
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
|
|
|
| |
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.
|
| |
|
|
|
|
| |
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.
|
| |
|
|
|
|
|
|
|
| |
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.
|
| | |
|
| |\
| |
| |
| | |
A single commit that was cooking for over a month.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |\ \ |
|
| | | |
| | |
| | |
| | |
| | |
| | |
| | | |
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.
|
| |/ /
| |
| |
| |
| |
| |
| | |
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.
|
| | |
| |
| |
| |
| |
| | |
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.
|
| |\ \
| |/
|/|
| |
| |
| |
| |
| | |
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.
|
| | |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| | | |
|
| | |
| |
| |
| |
| | |
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.
|
| | |
| |
| |
| |
| | |
It has only one user, make_message(), so it's simpler to include the
code there.
|