|
|
EDA365欢迎您登录!
您需要 登录 才可以下载或查看,没有帐号?注册
x
由于Linux内核版本更新的原因,LDD3(v2.6.10)提供的源码无法直接使用,下面是本人编译scull源码时出现的一些问题及解决方法。5 d# `! ^# I$ y" f- ?6 ]
编译环境:CentOS 6.3(kernel version 2.6.32)$ @8 f N( ~% k
N/ I7 @7 X; a/ k: K编译错误:
. c/ D7 l& O& i# T2 L/ J& j8 rmake -C /lib/modules/2.6.32-279.14.1.el6.i686/build M=/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull LDDINC=/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/../include modules% R! m$ r' R5 r" X- b
make[1]: Entering directory `/usr/src/kernels/2.6.32-279.14.1.el6.i686'
, u3 Y% i+ a5 Q) R, X8 _" n, e* W# cscripts/Makefile.build:49: *** CFLAGS was changed in "/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/Makefile". Fix it to use EXTRA_CFLAGS. Stop.
& E5 F9 B7 b/ Z$ bmake[1]: *** [_module_/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull] Error 2
% T8 I- [$ U& ~0 c/ umake[1]: Leaving directory `/usr/src/kernels/2.6.32-279.14.1.el6.i686'. {- w2 W- o" d' N
make: *** [modules] Error 2/ \+ J6 x( c7 z( }+ \& G
解决方案:
, m w! k1 z7 v8 @CFLAGS与Makefile.build中的CFLAGS冲突,错误提示要求将CFLAG换成EXTRA_CFLAGS重新编译即可;
; Q: k+ I: N4 s# Z9 y
" n, p5 S R) q4 H1 P) s编译错误:: L8 A: x$ g: s6 \- X; R% e
error: linux/config.h: No such file or directory
0 l3 f2 n$ o7 S解决方案:/ A% @9 p( `: ?2 b
从linux-2.6.20起,config.h就已经被移除了.* Q5 D& T# j) J3 T, o" M
将#include <linux/config.h>修改成如下——>9 Q& V/ v: v& A4 S
#include <linux/version.h>4 j; P0 G$ S0 C
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18))
2 e# b i9 Y6 N# N$ a; J9 g4 C#include <linux/config.h>8 y5 q X* d B$ X2 v' B
#endif
) |! S- U: p, v9 T6 a0 k; `/ k2 c! N# m* B0 k. O
编译错误:
* J; H0 G ~0 U# b/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/pipe.c: In function ‘scull_p_read’:+ v# d; R" f$ s5 y: y$ c) u! S
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/pipe.c:131: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
3 y) ^" Q0 q; ]. g0 V. n/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/pipe.c:131: error: (Each undeclared identifier is reported only once
/ q5 X1 J$ u2 F! \! Z/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/pipe.c:131: error: for each function it appears in.)
9 ]4 g' M* b0 c, Q9 _- Q% ]; J$ @; B/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/pipe.c:131: error: implicit declaration of function ‘signal_pending’: u0 \4 x8 C7 ^2 z( B: ~: c
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/pipe.c:131: error: implicit declaration of function ‘schedule’
* a6 {. y* }3 [) D/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/pipe.c: In function ‘scull_getwritespace’:
' _. I7 }# o% ]) k+ i/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/pipe.c:168: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)+ l8 \( S4 s/ ]6 }( `" F1 e; t/ e
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/pipe.c: In function ‘scull_p_write’:; Y6 ~& x+ W( s, a5 r
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/pipe.c:219: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)$ I" q' _: v% h6 V& h$ ~3 k3 o' p! U
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/pipe.c:223: error: ‘SIGIO’ undeclared (first use in this function)
0 M5 c6 f4 I8 S! @' ]6 M/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/pipe.c:223: error: ‘POLL_IN’ undeclared (first use in this function). J+ G2 Q6 T; b! N
make[2]: *** [/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/pipe.o] Error 1
. X' a* S3 K) T3 c% j% Amake[1]: *** [_module_/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull] Error 2
) w; R) K4 T! {/ J5 Y解决方案:0 E+ ^& ?9 J: L4 u4 n$ o
头文件变动原因,在pipe.c中添加
" O6 p `& ]* Q#include <linux/sched.h>
U- A$ t j: l1 f R$ T- g' M3 P3 C
编译错误:
- S8 \1 A1 b8 B2 J) Z/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c: In function ‘scull_u_open’:% A5 b, ~0 g4 L y! h- M: C' w
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:106: error: dereferencing pointer to incomplete type
4 t; y$ l5 U+ h( e. e! \! p9 P/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:107: error: dereferencing pointer to incomplete type+ z' a5 e: k0 G, _
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:114: error: dereferencing pointer to incomplete type5 \ s! n1 T6 S
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c: In function ‘scull_w_available’:
* O" g; n3 T4 p6 Z, j/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:165: error: dereferencing pointer to incomplete type; K$ o# b' q. r4 `0 |# J
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:166: error: dereferencing pointer to incomplete type& B1 J: _8 P3 f/ J) W3 s& ]
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c: In function ‘scull_w_open’:
) a: m3 u1 F: s. ^8 m3 N1 U/ b$ a/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:179: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)
% z2 B8 D( c/ N2 N% _1 }/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:179: error: (Each undeclared identifier is reported only once
9 s( i; g6 @: m/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:179: error: for each function it appears in.)8 u* |3 r z1 {6 C/ A1 W% S% `
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:179: error: implicit declaration of function ‘signal_pending’9 s( p" C! Z2 f6 \
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:179: error: implicit declaration of function ‘schedule’6 k( g Q/ N' }3 K; n
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:184: error: dereferencing pointer to incomplete type7 E$ S5 p' s) i4 H2 i& `7 L! g
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c: In function ‘scull_w_release’:- j& b5 |3 b. t; U) V H" s
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:205: error: ‘TASK_INTERRUPTIBLE’ undeclared (first use in this function)/ `* @6 D A9 x
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c: In function ‘scull_c_open’:
# H: x, B. p3 y/ |, u2 V1 {/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:277: error: dereferencing pointer to incomplete type
7 x2 _! N0 P" \, s+ F* a/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:281: error: dereferencing pointer to incomplete type& Q, Q& d) q$ |% ?
make[2]: *** [/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.o] Error 1
! X, f" f7 U7 Nmake[1]: *** [_module_/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull] Error 2) w; h2 Z! N9 W3 f) b2 ~# q. r
make[1]: Leaving directory `/usr/src/kernels/2.6.32-279.14.1.el6.i686'
7 _+ @: {& y5 { a1 H- @- z' Kmake: *** [modules] Error 23 m1 o2 \! I, J( u6 Q
解决方案:: V( ?5 s8 b9 i( Y9 q
头文件变动原因,在access.c中添加
; J! N* m. |5 J" F Y9 O#include <linux/sched.h> 5 K$ I& C! E* J( k9 R" c: M
7 j: t. I& `; T M: {0 V编译错误:
3 B# b5 P% W5 L: d/ L# r7 g5 }/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c: In function ‘scull_u_open’:
3 e' ?& _6 m+ Y/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:107: error: ‘struct task_struct’ has no member named ‘uid’4 l0 E7 S' k u) y3 ?
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:108: error: ‘struct task_struct’ has no member named ‘euid’
( \: {4 a' ^, l/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:115: error: ‘struct task_struct’ has no member named ‘uid’2 S% a. E. S" ^4 ]# v$ ?# m1 I
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c: In function ‘scull_w_available’:6 D6 E1 ^- A+ s) [: ?! J! v5 ^" V
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:166: error: ‘struct task_struct’ has no member named ‘uid’% Z& Y2 I2 B( \0 f7 R9 Q7 p
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:167: error: ‘struct task_struct’ has no member named ‘euid’6 M/ z }' [$ o0 q2 X" |; Y0 S& b
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c: In function ‘scull_w_open’:/ L' M# h4 W% m
/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.c:185: error: ‘struct task_struct’ has no member named ‘uid’
# H* i9 Z/ l* n$ v% c. ^make[2]: *** [/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull/access.o] Error 16 O, W% s" @. z% y7 K' T ]$ o
make[1]: *** [_module_/mnt/HappyStudy/MyDesigner/Linux/LDD3/examples/scull] Error 2
! q* F8 y6 ?3 R* Gmake[1]: Leaving directory `/usr/src/kernels/2.6.32-279.14.1.el6.i686'
& x z; B5 t& Q! p/ K1 ?make: *** [modules] Error 2
- K5 P: h% _5 Z4 F3 g8 J4 b解决方案:
* S* _9 B4 \. _' s% H因为内核版本的升级,struct task_struct发生了变动,uid和euid放到了cred域下.
7 F( i @( J2 b$ t4 g/ a2 I: u修改,做如下替换# f. w+ _ {( N! {. o3 ~ [
current->uid 替换成current->cred->uid
+ W* o1 K9 W1 W& f# y0 R% Bcurrent->euid替换成current->cred->euid
) N# W& L! L( V0 |
( a. D; e* |# @! E! h. t重新编译,成功!
3 J8 P7 c5 ~. C" V
. R0 s+ r; C/ l: f* m& s7 p9 i2 [9 m. C; c& Y3 G% S4 R/ i: V
|
|