分享

如何修改ldd源码,才能通过编译

 WUCANADA 2012-05-02
setlevel.c:41: warning: implicit declaration of function 'syslog'
'man 2 _syscall' says that it is obsolete and deprecated.

Fixing the userspace programs is easy. E.g., for setlevel.c, just
#include <unistd.h>
and change this line:

-_syscall3(int, syslog, int, type, char *, bufp, int, len);
+#define syslog(type, bufp, len) syscall(8, type, bufp, len)


For the kernel modules, remove
#include <linux/config.h>
from all of them and change CFLAGS to EXTRA_CFLAGS in all Makefiles.

The biggest remaining problem with the kernel modules is scheduled_work
usage and its changing API.

inp.c:33:41: error: asm/io.h: No such file or directory
改为sys/io.h

ubuntu #include <linux/config.h> no such file or directory  

2012-01-12 21:28:08|  分类: Linux 驱动 |字号 订阅

存在的问题和解决方法:

1、关于CFLAG的错误。将Makefile中的CFLAG项全部屏蔽即可;

2、 提示linux/config.h no such file or directory。在/usr/src/linux-source..../include/linux中创建config.h即可(例:touch /usr/src/linux-source-2.6.35/include/linux/config.h   实际路径中没有config.h)

3、提示TASK_INTERRUPTIBLE undeclared,增加头文件#include <linux/sched.h>即可;

4、 struct task_struct has no member name uid,增加头文件 #include <linux/cred.h>,同时将current->uid改成current->cred->uid,将 current->euid改为current->cred->euid即可;(原因在于新内核数据结构发生了变化,将uid和 euid放入cred结构中,参考:

http://hi.baidu.com/swinggucas/blog/item/32e1d3c3d4eacf3ee4dd3b22.html

1. remove
//#include <linux/config.h>

2. add
#include <linux/sched.h>


3.ˉschedule_delayed_workˇ from incompatible pointer type
jiq.c, L53
//static struct work_struct jiq_work;
static struct delayed_work jiq_work;

4.
jiq.c, L244
//	INIT_WORK(&jiq_work, jiq_print_wq, &jiq_data);
	INIT_DELAYED_WORK(&jiq_work, jiq_print_wq, &jiq_data);

jiq.c, L124, L140
//		schedule_work(&jiq_work);
		schedule_work(&jiq_work.work);

5. macro "INIT_DELAYED_WORK" passed 3 arguments, but takes just 2
//	INIT_WORK(&jiq_work, jiq_print_wq, &jiq_data);
	INIT_DELAYED_WORK(&jiq_work, jiq_print_wq);
Question: &jiq_data? defined in struct delayed_work?

6. error: 'system_utsname' undeclared 
kdatasize.c and kdatalign.c
-               system_utsname.machine,
+               init_uts_ns.name.machine,

7. to test sleepy
	sudo insmod sleepy.ko
	cat /proc/devices to find the major number of sleepy, say 250
	sudo mknod /dev/sleepy c 250 0
	sudo chmod 666 /dev/sleepy
	in first terminal, cat /dev/sleepy
	in second terminal, cat /dev/sleepy
	in third terminal, ls > /dev/sleepy
	sudo rm -f /dev/sleepy


    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多