安装交叉编译器的方法:
1、解压cross-compile到 / 目录下
2、将交叉编译器添加到环境变量中:(#vim /etc/prifile)
export PATH=$PATH:/usr/local/arm/arm-none-linux-gnueabi/bin
3、注销一下
制作内核的准备工作方法:
1、改写错误的文件:
linux-2.6.28_smdk6410/drivers/video/samsung
2、将"s3cfb_UT_LCD43C_D .c"改名字
#mv s3cfb_UT_LCD43C_D\ .c s3cfb_UT_LCD43C_D .c
//说明:空格需要一个转译字符
编译内核的方法:
1、下载下内核源码之后第一件事是将内核编译成映像,使之能够稳定,然后在稳定的环境下进行编程。
在 linux-2.6.28_smdk6410i/(即内核根目录)下,再将特定的*config复制到.config
#cp smdk6410_config .config
2、选择需要编译的一些东西
#make gconfig
3、编译内核映像:
#make zImage
最终映像zImage 在arch/arm/boot/下
?为什么vmlinux在arch/arm/boot/compressed/下
?为什么giggy.o在arch/arm/boot/compressed/下
内核模块编译的步骤:
LD vmlinux
SYSMAP System.map
SYSMAP .tmp_System.map
OBJCOPY arch/arm/boot/Image
Kernel: arch/arm/boot/Image is ready
GZIP arch/arm/boot/compressed/piggy.gz
AS arch/arm/boot/compressed/piggy.o
LD arch/arm/boot/compressed/vmlinux
OBJCOPY arch/arm/boot/zImage
Kernel: arch/arm/boot/zImage is ready
?在需要挂载的文件系统下设置
到挂在的根文件下的 #vim etc/eth0-setting
命令: ls -a 显示隐藏的文件
安装交叉编译器的方法:
1、解压cross-compile到 / 目录下
2、将交叉编译器添加到环境变量中:(#vim /etc/prifile)
export PATH=$PATH:/usr/local/arm/arm-none-linux-gnueabi/bin
3、注销一下
制作内核的准备工作方法:
1、改写错误的文件:
linux-2.6.28_smdk6410/drivers/video/samsung
2、将"s3cfb_UT_LCD43C_D .c"改名字
#mv s3cfb_UT_LCD43C_D\ .c s3cfb_UT_LCD43C_D .c
//说明:空格需要一个转译字符
编译内核的方法:
1、下载下内核源码之后第一件事是将内核编译成映像,使之能够稳定,然后在稳定的环境下进行编程。
在 linux-2.6.28_smdk6410i/(即内核根目录)下,再将特定的*config复制到.config
#cp smdk6410_config .config
2、选择需要编译的一些东西
#make gconfig
3、编译内核映像:
#make zImage
最终映像zImage 在arch/arm/boot/下
?为什么vmlinux在arch/arm/boot/compressed/下
?为什么giggy.o在arch/arm/boot/compressed/下
内核模块编译的步骤:
LD vmlinux
SYSMAP System.map
SYSMAP .tmp_System.map
OBJCOPY arch/arm/boot/Image
Kernel: arch/arm/boot/Image is ready
GZIP arch/arm/boot/compressed/piggy.gz
AS arch/arm/boot/compressed/piggy.o
LD arch/arm/boot/compressed/vmlinux
OBJCOPY arch/arm/boot/zImage
Kernel: arch/arm/boot/zImage is ready
?在需要挂载的文件系统下设置
到挂在的根文件下的 #vim etc/eth0-setting
命令: ls -a 显示隐藏的文件
Time: 2012.10.23
Things: 中极课程第二天
theme: 1、内核模块的编写编译
2、内核模块的拷贝
3、内核模块的插入删除
4、busybox的安装
第一部分:内核模块的编写编译
第一小节:在任意文件夹下面编写内核代码:
1、内核模块的编写:hello.c 和 Makefile
//hello.c
#include
#include
MODULE_LICENSE("GPL");
static int __init hello_init(void)
{
printk("Hello,worldkdjfk(((((((((((((((((((((99!\n");
return 0;
}
static void __exit hello_exit(void)
{
printk("Goodbjdkfjdkfkdjfdjfkddddddd***********8ye world!\n");
}
module_init(hello_init);
module_exit(hello_exit);
//Makefile
obj-m :=hello.o
2、内核模块的编译
生成插入板子的内核模块:
#make -C /home/luoyuntian/linux-2.6.28_smdk6410/ modules
生成插入PC的内核模块:
#make -C usr/src/kernels/2.6.32-131.0.15.el6.i686/ modules
第二小节:在内核树里面编写与编译
1、内核的编写:
到~/dirvers/char/ 建立 hellop文件夹,
在hellop/文件下新建hellop.c 和 Makefile , Kconfig文件
//hellop.c
#include
#include
#include
static char *whom = "boy";
static int howmany = 1;
module_param(howmany, int, S_IRUGO);
module_param(whom, charp, S_IRUGO);
static int __init hellop_init(void)
{
int i;
for (i = 0; i < howmany; i++) {
printk("hello,%s\n", whom);
}
return 0;
}
static void __exit hellop_exit(void)
{
printk("Goodbye!\n");
}
module_init(hellop_init);
module_exit(hellop_exit);
MODULE_LICENSE("GPL");
//Makefile
obj-$(CONFIG_HELLOP) += hellop.o
//Kconfig
config HELLOP
tristate "This is hellop"
到~/drivers/char/ 下:
在Kconfig 文件中加入:
source "drivers/char/hellop/Kconfig"
在Makefile文件中加入:
obj-$(CONFIG_HELLOP) += hellop/ //注意这里的HELLOP要和前面的HELLOP一样。
第二部分:内核模块的拷贝
第一小节:在任意文件夹下面编写的内核代码
拷贝到PC的内核:
不需要拷贝,在任意目录下面直接调用
#modproble
拷贝到板子上的内核:
在/home/luoyuntian/linux-2.6.28_smdk6410/ 目录下面:
在hellop文件夹目录下面的方式:
#make -C /home/luoyuntian/linux-2.6.28_smdk6410/ M=$(pwd) INSTALL_MOD_PATH=/arm_system modules_install
拷贝结束以后:hellop.ko被放到了文件夹:/arm_system/lib/modules/2.6.28.6
第二小节:在内核树中编写的内核代码:
拷贝到PC的内核:
同上
拷贝到板子上的内核:
#make -C /home/luoyuntian/linux-2.6.28_smdk6410/ M=$(pwd) INSTALL_MOD_PATH=/arm_system modules_install
第一二部分的简便方式:
在任意文件夹下面建立:hellop.c 和 Makefile 和 Kconfig 文件
//hellop.c
同上
//Makefile
ifneq ($(KERNELRELEASE),)
obj-m := hellop.o
else
#KERNELDIR=/usr/src/kernels/2.6.32-131.0.15.el6.i686/ //不用安装直接用insmod 显示看效果
KERNELDIR=/home/luoyuntian/linux-2.6.28_smdk6410/
PWD := $(shell pwd)
default:
make -C $(KERNELDIR) M=$(PWD) modules //切换内核源码树
clean:
make -C $(KERNELDIR) M=$(PWD) clean
modules_install:
make -C $(KERNELDIR) M=$(PWD) INSTALL_MOD_PATH=/arm_system moudles_install
endif
第二部分:内核模块的插入、查看、移除:
内核模块的插入:
insmod 与 modprobe 的区别:
insmod 需要路径:
插入板子上面的内核:
在板子上面的/文件下,要安装内核模块的方式:
#insmod /lib/modules/2.6.28.6/kernel/drivers/char/hellop/hellop.ko
insmod 的缺省值是当前文件夹,上面的方式还可以采取如下:
#cd /lib/modules/2.6.28.6/kernel/drivers/char/hellop/
#insmod hellop.ko
插入PC上面的内核:
??
内核模块的查看:
#lsmod 查看内核上插入的内核模块。
#dmesg 查看缓冲区打印的东西。
modprobe 不需要路径:
插入板子上面的内核:
在板子系统下的任何的路径都可以。
#modprobe hello //注意这里不需要写后缀
插入PC内核:
??
内核模块的移除:
rmmod:没有路径的限制
无论在板子或者PC下面,在任何的路径:
#rmmod hello //注意这里也不许要写后缀
安装busybox:
1、解压busybox
#tar -vxf busybox-1.13.3-mini6410.tar.gz -C /home/luoyuntian/middle/
busybox文件在/home/luoyuntian/software/documents_teacher_middle/smdk6410_resource/src/目录下
2、制作.config文件
#cp fa.config .config
3、设置busybox(主要设置两点)
#make gconfig
在Busybox Settings 下的Bulid Options中 Cross Compiler prefix 的编译器前缀改成当前电脑中安装的类型。(可以在文件夹中查看:/usr/local/arm/arm-none-linux-gnueabi/bin查看)
在Busybox Settins 下的Installation Options下的BusybBox install prefix文件下:
将路径改为你想要的将系统安装上去的路径。
4、
#make
5、安装系统到第三步骤制定的文件当中
#make install
Time: 2012.10.23
Things: 中极课程第二天
theme: 1、内核模块的编写编译
2、内核模块的拷贝
3、内核模块的插入删除
4、busybox的安装
第一部分:内核模块的编写编译
第一小节:在任意文件夹下面编写内核代码:
1、内核模块的编写:hello.c 和 Makefile
//hello.c
#include
#include
MODULE_LICENSE("GPL");
static int __init hello_init(void)
{
printk("Hello,worldkdjfk(((((((((((((((((((((99!\n");
return 0;
}
static void __exit hello_exit(void)
{
printk("Goodbjdkfjdkfkdjfdjfkddddddd***********8ye world!\n");
}
module_init(hello_init);
module_exit(hello_exit);
//Makefile
obj-m :=hello.o
2、内核模块的编译
生成插入板子的内核模块:
#make -C /home/luoyuntian/linux-2.6.28_smdk6410/ modules
生成插入PC的内核模块:
#make -C usr/src/kernels/2.6.32-131.0.15.el6.i686/ modules
第二小节:在内核树里面编写与编译
1、内核的编写:
到~/dirvers/char/ 建立 hellop文件夹,
在hellop/文件下新建hellop.c 和 Makefile , Kconfig文件
//hellop.c
#include
#include
#include
static char *whom = "boy";
static int howmany = 1;
module_param(howmany, int, S_IRUGO);
module_param(whom, charp, S_IRUGO);
static int __init hellop_init(void)
{
int i;
for (i = 0; i < howmany; i++) {
printk("hello,%s\n", whom);
}
return 0;
}
static void __exit hellop_exit(void)
{
printk("Goodbye!\n");
}
module_init(hellop_init);
module_exit(hellop_exit);
MODULE_LICENSE("GPL");
//Makefile
obj-$(CONFIG_HELLOP) += hellop.o
//Kconfig
config HELLOP
tristate "This is hellop"
到~/drivers/char/ 下:
在Kconfig 文件中加入:
source "drivers/char/hellop/Kconfig"
在Makefile文件中加入:
obj-$(CONFIG_HELLOP) += hellop/ //注意这里的HELLOP要和前面的HELLOP一样。
第二部分:内核模块的拷贝
第一小节:在任意文件夹下面编写的内核代码
拷贝到PC的内核:
不需要拷贝,在任意目录下面直接调用
#modproble
拷贝到板子上的内核:
在/home/luoyuntian/linux-2.6.28_smdk6410/ 目录下面:
在hellop文件夹目录下面的方式:
#make -C /home/luoyuntian/linux-2.6.28_smdk6410/ M=$(pwd) INSTALL_MOD_PATH=/arm_system modules_install
拷贝结束以后:hellop.ko被放到了文件夹:/arm_system/lib/modules/2.6.28.6
第二小节:在内核树中编写的内核代码:
拷贝到PC的内核:
同上
拷贝到板子上的内核:
#make -C /home/luoyuntian/linux-2.6.28_smdk6410/ M=$(pwd) INSTALL_MOD_PATH=/arm_system modules_install
第一二部分的简便方式:
在任意文件夹下面建立:hellop.c 和 Makefile 和 Kconfig 文件
//hellop.c
同上
//Makefile
ifneq ($(KERNELRELEASE),)
obj-m := hellop.o
else
#KERNELDIR=/usr/src/kernels/2.6.32-131.0.15.el6.i686/ //不用安装直接用insmod 显示看效果
KERNELDIR=/home/luoyuntian/linux-2.6.28_smdk6410/
PWD := $(shell pwd)
default:
make -C $(KERNELDIR) M=$(PWD) modules //切换内核源码树
clean:
make -C $(KERNELDIR) M=$(PWD) clean
modules_install:
make -C $(KERNELDIR) M=$(PWD) INSTALL_MOD_PATH=/arm_system moudles_install
endif
第二部分:内核模块的插入、查看、移除:
内核模块的插入:
insmod 与 modprobe 的区别:
insmod 需要路径:
插入板子上面的内核:
在板子上面的/文件下,要安装内核模块的方式:
#insmod /lib/modules/2.6.28.6/kernel/drivers/char/hellop/hellop.ko
insmod 的缺省值是当前文件夹,上面的方式还可以采取如下:
#cd /lib/modules/2.6.28.6/kernel/drivers/char/hellop/
#insmod hellop.ko
插入PC上面的内核:
??
内核模块的查看:
#lsmod 查看内核上插入的内核模块。
#dmesg 查看缓冲区打印的东西。
modprobe 不需要路径:
插入板子上面的内核:
在板子系统下的任何的路径都可以。
#modprobe hello //注意这里不需要写后缀
插入PC内核:
??
内核模块的移除:
rmmod:没有路径的限制
无论在板子或者PC下面,在任何的路径:
#rmmod hello //注意这里也不许要写后缀
安装busybox:
1、解压busybox
#tar -vxf busybox-1.13.3-mini6410.tar.gz -C /home/luoyuntian/middle/
busybox文件在/home/luoyuntian/software/documents_teacher_middle/smdk6410_resource/src/目录下
2、制作.config文件
#cp fa.config .config
3、设置busybox(主要设置两点)
#make gconfig
在Busybox Settings 下的Bulid Options中 Cross Compiler prefix 的编译器前缀改成当前电脑中安装的类型。(可以在文件夹中查看:/usr/local/arm/arm-none-linux-gnueabi/bin查看)
arm-none-linux-gnueabi-
在Busybox Settins 下的Installation Options下的BusybBox install prefix文件下:
将路径改为你想要的将系统安装上去的路径。
4、
#make
5、安装系统到第三步骤制定的文件当中
#make install
构建Linux根文件系统:
第一步:移植安装busybox——Unix命令集合。
见上个文件。
第二步:使用glibc库:
安装lib库文件:
开发板上只需要加载器和动态库:
<1>安装加载器
在/usr/local/arm/arm-none-linux-gnueabi/arm-none-linux-gnueabi/libc/lib目录下找到两个文件
ld-2.8.so //动态程序启动前,被用来加载动态链接库
ld-linux.so.3 -> ld-2.8.so
<2>安装动态库
/*编译动态库时会用到动态库,但不会链接他们,运行时才链接*/
首先:查看需要那些动态库:
在文件夹下面:/home/luoyuntian/middle/install/bin 检查busybox的依赖关系
查看以来关系的方式:
#arm-none-linux-gnueabi-readelf -a /home/luoyuntian/middle/install/bin/busybox | grep "Shated"
libc.so.6
libcrypt.so.1
libm.so.6
然后:到交叉编译器libc文件的目录:/usr/local/arm/arm-none-linux-gnueabi/arm-none-linux-gnueabi/libc/lib
拷贝到/home/luoyuntian/middle/install/lib/目录下(但是拷贝的方式必须是这样的要带属性的拷贝过去):
cp $(copyfile) ~/lib/ -a
最后:在/home/luoyuntian/middle/install/lib/下 用#ll 命令查看上一步拷贝的几个文件所指向的文件
libc.so.6 -> libc-2.8.so
libcrypt.so.1 -> libcrypt-2.8.so
libm.so.6 -> libm-2.8.so
/* 说明:
libc-2.8.so //动态标准C库
libm-2.8.so //动态数学库
libcrypt-2.8.so //加密库
*/
第三步:构建根文件系统
1、构建etc目录
init进程根据/etc/inittab 文件来创建其他子进程:比如调用脚本文件配置IP地址、挂在其他文件系统,最后启动shell等。
<1>、创建etc/inittab文件
# /etc/inittab
::sysinit:/etc/init.d/rcS //运行脚本配置IP地址
ttySAC0::askfirst:~/bin/sh //串口上启动shell命令
::ctrlaltdel:/sbin/reboot //重启命令
::shutdown:/bin/umount -a -r //在关机的时候卸载所有的挂载
<2>、创建etc/init.d/rcS文件
# !bin/sh //表示这是一个脚本文件,运行时使用/bin/sh解析
ifconfig eth0 192.168.0.8 //板子的ip
mount -a //挂接/etc/fatab文件指定的所有文件系统
创建完成后,要改变它的属性,使它能够运行
#chmod +x etc/init.d/rcS
<3>、创建etc/fstab文件
内容如下,表示执行“mount -a”后将挂接在proc、tmpfs文件系统
# device mount-point type option dump fsck order
proc /proc proc defaults 0 0
tmpfs /tmp tmpfs defaults 0 0
2、构建dev目录
使用两种方法构建dev系统。
方法1:静态创建设备文件(节点)
从系统启动过程可知,涉及的设备有:/dev/mtdblock*(MTD)(MTD块设备),/dev/ttySAC*(串口设备)、/dev/console、/devnull,只要建立以下设备就可以启动系统。
在dev目录下:
#mknod console c 5 1
#mknod null c 1 3
#mknod ttySAC0 c 204 64
方法2:使用mdev创建设备文件
/*通过读取内核信息来创建设备文件的*/
#mount -t tmpfs mdev /dev //使用内核文件系统,减少对flash的读写
#mkdir /dev/pts //dev/pts用来支持外部网络链接(telnet)的虚拟终端
#mount -t devpts devpts /dev/pts
#mount -t sysfs sysfs /sys //mdev通过sysfs文件系统获得设备信息
#echo /bin/mdev>/proc/sys/kernel/hotplug //设置内核,当有设备插拔时调用/bin/mdev程序
#mdev -s //在/dev目录下生成内核支持的所有设备的节点
要在内核启动时,自动运行mdev。需要修改两个文件:etc/fstab来自动挂载文件系统、修改etc/init.d/rcS加入自动运行命令。
1:etc/fstab
# device mount-point type option dump fsck order
proc /proc proc defaults 0 0
tmpfs /tmp tmpfs defaults 0 0 //提高速度,减小磨损
sysfs /sys sysfs defaults 0 0 //告诉mdev有那些设备文件的操作
tmpfs /dev tmpfs defaults 0 0 //防止热插拔时减少磨损
2:etc/init.d/rcS
# !bin/sh //表示这是一个脚本文件,运行时使用/bin/sh解析
ifconfig eth0 192.168.0.8 //板子的ip
mount -a //挂接/etc/fatab文件指定的所有文件系统
mkdir /dev/pts
mount -t devpts devpts /dev/pts
echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s
需要注意的是:开发板上通过mdev生成的/dev目录中,S3C2410的串口名是s3c2410_serial 0。需要修改etc/inittab文件。
修改前:
ttySAC0::askfirst:~bin/sh
修改后:
s3c2410_serial0::askfirst:~/bin/sh
另外,mdev是通过init进程来启动的,在使用mdev构造/dev目录之前,init进程至少要用到设备文件/dev/console、/dev/null,所要建立这两个设备文件。
在构造的系统根目录下:
#mkdir -p dev
在dev目录下:
#mknod console c 5 1
#mknod null c 1 3
3、构建其他目录
其他目录可以为空,
在构建的跟文件夹下:
#mkdir proc mnt tmp sys root
构建Linux根文件系统:
第一步:移植安装busybox——Unix命令集合。
见上个文件。
第二步:使用glibc库:
安装lib库文件:
开发板上只需要加载器和动态库:
<1>安装加载器
在/usr/local/arm/arm-none-linux-gnueabi/arm-none-linux-gnueabi/libc/lib目录下找到两个文件
ld-2.8.so //动态程序启动前,被用来加载动态链接库
ld-linux.so.3 -> ld-2.8.so
<2>安装动态库
/*编译动态库时会用到动态库,但不会链接他们,运行时才链接*/
首先:查看需要那些动态库:
在文件夹下面:/home/luoyuntian/middle/install/bin 检查busybox的依赖关系
查看以来关系的方式:
#arm-none-linux-gnueabi-readelf -a /home/luoyuntian/middle/install/bin/busybox | grep "Shated"
libc.so.6
libcrypt.so.1
libm.so.6
然后:到交叉编译器libc文件的目录:/usr/local/arm/arm-none-linux-gnueabi/arm-none-linux-gnueabi/libc/lib
拷贝到/home/luoyuntian/middle/install/lib/目录下(但是拷贝的方式必须是这样的要带属性的拷贝过去):
cp $(copyfile) ~/lib/ -a
最后:在/home/luoyuntian/middle/install/lib/下 用#ll 命令查看上一步拷贝的几个文件所指向的文件
libc.so.6 -> libc-2.8.so
libcrypt.so.1 -> libcrypt-2.8.so
libm.so.6 -> libm-2.8.so
/* 说明:
libc-2.8.so //动态标准C库
libm-2.8.so //动态数学库
libcrypt-2.8.so //加密库
*/
第三步:构建根文件系统
1、构建etc目录
init进程根据/etc/inittab 文件来创建其他子进程:比如调用脚本文件配置IP地址、挂在其他文件系统,最后启动shell等。
<1>、创建etc/inittab文件
# /etc/inittab
::sysinit:/etc/init.d/rcS //运行脚本配置IP地址
ttySAC0::askfirst:~/bin/sh //串口上启动shell命令
::ctrlaltdel:/sbin/reboot //重启命令
::shutdown:/bin/umount -a -r //在关机的时候卸载所有的挂载
<2>、创建etc/init.d/rcS文件
# !bin/sh //表示这是一个脚本文件,运行时使用/bin/sh解析
ifconfig eth0 192.168.0.8 //板子的ip
mount -a //挂接/etc/fatab文件指定的所有文件系统
创建完成后,要改变它的属性,使它能够运行
#chmod +x etc/init.d/rcS
<3>、创建etc/fstab文件
内容如下,表示执行“mount -a”后将挂接在proc、tmpfs文件系统
# device mount-point type option dump fsck order
proc /proc proc defaults 0 0
tmpfs /tmp tmpfs defaults 0 0
2、构建dev目录
使用两种方法构建dev系统。
方法1:静态创建设备文件(节点)
从系统启动过程可知,涉及的设备有:/dev/mtdblock*(MTD)(MTD块设备),/dev/ttySAC*(串口设备)、/dev/console、/devnull,只要建立以下设备就可以启动系统。
在dev目录下:
#mknod console c 5 1
#mknod null c 1 3
#mknod ttySAC0 c 204 64
方法2:使用mdev创建设备文件
/*通过读取内核信息来创建设备文件的*/
#mount -t tmpfs mdev /dev //使用内核文件系统,减少对flash的读写
#mkdir /dev/pts //dev/pts用来支持外部网络链接(telnet)的虚拟终端
#mount -t devpts devpts /dev/pts
#mount -t sysfs sysfs /sys //mdev通过sysfs文件系统获得设备信息
#echo /bin/mdev>/proc/sys/kernel/hotplug //设置内核,当有设备插拔时调用/bin/mdev程序
#mdev -s //在/dev目录下生成内核支持的所有设备的节点
要在内核启动时,自动运行mdev。需要修改两个文件:etc/fstab来自动挂载文件系统、修改etc/init.d/rcS加入自动运行命令。
1:etc/fstab
# device mount-point type option dump fsck order
proc /proc proc defaults 0 0
tmpfs /tmp tmpfs defaults 0 0 //提高速度,减小磨损
sysfs /sys sysfs defaults 0 0 //告诉mdev有那些设备文件的操作
tmpfs /dev tmpfs defaults 0 0 //防止热插拔时减少磨损
2:etc/init.d/rcS
# !bin/sh //表示这是一个脚本文件,运行时使用/bin/sh解析
ifconfig eth0 192.168.0.8 //板子的ip
mount -a //挂接/etc/fatab文件指定的所有文件系统
mkdir /dev/pts
mount -t devpts devpts /dev/pts
echo /sbin/mdev > /proc/sys/kernel/hotplug
mdev -s
需要注意的是:开发板上通过mdev生成的/dev目录中,S3C2410的串口名是s3c2410_serial 0。需要修改etc/inittab文件。
修改前:
ttySAC0::askfirst:~bin/sh
修改后:
s3c2410_serial0::askfirst:~/bin/sh
另外,mdev是通过init进程来启动的,在使用mdev构造/dev目录之前,init进程至少要用到设备文件/dev/console、/dev/null,所要建立这两个设备文件。
在构造的系统根目录下:
#mkdir -p dev
在dev目录下:
#mknod console c 5 1
#mknod null c 1 3
3、构建其他目录
其他目录可以为空,
在构建的跟文件夹下:
#mkdir proc mnt tmp sys root
the theme of today : file opeartation
1.要想真的掌握还是需要花一点功夫。
《Linux环境高级编程》 《Linux程序设计》(这本书要看完)
2.下来后大家一定要多去看,因为操作系统这一部分呢一定要多去体会,去琢磨,去理解。
3.@search: poszx program rules
4.@search: API function, system call library function
5.about most of the OS the virtual space: 1G kernel space, 3G user space
6.user space: user program and lib function in user peogram
|
| call
V
kernel space:system call and kernel and drivers program in kernel
7.user mod -->user -->目态
kernel mod -->superrise -->管态
8.the second part of man datasheet is system function
9.文件描述符:file descriptor
head: #include
#include
#include
int open(const char *pathname, int flags)
int open(const char *pathname, int flags, mode_t mode) -->O_CREAT
return value: file descriptor -->success
or -1 -->fail
10.设备和文件的统一性时,可能会出现打开文件失败。因为可能有别的用户正在使用。
11.@man: exit() -->ask how to man
12.在main函数之前会有一段汇编程序先执行
13.exit(main()) -->ask what to do
14.truncated: a. 切短的, 缩短了的, 截短的, 削去尖角的
【计】 截去的
15. alter: change
16. optional: can choose
indicates
17.#man 2 read -> system function
#man 3 read -> system function
18. UNIX 是一套标准
Linux 是UNIX这套标准的一个实现
19.阻塞:
当一个程序因为一些原因不能继续进行。则称为阻塞。
20. 管道:echo hello the | ./test
定向:./test < test.c
21.每周总结这周学的东西。每周要魔鬼的训练自己。
22. @man fsync <-强制将数据真正写到磁盘或者其他下层设备上
@man lseek fseek ftrunc
23.文件在计算机中分成三部分:文件名, inode文件信息节点, 文件内容
@man stat ->将获取的文件状态保存到缓冲区 int stat(const char *path, struct stat *buf);
@man fstat ->
struct stat {
dev_t st_dev; /* ID of device containing file */
ino_t st_ino; /* inode number */
mode_t st_mode; /* protection */
nlink_t st_nlink; /* number of hard links */
uid_t st_uid; /* user ID of owner */
gid_t st_gid; /* group ID of owner */
dev_t st_rdev; /* device ID (if special file) */ //设备文件
off_t st_size; /* total size, in bytes */ //文件的大小
blksize_t st_blksize; /* blocksize for file system I/O */ //文件块的大小,所有的文件在磁盘上都是以块存在的。
blkcnt_t st_blocks; /* number of 512B blocks allocated */ //??
time_t st_atime; /* time of last access */ //
time_t st_mtime; /* time of last modification */ //最后修改时间
time_t st_ctime; /* time of last status change */ //最后状态改变时间。//状态保存在inode中,修改inode将会改变。
};
root 的id号为0
其他的用户,id号是从500开始的。
查看文件信息的方式:
#ll test.c
或者: #stat test.c
24. 缓冲带来的好处:
检查方法:time ./test
25. > 的用法:
将很多的文件拷贝到文件里去:
cat mstat.c open.c test.c >file.in
拷一次:cat mstat.c > test
cat open.c > test
26. #ls -l 显示目录下文件的具体信息 -->
访问权限:指向该文件的链接数:等等
#ls -lh 区别与#ls -l 将文件的大小以bit显示,#ls -lh 将文件的大小以KB显示。
the theme of today : file opeartation
1.要想真的掌握还是需要花一点功夫。
《Linux环境高级编程》 《Linux程序设计》(这本书要看完)
2.下来后大家一定要多去看,因为操作系统这一部分呢一定要多去体会,去琢磨,去理解。
3.@search: poszx program rules
4.@search: API function, system call library function
5.about most of the OS the virtual space: 1G kernel space, 3G user space
6.user space: user program and lib function in user peogram
|
| call
V
kernel space:system call and kernel and drivers program in kernel
7.user mod -->user -->目态
kernel mod -->superrise -->管态
8.the second part of man datasheet is system function
9.文件描述符:file descriptor
head: #include
#include
#include
int open(const char *pathname, int flags)
int open(const char *pathname, int flags, mode_t mode) -->O_CREAT
return value: file descriptor -->success
or -1 -->fail
10.设备和文件的统一性时,可能会出现打开文件失败。因为可能有别的用户正在使用。
11.@man: exit() -->ask how to man
12.在main函数之前会有一段汇编程序先执行
13.exit(main()) -->ask what to do
14.truncated: a. 切短的, 缩短了的, 截短的, 削去尖角的
【计】 截去的
15. alter: change
16. optional: can choose
indicates
17.#man 2 read -> system function
#man 3 read -> system function
18. UNIX 是一套标准
Linux 是UNIX这套标准的一个实现
19.阻塞:
当一个程序因为一些原因不能继续进行。则称为阻塞。
20. 管道:echo hello the | ./test
定向:./test < test.c
21.每周总结这周学的东西。每周要魔鬼的训练自己。
22. @man fsync <-强制将数据真正写到磁盘或者其他下层设备上
@man lseek fseek ftrunc
23.文件在计算机中分成三部分:文件名, inode文件信息节点, 文件内容
@man stat ->将获取的文件状态保存到缓冲区 int stat(const char *path, struct stat *buf);
@man fstat ->
struct stat {
dev_t st_dev; /* ID of device containing file */
ino_t st_ino; /* inode number */
mode_t st_mode; /* protection */
nlink_t st_nlink; /* number of hard links */
uid_t st_uid; /* user ID of owner */
gid_t st_gid; /* group ID of owner */
dev_t st_rdev; /* device ID (if special file) */ //设备文件
off_t st_size; /* total size, in bytes */ //文件的大小
blksize_t st_blksize; /* blocksize for file system I/O */ //文件块的大小,所有的文件在磁盘上都是以块存在的。
blkcnt_t st_blocks; /* number of 512B blocks allocated */ //??
time_t st_atime; /* time of last access */ //
time_t st_mtime; /* time of last modification */ //最后修改时间
time_t st_ctime; /* time of last status change */ //最后状态改变时间。//状态保存在inode中,修改inode将会改变。
};
root 的id号为0
其他的用户,id号是从500开始的。
查看文件信息的方式:
#ll test.c
或者: #stat test.c
24. 缓冲带来的好处:
检查方法:time ./test
25. > 的用法:
将很多的文件拷贝到文件里去:
cat mstat.c open.c test.c >file.in
拷一次:cat mstat.c > test
cat open.c > test
26. #ls -l 显示目录下文件的具体信息 -->
访问权限:指向该文件的链接数:等等
#ls -lh 区别与#ls -l 将文件的大小以bit显示,#ls -lh 将文件的大小以KB显示。
1.注册模块的方法
2.早期的字符设备注册方式:
3.新的字符设备注册方式:
4.
5.控制设备的属性
fcntl -->一般用于常规文件
ioctl -->一般用于设备文件
6.书籍上的每一个程序都需要去做。
7.在定义变量时,要注意:
int *fp = "kdfj";
int fp[4] = "kdfj";
他们的区别在于前者不可改变内容,而后者可以改变类用。以后在使用的过程中要特别的注意。当需要修改的时候,千万不能将变量设置成前者。因为前者在只读区。
8.袁——陈安之
行动 ——> 学习不是记笔记,而是练习。不断的练习。
1.if you want to rearch the kernel you can as to /init/main.c
2.rearch the start flow of kernel
3. BSD select
AT&T poll
4.@search :multiplexing
@search :redirect
@search :blocking and unblocking
5.@do : read man datasheet,if cann't understand you will not understand the kernel of the function
6.@search : pipe files
7.creat pipe files:
#mknod pip1 p
8.new created file right: 666
new created directory righe: 777
9.program:
first: dup.c //at the book
second: umask.c //at the book
third: poll.c //at the book
fourth: mplex.c //at the book
fifth: mmcat.c //at the book
sixth:
the second part: scan directory
10.we must know all the function of the kernel
eg. lstat
11.@search : sys/types > for function
@search : dirent.h
@search : chdir
12:
the third part: memory mapping //内存映射
13.@search: memory structure
14.@search: frame buffer
15.@search: #include
struct fb_var_screeninfo
16.@search: memcpy
the first part:
1.#ps list the process own to terminal
#ps aux list the process all
2.PID process identify
3.the most function of opeartion system --> provide platform
4.未初始化的全局变量和静态变量存放在bss段中的。
初始化的全局变量和静态变量存放在栈区
5.竞态:几个进程同时访问一个内存区域会同时竞争一个内存区域
并发:两个或以上的进程同时的运行
6.@启示:老师经常说:……最重要的是…… 研究过系统内核的人,都有经验,懂得二八法则。
7.感性认识
理性认识
8.总结:
今天讲了一下几个内容:
1.进程的结构
2.启动新的进程
1.创建进程:
system function
fork function
exec function : l:list;e:enviroment;v:argv
2.控制进程:
wait function
3.信号初步
kill function --> killer.c -->GUN/Linux programming
9.作业:
1.用内存映射来画sin函数
2.用内存映射来复制文件
10.刷新缓冲区的方式:
1.换行 \n
2.fflush函数
3.调用函数
11.休眠、挂起、待机三者之间的区别
挂起是一种省电模式,系统将机器的硬盘、显示器等外部设备停止工作,而CPU、内存仍然工作,等待用户随时唤醒,再次唤醒需要按键盘上的Fn键数次。
休眠是一种更加省电的模式,它将内存中的数据保存于硬盘中,使CPU也停止工作,当再次使用时需按开关机键,机器将会恢复到您的执行休眠时的状态,而不用再次执行启动Windows这个复杂的过程。
待机是将当前处于运行状态的数据保存在内存中,机器只对内存供电,而硬盘、屏幕和CPU等部件则停止供电。由于数据存储在速度快的内存中,因此进入等待状态和唤醒的速度比较快。不过这些数据是保存在内存中
,如果断电则会使数据丢失。
summarize:
1.the proprety of process
PID and PPID
getpid
getppid
Real and Effective
getuid
geteuid
getgid
getegid
SetUID and SetGID
#chmod g+s ids
Usr and Group
getlogin
getpwnam
Append information
process times count: times()
struct resuage
resource usage: struct tms
getrusage()
2.signal
send signal
kill
catch signal
set overtime alarm
pause pause
identify a signal edit function
sigemptyset
sigfillset
sigaddset
sigdelset
sigismember
regester a signal edit function
sigprocmsk
sigaction struct sigaction
check signal
sigpending