Skip to content

Commit

Permalink
use a single call to 'zfs list' command
Browse files Browse the repository at this point in the history
Closes: #1713
  • Loading branch information
guillomovitch committed Aug 1, 2012
1 parent 9cd3b71 commit 4c0d117
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions lib/FusionInventory/Agent/Task/Inventory/Input/Solaris/Drives.pm
Expand Up @@ -37,28 +37,28 @@ sub doInventory {
# get all file systems
getFilesystemsFromDf(logger => $logger, command => _getDfCmd());

# get additional informations
# get indexed list of ZFS filesystems
my %zfs_filesystems =
map { $_ => 1 }
map { (split(/\s+/, $_))[0] }
getAllLines(command => 'zfs list -H');

# set filesystem type, using fstyp if needed
foreach my $filesystem (@filesystems) {

if ($filesystem->{VOLUMN} eq 'swap') {
$filesystem->{FILESYSTEM} = 'swap';
next;
}

# use -H to exclude headers
my $zfs_line = getFirstLine(
command => "zfs get -H creation $filesystem->{VOLUMN}"
);
if ($zfs_line && $zfs_line =~ /creation\s+(\S.*\S+)\s*-/) {
if ($zfs_filesystems{$filesystem->{VOLUMN}}) {
$filesystem->{FILESYSTEM} = 'zfs';
next;
}

# call fstype, and set filesystem type unless the output matches
# erroneous result
my $fstyp_line = getFirstLine(command => "fstyp $filesystem->{VOLUMN}");
if ($fstyp_line && $fstyp_line !~ /^fstyp/) {
$filesystem->{FILESYSTEM} = $fstyp_line;
my $type = getFirstLine(command => "fstyp $filesystem->{VOLUMN}");
if ($type && $type !~ /^fstyp/) {
$filesystem->{FILESYSTEM} = $type;
}
}

Expand Down

0 comments on commit 4c0d117

Please sign in to comment.