diff --git a/cmd/atomfs/mount.go b/cmd/atomfs/mount.go index eada06c..5b272c3 100644 --- a/cmd/atomfs/mount.go +++ b/cmd/atomfs/mount.go @@ -21,8 +21,8 @@ var mountCmd = cli.Command{ Action: doMount, Flags: []cli.Flag{ cli.StringFlag{ - Name: "persist, upper, upperdir", - Usage: "Specify a directory to use as writeable overlay (implies --writeable)", + Name: "persist", + Usage: "Specify a directory to use for the workdir and upperdir of a writeable overlay (implies --writeable)", }, cli.BoolFlag{ Name: "writeable, writable", diff --git a/molecule.go b/molecule.go index fd5e9f5..267309b 100644 --- a/molecule.go +++ b/molecule.go @@ -242,18 +242,20 @@ func (m Molecule) Mount(dest string) error { return err } - workdir := filepath.Join(metadir, "work") - if err := EnsureDir(workdir); err != nil { - return errors.Wrapf(err, "failed to ensure workdir") + persistMetaPath := m.config.WriteableOverlayPath + if persistMetaPath == "" { + // no configured path, use metadir + persistMetaPath = metadir } - upperdir := m.config.WriteableOverlayPath - if upperdir == "" { - upperdir = filepath.Join(metadir, "persist") + workdir := filepath.Join(persistMetaPath, "work") + if err := EnsureDir(workdir); err != nil { + return errors.Wrapf(err, "failed to ensure workdir %q", workdir) } + upperdir := filepath.Join(persistMetaPath, "persist") if err := EnsureDir(upperdir); err != nil { - return errors.Wrapf(err, "failed to ensure upperdir") + return errors.Wrapf(err, "failed to ensure upperdir %q", upperdir) } defer func() { diff --git a/test/priv-mount.bats b/test/priv-mount.bats index 6b7743e..dc8c4f8 100644 --- a/test/priv-mount.bats +++ b/test/priv-mount.bats @@ -92,7 +92,7 @@ function setup() { } @test "mount with writeable overlay in separate dir" { - export PERSIST_DIR=${BATS_TEST_TMPDIR}/upperdir + export PERSIST_DIR=${BATS_TEST_TMPDIR}/persist-dir mkdir -p $PERSIST_DIR run atomfs --debug mount --persist=${PERSIST_DIR} ${BATS_SUITE_TMPDIR}/oci:test-squashfs $MP assert_success @@ -104,9 +104,9 @@ function setup() { run cp $MP/1.README.md $MP/3.README.md assert_success - assert_file_exists $PERSIST_DIR/this-time-let-me - assert_file_exists $PERSIST_DIR/3.README.md - assert_file_not_exists $PERSIST_DIR/1.README.md + assert_file_exists $PERSIST_DIR/persist/this-time-let-me + assert_file_exists $PERSIST_DIR/persist/3.README.md + assert_file_not_exists $PERSIST_DIR/persist/1.README.md run atomfs --debug umount $MP assert_success @@ -117,6 +117,6 @@ function setup() { assert [ -z $( ls -A $ATOMFS_TEST_RUN_DIR/meta/$MY_MNTNSNAME/) ] # but persist dir should still be there: - assert_file_exists $PERSIST_DIR/this-time-let-me - assert_file_exists $PERSIST_DIR/3.README.md + assert_file_exists $PERSIST_DIR/persist/this-time-let-me + assert_file_exists $PERSIST_DIR/persist/3.README.md } diff --git a/test/unpriv-guestmount.bats b/test/unpriv-guestmount.bats index 20b40c7..3000819 100644 --- a/test/unpriv-guestmount.bats +++ b/test/unpriv-guestmount.bats @@ -20,7 +20,7 @@ function setup() { lxc-usernsexec -s <