X-Git-Url: http://git.tuebingen.mpg.de/dss.git/log?a=blobdiff_plain;f=dss.c;h=3d234ffb68851ddbb7996df59a8bdd31eb97c529;hb=31b7424d5b47509ed22667ca2ee31a5590664606;hp=3e626ab0113b1890277da115ea6c735dbdb690d7;hpb=3e8d431fb78e95c0d595b6e7e37ff248c0fa4edd;p=dss.git diff --git a/dss.c b/dss.c index 3e626ab..3d234ff 100644 --- a/dss.c +++ b/dss.c @@ -1053,17 +1053,36 @@ static int handle_sigchld(void) return -E_BUG; } +/* 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); + struct stat dot, dotdot; 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)