荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: jjk (Welcome to InstallBBS,Linux!), 信区: Linux
标  题: 内核FAQ2
发信站: 荔园晨风BBS站 (Wed Dec 19 20:22:55 2001), 转信

【 以下文字转载自 jjk 的信箱 】
【 原文由 jjk.bbs@bbs.nju.edu.cn 所发表 】
发信人: altmayer (alt), 信区: LinuxUnix
标  题: 内核FAQ2
发信站: 南京大学小百合站 (Sun Dec 16 06:04:50 2001), 站内信件

【 以下文字转载自 altmayer 的信箱 】
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 选项试试,我多次遇问题,这样做好象百试百中





--

  puke!
  技工而已

※ 来源:·哈工大紫丁香 bbs.hit.edu.cn·[FROM: 202.118.239.152]
--
※ 转寄:.哈工大紫丁香 bbs.hit.edu.cn.[FROM: 211.80.41.106]
--
※ 转载:.南京大学小百合站 bbs.nju.edu.cn.[FROM: 211.80.41.106]
--
※ 转寄:.南京大学小百合站 bbs.nju.edu.cn.[FROM: 深圳大学BBS]
--
※ 修改:·jjksam 於 Dec 19 20:27:53 修改本文·[FROM: 192.168.0.146]
※ 转载:·荔园晨风BBS站 bbs.szu.edu.cn·[FROM: 192.168.0.146]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店