Find specific code in the kernel

Source: Internet
Author: User

Assume that you want to start studying the USB driver. Where can I find the USB code?

First, you can try to runfindCommand:

$ find . -name \*usb\*

This command prints out all file names containing the string "usb.

Another way to try is to find a unique string. The only string can beprintk()Or/procOr any other unique string about the driver that can be found in the source code. For example, the message printed by USB is:

USB Universal Host Controller Interface driver v2.2

So we can try to use recursive grep to findprintkExcluding the version:

$ grep -r "USB Universal Host Controller Interface driver" .

Another way to try to find the USB source code is to view/proc. If you enterfind /proc -name usb, You may find/proc/bus/usbDirectory. Reading the entries in that directory may find the unique string used for the grep command.

If all other methods fail, you can try to enter each directory and list the files, or viewls -lR. You may see the relevant file name. However, this should be the final method. You can try it again only after running different find and grep commands multiple times.

After finding the source code you are interested in, you can start to read it. Reading and understanding source code is another course. You only need to remember that the more you read the source code, the easier it is to grasp it. Hope you have fun studying the kernel!


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.