Skip to content

Commit

Permalink
Issue openmediavault#1731: Display filesystem details (openmediavault…
Browse files Browse the repository at this point in the history
…#1740)

Signed-off-by: Volker Theile <votdev@gmx.de>
  • Loading branch information
votdev committed May 5, 2024
1 parent be87cd9 commit b6d4a27
Show file tree
Hide file tree
Showing 14 changed files with 225 additions and 0 deletions.
1 change: 1 addition & 0 deletions deb/openmediavault/debian/changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
openmediavault (7.1.0-1) stable; urgency=low

* Issue #1731: Display file system details.
* Issue #1736: Add support to create yearly scheduled shared
folder snapshots.
* Issue #1737: Add support for WPA3 authentication for wireless
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,17 @@
}
}
}
},{
"type": "rpc",
"id": "rpc.filesystemmgmt.getdetails",
"params": {
"type": "object",
"properties": {
"devicefile": {
"type": "string",
"format": "devicefile",
"required": true
}
}
}
}]
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class OMVRpcServiceFileSystemMgmt extends \OMV\Rpc\ServiceAbstract {
$this->registerMethod("setMountPoint");
$this->registerMethod("umount");
$this->registerMethod("hasFilesystem");
$this->registerMethod("getDetails");
}

/**
Expand Down Expand Up @@ -953,4 +954,21 @@ class OMVRpcServiceFileSystemMgmt extends \OMV\Rpc\ServiceAbstract {
return (FALSE !== \OMV\System\Filesystem\Filesystem::hasFileSystem(
$params['devicefile']));
}

/**
* Get details about the filesystem, e.g. the health status.
* @param params An array containing the following fields:
* \em devicefile The device file to check.
* @param context The context of the caller.
* @return A string that contains the details about the given device.
*/
public function getDetails($params, $context) {
$this->validateMethodContext($context, [
"role" => OMV_ROLE_ADMINISTRATOR
]);
$this->validateMethodParams($params, "rpc.filesystemmgmt.getdetails");
$fs = \OMV\System\Filesystem\Filesystem::assertGetImpl(
$params['devicefile']);
return $fs->getDetails();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php
/**
* This file is part of OpenMediaVault.
*
* @license http://www.gnu.org/licenses/gpl.html GPL Version 3
* @author Volker Theile <volker.theile@openmediavault.org>
* @copyright Copyright (c) 2009-2024 Volker Theile
*
* OpenMediaVault is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* OpenMediaVault is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with OpenMediaVault. If not, see <http://www.gnu.org/licenses/>.
*/
namespace OMV;

/**
* @ingroup api
*/
class NotSupportedException extends Exception {}
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,44 @@ class Btrfs extends Filesystem {
]);
}

/**
* See parent class definition.
*/
public function getDetails() {
$result = "";

$cmdArgs = [];
$cmdArgs[] = "filesystem";
$cmdArgs[] = "show";
$cmdArgs[] = escapeshellarg($this->getDeviceFile());
$cmd = new \OMV\System\Process("btrfs", $cmdArgs);
$cmd->setRedirect2to1();
$cmd->execute($output);
$result = implode("\n", $output);

$output = [];
$cmdArgs = [];
$cmdArgs[] = "filesystem";
$cmdArgs[] = "df";
$cmdArgs[] = escapeshellarg($this->getMountPoint());
$cmd = new \OMV\System\Process("btrfs", $cmdArgs);
$cmd->setRedirect2to1();
$cmd->execute($output);
$result = $result . "\n" . implode("\n", $output);

$output = [];
$cmdArgs = [];
$cmdArgs[] = "device";
$cmdArgs[] = "stats";
$cmdArgs[] = escapeshellarg($this->getDeviceFile());
$cmd = new \OMV\System\Process("btrfs", $cmdArgs);
$cmd->setRedirect2to1();
$cmd->execute($output);
$result = $result . "\n\n" . implode("\n", $output);

return $result;
}

/**
* Remove the filesystem.
* @return void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@
namespace OMV\System\Filesystem;

class Ext extends Filesystem {
/**
* See parent class definition.
*/
public function getDetails() {
$cmdArgs = [];
$cmdArgs[] = escapeshellarg($this->getDeviceFile());
$cmd = new \OMV\System\Process("dumpe2fs", $cmdArgs);
$cmd->setRedirect2to1();
$cmd->execute($output);
return implode("\n", $output);
}

/**
* Grow the filesystem.
* @return void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -665,6 +665,18 @@ class Filesystem extends \OMV\System\BlockDevice
return $result;
}

/**
* Get details about the filesystem, e.g. the health status.
* @return A string that contains information and details about the
* filesystem. If the filesystem does not provide details, an
* \OMV\NotSupportedException exception is thrown.
* @throw \OMV\ExecException
* @throw \OMV\NotSupportedException
*/
public function getDetails() {
throw new \OMV\NotSupportedException("File system does not provide details.");
}

/**
* Check if a filesystem is mounted.
* @return TRUE if the filesystem is mounted, otherwise FALSE.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,14 @@ interface FilesystemInterface {
*/
public function getStatistics();

/**
* Get details about the filesystem, e.g. the health status.
* @return A string that contains information and details about the
* filesystem.
* @throw \OMV\ExecException
*/
public function getDetails();

/**
* Check if a filesystem is mounted.
* @return TRUE if the filesystem is mounted, otherwise FALSE.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,19 @@
namespace OMV\System\Filesystem;

class Jfs extends Filesystem {
/**
* See parent class definition.
*/
public function getDetails() {
$cmdArgs = [];
$cmdArgs[] = "-l";
$cmdArgs[] = escapeshellarg($this->getDeviceFile());
$cmd = new \OMV\System\Process("jfs_tune", $cmdArgs);
$cmd->setRedirect2to1();
$cmd->execute($output);
return implode("\n", $output);
}

/**
* Grow the filesystem.
* @return void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,18 @@
namespace OMV\System\Filesystem;

class Xfs extends Filesystem {
/**
* See parent class definition.
*/
public function getDetails() {
$cmdArgs = [];
$cmdArgs[] = escapeshellarg($this->getDeviceFile());
$cmd = new \OMV\System\Process("xfs_info", $cmdArgs);
$cmd->setRedirect2to1();
$cmd->execute($output);
return implode("\n", $output);
}

/**
* Grow the filesystem.
* @return void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,19 @@ export class FilesystemDatatablePageComponent implements OnInit {
url: '/storage/filesystems/quota/{{ _selected[0].uuid }}'
}
},
{
type: 'iconButton',
icon: 'details',
tooltip: gettext('Show details'),
enabledConstraints: {
minSelected: 1,
maxSelected: 1
},
execute: {
type: 'url',
url: '/storage/filesystems/details/{{ _selected[0].canonicaldevicefile | encodeuricomponent }}'
}
},
{
template: 'delete',
icon: 'stop',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* This file is part of OpenMediaVault.
*
* @license http://www.gnu.org/licenses/gpl.html GPL Version 3
* @author Volker Theile <volker.theile@openmediavault.org>
* @copyright Copyright (c) 2009-2024 Volker Theile
*
* OpenMediaVault is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* OpenMediaVault is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
import { Component } from '@angular/core';

import { TextPageConfig } from '~/app/core/components/intuition/models/text-page-config.type';

@Component({
template: '<omv-intuition-text-page [config]="this.config"></omv-intuition-text-page>'
})
export class FilesystemDetailsTextPageComponent {
public config: TextPageConfig = {
hasCopyToClipboardButton: true,
hasReloadButton: true,
request: {
service: 'FileSystemMgmt',
get: {
method: 'getDetails',
params: {
devicefile: '{{ _routeParams.devicefile }}'
}
}
},
buttons: [
{
template: 'back',
url: '/storage/filesystems'
}
]
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { RouteConfigService } from '~/app/core/services/route-config.service';
import { DiskDatatablePageComponent } from '~/app/pages/storage/disks/disk-datatable-page.component';
import { DiskFormPageComponent } from '~/app/pages/storage/disks/disk-form-page.component';
import { FilesystemDatatablePageComponent } from '~/app/pages/storage/filesystems/filesystem-datatable-page.component';
import { FilesystemDetailsTextPageComponent } from '~/app/pages/storage/filesystems/filesystem-details-text-page.component';
import { FilesystemEditFormPageComponent } from '~/app/pages/storage/filesystems/filesystem-edit-form-page.component';
import { FilesystemMountFormPageComponent } from '~/app/pages/storage/filesystems/filesystem-mount-form-page.component';
import { FilesystemQuotaDatatablePageComponent } from '~/app/pages/storage/filesystems/filesystem-quota-datatable-page.component';
Expand Down Expand Up @@ -214,6 +215,16 @@ const routes: Routes = [
}
}
]
},
{
path: 'details/:devicefile',
component: FilesystemDetailsTextPageComponent,
data: {
title: gettext('Details'),
breadcrumb: {
text: '{{ "Details" | translate }} @ {{ _routeParams.devicefile }}'
}
}
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { MaterialModule } from '~/app/material.module';
import { DiskDatatablePageComponent } from '~/app/pages/storage/disks/disk-datatable-page.component';
import { DiskFormPageComponent } from '~/app/pages/storage/disks/disk-form-page.component';
import { FilesystemDatatablePageComponent } from '~/app/pages/storage/filesystems/filesystem-datatable-page.component';
import { FilesystemDetailsTextPageComponent } from '~/app/pages/storage/filesystems/filesystem-details-text-page.component';
import { FilesystemEditFormPageComponent } from '~/app/pages/storage/filesystems/filesystem-edit-form-page.component';
import { FilesystemMountFormPageComponent } from '~/app/pages/storage/filesystems/filesystem-mount-form-page.component';
import { FilesystemQuotaDatatablePageComponent } from '~/app/pages/storage/filesystems/filesystem-quota-datatable-page.component';
Expand Down Expand Up @@ -42,6 +43,7 @@ import { SharedModule } from '~/app/shared/shared.module';
SharedFolderPermissionsDatatablePageComponent,
SharedFolderSnapshotsTabsPageComponent,
SharedFolderAllSnapshotsTabsPageComponent,
FilesystemDetailsTextPageComponent,
FilesystemEditFormPageComponent,
FilesystemMountFormPageComponent,
FilesystemQuotaDatatablePageComponent,
Expand Down

0 comments on commit b6d4a27

Please sign in to comment.