diff --git a/src/mounts.js b/src/mounts.js index 46fb1e72e..779bf9b22 100644 --- a/src/mounts.js +++ b/src/mounts.js @@ -116,7 +116,8 @@ async function getStatus(mountType, hostPath) { assert.strictEqual(typeof hostPath, 'string'); if (mountType === 'noop' || mountType === 'mountpoint') { // noop is from volume provider and mountpoint is from backup provider - if (safe.child_process.execSync(`mountpoint -q -- ${hostPath}`, { encoding: 'utf8' })) { + safe.child_process.execSync(`mountpoint -q -- ${hostPath}`, { encoding: 'utf8' }); + if (!safe.error) { return { state: 'active', message: 'Mounted' }; } else { return { state: 'inactive', message: 'Not mounted' }; diff --git a/src/storage/filesystem.js b/src/storage/filesystem.js index d95bc8799..5d5d414e0 100644 --- a/src/storage/filesystem.js +++ b/src/storage/filesystem.js @@ -75,7 +75,6 @@ function checkPreconditions(apiConfig, dataLayout, callback) { debug(`checkPreconditions: ${used} bytes`); df.file(getBackupPath(apiConfig)).then(function (result) { - // Check filesystem is mounted so we don't write into the actual folder on disk if (apiConfig.provider === PROVIDER_SSHFS || apiConfig.provider === PROVIDER_CIFS || apiConfig.provider === PROVIDER_NFS || apiConfig.provider === PROVIDER_EXT4) { if (result.mountpoint !== apiConfig.mountPoint) return callback(new BoxError(BoxError.FS_ERROR, `${apiConfig.mountPoint} is not mounted`)); @@ -284,6 +283,11 @@ function testConfig(apiConfig, callback) { } } + if (apiConfig.provider === PROVIDER_MOUNTPOINT) { + safe.child_process.execSync(`mountpoint -q -- ${apiConfig.mountPoint}`, { encoding: 'utf8' }); + if (safe.error) return callback(new BoxError(BoxError.BAD_FIELD, `${apiConfig.mountPoint} is not mounted`, { field: 'mountPoint' })); + } + const backupPath = getBackupPath(apiConfig); const field = apiConfig.provider === PROVIDER_FILESYSTEM ? 'backupFolder' : 'mountPoint';