]> git.tuebingen.mpg.de Git - dss.git/commitdiff
Merge branch 'refs/heads/t/mountpoint'
authorAndre Noll <maan@tuebingen.mpg.de>
Wed, 15 Nov 2017 18:09:06 +0000 (19:09 +0100)
committerAndre Noll <maan@tuebingen.mpg.de>
Wed, 15 Nov 2017 18:09:53 +0000 (19:09 +0100)
A new main option which aborts dss if the destination file system is
not mounted.

Cooking for two weeks.

* refs/heads/t/mountpoint:
  New option: --mountpoint.

1  2 
NEWS
dss.c
dss.suite

diff --cc NEWS
index fc80e8e6535045fc321b2e9be932b8f224177337,755cad21834cc7b6d150746e6555544d706802c6..75fe3a2bd5eda8353f9bb4f42b9e62fcbf6e5ff7
--- 1/NEWS
--- 2/NEWS
+++ b/NEWS
@@@ -11,9 -11,6 +11,12 @@@ x.y.z (to be announced
   lopsub must be installed to compile this package. Also help2man is
   no longer required since lopsub has built-in roff support.
  
 + - New subcommand "configtest" to check the command line options and
 + the configuration file for syntactic correctness.
 +
++ - New option: --mountpoint. If this option is given, dss aborts if
++ no file system is mounted on the destination directory.
++
   - "make install" will install the executable and the man page.
  
   - In run mode, dss no longer exits successfully if another instance
diff --cc dss.c
index 6353fbe79df9b7b38f92d6e6c6fba1fa80399f5b,3d234ffb68851ddbb7996df59a8bdd31eb97c529..bd9e577e3f6a6df2b94c6f48dddb9ffdeff96d39
--- 1/dss.c
--- 2/dss.c
+++ b/dss.c
@@@ -1064,16 -1058,34 +1065,34 @@@ 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)
 +static int check_config(void)
  {
        int ret;
        uint32_t unit_interval = OPT_UINT32_VAL(DSS, UNIT_INTERVAL);
diff --cc dss.suite
Simple merge