forked from pavolelsig/IOMMU-viewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
iommu_viewer.sh
53 lines (34 loc) · 1.14 KB
/
iommu_viewer.sh
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
#!/bin/bash
echo "Please be patient. This may take a couple seconds."
#Initializing the list of all IOMMU groups
GROUP=`find /sys/kernel/iommu_groups/ -type l | cut -d '/' -f 5,7 --output-delimiter='-'`
for i in $GROUP; do
#K holds the group number
k=`echo $i | cut -d '-' -f 1`
#L holds the address
l=`echo $i | cut -d '-' -f 2`
#J holds the part of the address that's pasted into lspci to get the name
j=`echo $i | cut -d ':' -f 2,3,4`
#M holds the kernel driver in use
m=`lspci -k -s $j | grep "Kernel driver in use"`
echo -n "Group: "
#This if-statement is here for proper alignment. If group is less than 10, a space is added.
if [ $k -lt 10 ]
then
echo -n " $k "
else
echo -n " $k "
fi
#Outputting the address
echo -n " $l "
#Outputting the name and id
echo -n "`lspci -nn | grep $j | cut -d ' ' -f 2-`"
#Only displays " Driver:" if m is not an empty string
if ! [ -z "$m" ]
then
echo -n " Driver:"
fi
#Outputting the kernel driver in use
echo "$m" | cut -d ':' -f 2
#The output is sorted numerically based on the second space-separated field.
done | sort -nk2