summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
3e8d431)
The new option applies to run, create, ls and prune. The feature
could be implemented as a pre-create hook, but since it is so common,
it makes sense to add it to dss proper.
As for the implementation we simply check that "." and ".." are on
different devices (or are identical).
+/* also checks if . is a mountpoint, if --mountpoint was given */
static int change_to_dest_dir(void)
{
int ret;
const char *dd = OPT_STRING_VAL(DSS, DEST_DIR);
static int change_to_dest_dir(void)
{
int ret;
const char *dd = OPT_STRING_VAL(DSS, DEST_DIR);
+ struct stat dot, dotdot;
DSS_INFO_LOG(("changing cwd to %s\n", dd));
DSS_INFO_LOG(("changing cwd to %s\n", dd));
- if (chdir(dd) >= 0)
- return 1;
- ret = -ERRNO_TO_DSS_ERROR(errno);
- DSS_ERROR_LOG(("could not change cwd to %s\n", dd));
- return ret;
+ if (chdir(dd) < 0) {
+ ret = -ERRNO_TO_DSS_ERROR(errno);
+ DSS_ERROR_LOG(("could not change cwd to %s\n", dd));
+ return ret;
+ }
+ if (!OPT_GIVEN(DSS, MOUNTPOINT))
+ return 0;
+ if (stat(".", &dot) < 0) {
+ ret = -ERRNO_TO_DSS_ERROR(errno);
+ DSS_ERROR_LOG(("could not stat .\n"));
+ return ret;
+ }
+ if (stat("..", &dotdot) < 0) {
+ ret = -ERRNO_TO_DSS_ERROR(errno);
+ DSS_ERROR_LOG(("could not stat ..\n"));
+ return ret;
+ }
+ if (dot.st_dev == dotdot.st_dev && dot.st_ino != dotdot.st_ino) {
+ DSS_ERROR_LOG(("mountpoint check failed for %s\n", dd));
+ return -E_MOUNTPOINT;
+ }
+ return 1;
}
static int check_config(const struct lls_command *cmd)
}
static int check_config(const struct lls_command *cmd)
This option is mandatory for all subcommands except kill.
[/help]
This option is mandatory for all subcommands except kill.
[/help]
+ [option mountpoint]
+ summary = abort if destination directory is not a mountpoint
+ [help]
+ This option checks whether a file system is mounted on the directory
+ specified as the argument to --dest-dir. Operation proceeds only
+ if this is the case. Otherwise dss exits unsuccessfully without
+ performing any action. Use this option to prevent snapshot creation
+ if the snapshot file system is not mounted.
+
+ This option is silently ignored for subcommands which do not depend
+ on the destination directory.
+ [/help]
[option Rsync-options]
summary = Controlling how rsync is run
flag ignored
[option Rsync-options]
summary = Controlling how rsync is run
flag ignored
DSS_ERROR(INVALID_NUMBER, "invalid number"), \
DSS_ERROR(STRFTIME, "strftime() failed"), \
DSS_ERROR(LOCALTIME, "localtime() failed"), \
DSS_ERROR(INVALID_NUMBER, "invalid number"), \
DSS_ERROR(STRFTIME, "strftime() failed"), \
DSS_ERROR(LOCALTIME, "localtime() failed"), \
+ DSS_ERROR(MOUNTPOINT, "destination directory is no mountpoint"), \
DSS_ERROR(NULL_OPEN, "can not open /dev/null"), \
DSS_ERROR(DUP_PIPE, "exec error: can not create pipe"), \
DSS_ERROR(INVOLUNTARY_EXIT, "unexpected termination cause"), \
DSS_ERROR(NULL_OPEN, "can not open /dev/null"), \
DSS_ERROR(DUP_PIPE, "exec error: can not create pipe"), \
DSS_ERROR(INVOLUNTARY_EXIT, "unexpected termination cause"), \