Find specific code in the kernel

Source: Internet
Author: User
Assume that you want to start studying the USB driver, where do you start to find the USB code? First, you can try to run the find command: $ find-name in the top-level kernel directory.

Assume that you want to start studying the USB driver, where do you start to find the USB code? First, you can try to run the find command in the top-level kernel Directory:

$ Find.-name * usb *

This command prints all file names containing the string "usb". another way to try is to find a unique string, which can be printk () or the file name in/proc, or 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 find the part of the printk that does not include the version number:

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

Another way to try to find the USB source code is to view/proc. If you enter find/proc-name usb, you may find a directory named/proc/bus/usb, read the entries in the directory, or find the only string used for the grep command.

If all other methods fail, you can try to enter each directory and list the files, or view the ls-lR output. 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 the source code itself is another course. you only need to remember that the more you read the source code, the easier you can grasp it, hope you have fun studying the kernel!

Related Article

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.