From the course: Advanced Linux: The Linux Kernel
Solution: sysfs - Linux Tutorial
From the course: Advanced Linux: The Linux Kernel
Solution: sysfs
(bouncy upbeat music) - [Instructor] Let's look at solutions for those challenges. So we want to know what files LSPCI opens and we're maybe particularly interested in files underneath /sys. But let's see. What's strace. We're going to do all the openat lspci. Not a whole lot of them, some library stuff, but we see several SIS bus PCI devices sort of things opened. So it's looking for PCI devices using the SIS file system. Also, by the way, it opens users share miscellaneous pci.ids to get the names that correspond to the code for things like the vendor name for PCI devices. Now we want to look at sysblock. We do a list there. We see our block devices and we see an sda, right? That's a soft link but yeah, we have a sda disc block device on this system. Let's go in there and we see sub directories, for its partitions, sda1, sda2, sda3. Great, got three partitions. Let's look at what fdisk -l opens. strace - e openat output, what to put it in temp. We can't write into the directory we're in right now, sys block sda, can't create a file there and we want to run fdisk -l. Alright, now we want to see if that fdisk -l opened anything underneath sys block. So let's grab sys/block in that strace file. It opened a lot. It also failed to open a lot. Look, for example, it tried to open sysblock sda3 device dev sysblock, sda, those are all failing. No such file directory. What's up with that? All right, so sysblock sda3. If we go back, there's no entries here for the partitions, so there's no sysblock sda3. sda3 is underneath sda. So if fdisk were looking for information about sda1, it should be trying to open sysblock sda sda1. That looks like a little problem with the fdisk utility to me. And if we look in sda1, sure enough, there is a dev file there. So it could have been looking there. The other question was does fdisk -l open anything in cis dev block? So let's grip sys dev block in the strace output. Yep, it opens a bunch of things there. All these names that are number:number, we'll talk about that. That's major and minor number. That's device file sort of information. But yeah, fdisk tries to open lots of files. There you go.
Contents
-
-
-
Discover and control hardware5m 55s
-
(Locked)
Challenge: Hardware26s
-
(Locked)
Solution: Hardware1m 32s
-
(Locked)
System calls in-depth4m 30s
-
(Locked)
Challenge: System calls (syscalls)1m 51s
-
(Locked)
Solution: System calls (syscalls)4m 45s
-
(Locked)
Read messages from the kernel and /proc3m 34s
-
(Locked)
Challenge: kernel messages and proc1m 12s
-
(Locked)
Solution: kernel messages and proc2m 19s
-
(Locked)
Introduction to /sys2m 30s
-
(Locked)
Challenge: sysfs1m 17s
-
Solution: sysfs3m 38s
-
(Locked)
Device drivers and device files4m 17s
-
(Locked)
Challenge: Drivers and device files44s
-
(Locked)
Solution: Drivers and device files2m 47s
-
-
-
-
-
-