Skip to content

Commit

Permalink
Исправил проблемы получения информации о точке монтирования диска.
Browse files Browse the repository at this point in the history
  • Loading branch information
boffart committed Jul 12, 2024
1 parent c500eff commit a9b4361
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Core/System/Storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,12 @@ public static function isStorageDiskMounted(string $filter = '', string &$mount_
$grep = Util::which('grep');
$mount = Util::which('mount');
$awk = Util::which('awk');
$head = Util::which('head');

$filter = escapeshellarg($filter);

// Execute the command to filter the mount points based on the filter
$out = shell_exec("$mount | $grep $filter | $awk '{print $3}'");
$out = shell_exec("$mount | $grep $filter | $awk '{print $3}' | $head -n 1");
$mount_dir = trim($out);
return ($mount_dir !== '');
}
Expand Down Expand Up @@ -1489,9 +1490,10 @@ public static function diskIsMounted(string $disk, string $filter = '/dev/')
$out = [];
$grepPath = Util::which('grep');
$mountPath = Util::which('mount');
$headPath = Util::which('head');

// Execute mount command and grep the output for the disk name
Processes::mwExec("$mountPath | $grepPath '$filter$disk'", $out);
Processes::mwExec("$mountPath | $grepPath '$filter${disk}' | $headPath -n 1", $out);
if (count($out) > 0) {
$res_out = end($out);
} else {
Expand Down Expand Up @@ -1541,9 +1543,10 @@ public static function getFreeSpace(string $hdd)
$grep = Util::which('grep');
$awk = Util::which('awk');
$df = Util::which('df');
$head = Util::which('head');

// Execute df command to get the free space for the HDD
Processes::mwExec("$df -m | $grep $hdd | $awk '{print $4}'", $out);
Processes::mwExec("$df -m | $grep $hdd | $grep -v custom_modules | $head -n 1 | $awk '{print $4}'", $out);
$result = 0;
// Sum up the free space values
Expand Down

0 comments on commit a9b4361

Please sign in to comment.