1
00:00:00,002 --> 00:00:05,005
(bouncy upbeat music)

2
00:00:05,005 --> 00:00:09,001
- [Instructor] Let's look at solutions for those challenges.

3
00:00:09,001 --> 00:00:15,004
So we want to know what files LSPCI opens

4
00:00:15,004 --> 00:00:17,001
and we're maybe particularly interested

5
00:00:17,001 --> 00:00:19,004
in files underneath /sys.

6
00:00:19,004 --> 00:00:23,006
But let's see. What's strace.

7
00:00:23,006 --> 00:00:28,009
We're going to do all the openat lspci.

8
00:00:28,009 --> 00:00:31,006
Not a whole lot of them, some library stuff,

9
00:00:31,006 --> 00:00:36,006
but we see several SIS bus PCI devices

10
00:00:36,006 --> 00:00:38,007
sort of things opened.

11
00:00:38,007 --> 00:00:43,005
So it's looking for PCI devices using the SIS file system.

12
00:00:43,005 --> 00:00:49,005
Also, by the way, it opens users share miscellaneous pci.ids

13
00:00:49,005 --> 00:00:54,006
to get the names that correspond to the code

14
00:00:54,006 --> 00:00:59,003
for things like the vendor name for PCI devices.

15
00:00:59,003 --> 00:01:03,003
Now we want to look at sysblock.

16
00:01:03,003 --> 00:01:05,001
We do a list there.

17
00:01:05,001 --> 00:01:08,007
We see our block devices and we see an sda, right?

18
00:01:08,007 --> 00:01:11,001
That's a soft link but yeah,

19
00:01:11,001 --> 00:01:16,008
we have a sda disc block device on this system.

20
00:01:16,008 --> 00:01:22,004
Let's go in there and we see sub directories,

21
00:01:22,004 --> 00:01:27,005
for its partitions, sda1, sda2, sda3.

22
00:01:27,005 --> 00:01:31,004
Great, got three partitions.

23
00:01:31,004 --> 00:01:37,000
Let's look at what fdisk -l opens.

24
00:01:37,000 --> 00:01:42,003
strace - e openat output,

25
00:01:42,003 --> 00:01:44,008
what to put it in temp.

26
00:01:44,008 --> 00:01:47,001
We can't write into the directory we're in right now,

27
00:01:47,001 --> 00:01:52,000
sys block sda, can't create a file there

28
00:01:52,000 --> 00:01:57,009
and we want to run fdisk -l.

29
00:01:57,009 --> 00:02:01,002
Alright, now we want to see if that fdisk -l

30
00:02:01,002 --> 00:02:04,007
opened anything underneath sys block.

31
00:02:04,007 --> 00:02:12,005
So let's grab sys/block in that strace file.

32
00:02:12,005 --> 00:02:14,002
It opened a lot.

33
00:02:14,002 --> 00:02:15,006
It also failed to open a lot.

34
00:02:15,006 --> 00:02:17,003
Look, for example, it tried to open

35
00:02:17,003 --> 00:02:23,004
sysblock sda3 device dev sysblock, sda,

36
00:02:23,004 --> 00:02:24,005
those are all failing.

37
00:02:24,005 --> 00:02:27,006
No such file directory. What's up with that?

38
00:02:27,006 --> 00:02:30,004
All right, so sysblock sda3.

39
00:02:30,004 --> 00:02:34,003
If we go back, there's no entries here

40
00:02:34,003 --> 00:02:38,006
for the partitions, so there's no sysblock sda3.

41
00:02:38,006 --> 00:02:42,001
sda3 is underneath sda.

42
00:02:42,001 --> 00:02:46,006
So if fdisk were looking for information about sda1,

43
00:02:46,006 --> 00:02:51,003
it should be trying to open sysblock sda sda1.

44
00:02:51,003 --> 00:02:52,005
That looks like a little problem

45
00:02:52,005 --> 00:02:56,002
with the fdisk utility to me.

46
00:02:56,002 --> 00:02:59,008
And if we look in sda1,

47
00:02:59,008 --> 00:03:02,004
sure enough, there is a dev file there.

48
00:03:02,004 --> 00:03:05,007
So it could have been looking there.

49
00:03:05,007 --> 00:03:09,006
The other question was does fdisk -l

50
00:03:09,006 --> 00:03:12,004
open anything in cis dev block?

51
00:03:12,004 --> 00:03:17,001
So let's grip sys dev block

52
00:03:17,001 --> 00:03:19,005
in the strace output.

53
00:03:19,005 --> 00:03:22,004
Yep, it opens a bunch of things there.

54
00:03:22,004 --> 00:03:26,006
All these names that are number:number,

55
00:03:26,006 --> 00:03:27,005
we'll talk about that.

56
00:03:27,005 --> 00:03:29,007
That's major and minor number.

57
00:03:29,007 --> 00:03:33,003
That's device file sort of information.

58
00:03:33,003 --> 00:03:37,000
But yeah, fdisk tries to open lots of files.

59
00:03:37,000 --> 00:03:38,000
There you go.

