Linux driver_ldd3_scull driver compilation in the new kernel

Source: Internet
Author: User

When compiling the scull program of ldd3, the compilation fails, and the problems encountered are the same as those encountered by the following buddies,

Follow the steps below to solve the problem and record it here.

/*************************************** **************************************** **************************************** ********************/

Recently, I was reading the character device driver scull in Linux driver program. The following problem occurs during make compilation on Linux 2.6.32-22 kernel:

Make-C/lib/modules/2.6.32-22-generic/build M =/home/savi0r/desktop/Linux device driver development/examples/scull lddinc =/home/savi0r/desktop /Linux device driver development/examples/scull /.. /include modules

Make [1]: Entering directory '/usr/src/linux-headers-2.6.32-22-generic'

Scripts/makefile. build: 49: *** cflags was changed in "/home/savi0r/desktop/Linux device driver development/examples/scull/makefile ". fix it to use extra_cflags. stop.

Make [1]: *** [_ module _/home/savi0r/desktop/Linux device driver development/examples/scull] Error 2

Make [1]: Leaving directory '/usr/src/linux-headers-2.6.32-22-generic'

Make: *** [modules] Error 2


Open makefile and block cflags:

# Cflags + = $ (debflags)

# Cflags + =-I $ (lddinc)


Continue to make, and the following problem occurs again:

Make-C/lib/modules/2.6.32-22-generic/build M =/home/savi0r/desktop/Linux device driver development/examples/scull lddinc =/home/savi0r/desktop /Linux device driver development/examples/scull /.. /include modules

Make [1]: Entering directory '/usr/src/linux-headers-2.6.32-22-generic'

CC [m]/home/savi0r/desktop/Linux device driver development/examples/scull/Main. o

/Home/savi0r/desktop/Linux device driver development/examples/scull/Main. C: 17: 26: Error: Linux/config. h: no such file or directory

Make [2]: *** [/home/savi0r/desktop/Linux device driver development/examples/scull/Main. O] Error 1

Make [1]: *** [_ module _/home/savi0r/desktop/Linux device driver development/examples/scull] Error 2

Make [1]: Leaving directory '/usr/src/linux-headers-2.6.32-22-generic'

Make: *** [modules] Error 2


The Linux/config. h file cannot be found. The kernel structure of the new version may change. This file has been deleted.

Open main. C and delete # include <Linux/config. h>.


Continue to make. Other problems:

Make-C/lib/modules/2.6.32-22-generic/build M =/home/savi0r/desktop/Linux device driver development/examples/scull lddinc =/home/savi0r/desktop /Linux device driver development/examples/scull /.. /include modules

Make [1]: Entering directory '/usr/src/linux-headers-2.6.32-22-generic'

CC [m]/home/savi0r/desktop/Linux device driver development/examples/scull/Main. o

CC [m]/home/savi0r/desktop/Linux device driver development/examples/scull/pipe. o

/Home/savi0r/desktop/Linux device driver development/examples/scull/pipe. C: In function 'scull _ p_read ':

/Home/savi0r/desktop/Linux device driver development/examples/scull/pipe. C: 131: Error: 'Task _ interruptible 'undeclared (first use in this function)

/Home/savi0r/desktop/Linux device driver development/examples/scull/pipe. C: 131: Error: (each undeclared identifier is reported only once

/Home/savi0r/desktop/Linux device driver development/examples/scull/pipe. C: 131: Error: for each function it appears in .)

/Home/savi0r/desktop/Linux device driver development/examples/scull/pipe. C: 131: Error: Implicit declaration of function 'signal _ pending'

/Home/savi0r/desktop/Linux device driver development/examples/scull/pipe. C: 131: Error: Implicit declaration of function 'schedule'

/Home/savi0r/desktop/Linux device driver development/examples/scull/pipe. C: In function 'scull _ getwritespace ':

/Home/savi0r/desktop/Linux device driver development/examples/scull/pipe. C: 168: Error: 'Task _ interruptible 'undeclared (first use in this function)

/Home/savi0r/desktop/Linux device driver development/examples/scull/pipe. C: In function 'scull _ p_write ':

/Home/savi0r/desktop/Linux device driver development/examples/scull/pipe. C: 219: Error: 'Task _ interruptible 'undeclared (first use in this function)

/Home/savi0r/desktop/Linux device driver development/examples/scull/pipe. C: 223: Error: 'sigio 'undeclared (first use in this function)

/Home/savi0r/desktop/Linux device driver development/examples/scull/pipe. C: 223: Error: 'Poll _ in 'undeclared (first use in this function)

Make [2]: *** [/home/savi0r/desktop/Linux device driver development/examples/scull/pipe. O] Error 1

Make [1]: *** [_ module _/home/savi0r/desktop/Linux device driver development/examples/scull] Error 2

Make [1]: Leaving directory '/usr/src/linux-headers-2.6.32-22-generic'

Make: *** [modules] Error 2


Task_interruptible cannot be found. Since a header file is deleted earlier, many variables cannot be found,

Then go to the/usr/src/linux-headers-2.6.32-22-generic grep it:

Finally, find the header file and add it:

# Include <Linux/sched. h>


Access. C also needs to add the header file above.


Then, make is required ....


Make-C/lib/modules/2.6.32-22-generic/build M =/home/savi0r/desktop/Linux device driver development/examples/scull lddinc =/home/savi0r/desktop /Linux device driver development/examples/scull /.. /include modules

Make [1]: Entering directory '/usr/src/linux-headers-2.6.32-22-generic'

CC [m]/home/savi0r/desktop/Linux device driver development/examples/scull/access. o

/Home/savi0r/desktop/Linux device driver development/examples/scull/access. C: In function 'scull _ u_open ':

/Home/savi0r/desktop/Linux device driver development/examples/scull/access. C: 107: Error: 'struct task_struct 'has no member named 'uid'

/Home/savi0r/desktop/Linux device driver development/examples/scull/access. C: 108: Error: 'struct task_struct 'has no member named 'euid'

/Home/savi0r/desktop/Linux device driver development/examples/scull/access. C: 115: Error: 'struct task_struct 'has no member named 'uid'

/Home/savi0r/desktop/Linux device driver development/examples/scull/access. C: In function 'scull _ w_available ':

/Home/savi0r/desktop/Linux device driver development/examples/scull/access. C: 166: Error: 'struct task_struct 'has no member named 'uid'

/Home/savi0r/desktop/Linux device driver development/examples/scull/access. C: 167: Error: 'struct task_struct 'has no member named 'euid'

/Home/savi0r/desktop/Linux device driver development/examples/scull/access. C: In function 'scull _ w_open ':

/Home/savi0r/desktop/Linux device driver development/examples/scull/access. C: 185: Error: 'struct task_struct 'has no member named 'uid'

Make [2]: *** [/home/savi0r/desktop/Linux device driver development/examples/scull/access. O] Error 1

Make [1]: *** [_ module _/home/savi0r/desktop/Linux device driver development/examples/scull] Error 2

Make [1]: Leaving directory '/usr/src/linux-headers-2.6.32-22-generic'

Make: *** [modules] Error 2


The task_struct struct does not have uid, EUID member variable, and struct task_struct is defined in include/Linux/sched. h, this is mainly because the definition of the original task_struct struct has been changed, the UID and EUID are moved to the cred, see include/Linux/sched. H and include/Linux/cred. h.


Therefore, you only need to modify the Error Code as follows:

Current-> uid changed to current-> cred-> uid

Modify current-> EUID to current-> cred-> EUID

Then compile and you can pass.

/*************************************** **************************************** **************************************** ********************/

Compiling on redhat2.6.9.55 is OK. It seems that ldd3 is written based on Kernel 2.6.10.


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.