This file is indexed.

/usr/share/fusioninventory/lib/FusionInventory/Agent/Task/Inventory/Linux/Storages/Adaptec.pm is in fusioninventory-agent 1:2.3.10.1-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
package FusionInventory::Agent::Task::Inventory::Linux::Storages::Adaptec;

use strict;
use warnings;

use English qw(-no_match_vars);

use FusionInventory::Agent::Tools;
use FusionInventory::Agent::Tools::Linux;

sub isEnabled {
    return -r '/proc/scsi/scsi';
}

sub doInventory {
    my (%params) = @_;

    my $inventory = $params{inventory};
    my $logger    = $params{logger};

    my @devices = getDevicesFromUdev(logger => $logger);

    foreach my $device (@devices) {
        next unless $device->{MANUFACTURER};
        next unless
            $device->{MANUFACTURER} eq 'Adaptec' ||
            $device->{MANUFACTURER} eq 'Sun'     ||
            $device->{MANUFACTURER} eq 'ServeRA';

        foreach my $disk (_getDisksFromProc(
                controller => 'scsi' . $device->{SCSI_COID},
                name       => $device->{NAME},
                logger     => $logger
        )) {
            # merge with smartctl info
            my $info = getInfoFromSmartctl(device => $disk->{device});
            next unless $info->{TYPE} =~ /disk/i;
            foreach my $key (qw/SERIALNUMBER DESCRIPTION TYPE DISKSIZE MANUFACTURER/) {
                $disk->{$key} = $info->{$key};
            }
            delete $disk->{device};
            $inventory->addEntry(section => 'STORAGES', entry => $disk);
        }
    }
}

sub _getDisksFromProc {
    my (%params) = (
        file => '/proc/scsi/scsi',
        @_
    );

    return unless $params{controller};

    my $handle = getFileHandle(%params);
    return unless $handle;

    my @disks;
    my $disk;

    my $count = -1;
    while (my $line = <$handle>) {
        if ($line =~ /^Host: (\w+)/) {
            $count++;
            if ($1 eq $params{controller}) {
                # that's the controller we're looking for
                $disk = {
                    NAME        => $params{name},
                };
            } else {
                # that's another controller
                undef $disk;
            }
        }

        if ($line =~ /Model: \s (\S.+\S) \s+ Rev: \s (\S+)/x) {
            next unless $disk;
            $disk->{MODEL}    = $1;
            $disk->{FIRMWARE} = $2;

            # that's the controller itself, not a disk
            next if $disk->{MODEL} =~ /raid|virtual/i;

            $disk->{MANUFACTURER} = getCanonicalManufacturer(
                $disk->{MODEL}
            );
            $disk->{device} = "/dev/sg$count";

            push @disks, $disk;
        }
    }
    close $handle;

    return @disks;
}

1;