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 67ef0ad
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 10 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.
$info = $mp->getInfo();
$mngr = Backend\Manager::getInstance();
$backend = $mngr->getBackendById($deviceFile);
return $backend->getImpl($deviceFile);
$backend = $mngr->getBackendByType($info['fstype']);
return $backend->getImpl($info['source']);
}
}
Expand Up @@ -201,16 +201,27 @@ class MountPoint {
* directory, e.g. '/dev/vda1'.
*/
public function getDeviceFile() {
$info = $this->getInfo();
return $info['source'];
}

/**
* Get various information about the mount point, e.g. 'target',
* 'source', 'fstype', 'label', 'uuid', 'size', 'avail', 'used',
* 'maj:min' or 'options'.
* @return Returns an object containing the file system information.
*/
public function getInfo() {
$cmdArgs = [];
$cmdArgs[] = "--first-only";
$cmdArgs[] = "--noheadings";
$cmdArgs[] = "--output=SOURCE";
$cmdArgs[] = "--raw";
$cmdArgs[] = "--output-all";
$cmdArgs[] = "--json";
$cmdArgs[] = escapeshellarg($this->getPath());
$cmd = new \OMV\System\Process("findmnt", $cmdArgs);
$cmd->setRedirect2to1();
$cmd->execute($output);
return trim($output[0]);
$output = json_decode_safe(implode($output, ""), TRUE);
return $output['filesystems'][0];
}

/**
Expand Down

0 comments on commit 67ef0ad

Please sign in to comment.