Skip to content

Commit

Permalink
Use \OMV\System\Filesystem\Backend\Manager::getBackendByType() to get…
Browse files Browse the repository at this point in the history
… the file system implementation. This is necessary to support union file systems.

Fixes: openmediavault#583
Fixes: openmediavault#582
Signed-off-by: Volker Theile <votdev@gmx.de>
  • Loading branch information
votdev committed Feb 3, 2020
1 parent c947963 commit 8065ede
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
Expand Up @@ -885,16 +885,19 @@ class Filesystem extends \OMV\System\BlockDevice
* OMV\System\Filesystem\FilesystemInterface) or NULL on failure.
*/
public static function getImplByMountPoint($dir) {
if (TRUE === empty($dir))
if (TRUE === empty($dir)) {
return NULL;
}
// Exit immediately if the specified directory is no mount point.
$mp = new \OMV\System\MountPoint($dir);
if (FALSE === $mp->isMountPoint())
if (FALSE === $mp->isMountPoint()) {
return NULL;
// Get the device file that is mounted on the given directory.
$deviceFile = $mp->getDeviceFile();
}
// Try to get the backend using the file system type. This has
// to be done especially when using union file systems.
$fsType = $mp->getFsType();
$mngr = Backend\Manager::getInstance();
$backend = $mngr->getBackendById($deviceFile);
$backend = $mngr->getBackendByType($fsType);
return $backend->getImpl($deviceFile);
}
}
Expand Up @@ -213,6 +213,25 @@ class MountPoint {
return trim($output[0]);
}

/**
* Get the type of the file system that is mounted on the given
* directory. Note, the device MUST be mounted.
* @return The type of the file system that is mounted on the
* given directory, e.g. 'ext4' or 'fuse.mergerfs'.
*/
public function getFsType() {
$cmdArgs = [];
$cmdArgs[] = "--first-only";
$cmdArgs[] = "--noheadings";
$cmdArgs[] = "--output=FSTYPE";
$cmdArgs[] = "--raw";
$cmdArgs[] = escapeshellarg($this->getPath());
$cmd = new \OMV\System\Process("findmnt", $cmdArgs);
$cmd->setRedirect2to1();
$cmd->execute($output);
return trim($output[0]);
}

/**
* Get the mountpoint path where the file system should be mounted to.
* Note, this path is OMV specific: /srv/<FSUUID>.
Expand Down

0 comments on commit 8065ede

Please sign in to comment.