Skip to content

Commit

Permalink
Match any non-whitespace character in filesystem type pattern
Browse files Browse the repository at this point in the history
Signed-off-by: J0WI <J0WI@users.noreply.github.com>
  • Loading branch information
J0WI committed Mar 26, 2021
1 parent 06bc7ad commit 512182f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/OperatingSystems/DefaultOs.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ public function getDiskInfo(): array {
}

$matches = [];
$pattern = '/^(?<Filesystem>[\S]+)\s*(?<Type>\w+)\s*(?<Blocks>\d+)\s*(?<Used>\d+)\s*(?<Available>\d+)\s*(?<Capacity>\d+%)\s*(?<Mounted>[\w\/-]+)$/m';
$pattern = '/^(?<Filesystem>[\S]+)\s*(?<Type>[\S]+)\s*(?<Blocks>\d+)\s*(?<Used>\d+)\s*(?<Available>\d+)\s*(?<Capacity>\d+%)\s*(?<Mounted>[\w\/-]+)$/m';

$result = preg_match_all($pattern, $disks, $matches);
if ($result === 0 || $result === false) {
Expand Down
1 change: 1 addition & 0 deletions tests/data/df_tp
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ vagrant vboxsf 958123168 614831132 343292036
home_vagrant_code vboxsf 958123168 614831132 343292036 65% /home/vagrant/code
tmpfs tmpfs 816800 0 816800 0% /run/user/1000
nfs.example.com:/export nfs4 14820 0 1230 0% /nfs
198.51.100.42:/storage fuse.sshfs 47929956 53116 45419052 1% /mnt/sshfs
8 changes: 8 additions & 0 deletions tests/lib/DefaultOsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,14 @@ public function testGetDiskInfo(): void {
'available' => 1259520,
'percent' => '0%',
'mount' => '/nfs',
],
[
'device' => '198.51.100.42:/storage',
'fs' => 'fuse.sshfs',
'used' => 51,
'available' => 44354,
'percent' => '1%',
'mount' => '/mnt/sshfs',
]
];

Expand Down

0 comments on commit 512182f

Please sign in to comment.