




已阅读5页,还剩15页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
Linux 内核裁剪的自动化方法Linux 内核裁剪的自动化方法随着广泛地获得使用并被移植到不同的平台,Linux 内核源代码正在越来越大,比如, Linux 2.6.28 中, 文件数有 25282 个,大小有350M。 对于某一个平台,真正需要的的文件其实不到 10%, 为了提高研发效率,我们应当删除或者暂时删除那些永远也不会用到的文件, 比如,可以使内核的文件数缩减到5000, 从而节约拷贝、查找等的时间,提高研发效率。 本文提出一种高效、干净的进行内核裁剪的办法。以往,我们是通过手工删除某些目录来完成这个任务的。 手工删除的缺点有:1.花时间,每次裁剪都要花 1 2 天, 才能将文件数目删除到 5000 以下。2.不够干净。 内核代码的 Makefile 以及 Kconfig 配置文件彼此的依赖性比较大, 即使某个目录下的功能不被使用,直接删除也会导致编译出错, 从而, 不得不修改相应的 Makefile 以及 Kconfig 才能使编译通过。 这留下一下隐患。3.恢复困难。 根据2)的描述,在我们对外发布完整版本而需要将以前删除、修改的文件复原时,需要使用比较工具,仔细地比对,才能完整恢复, 这也非常花时间。 在经历了手工操作的痛苦之后,我们提出了一种自动化的方法。具体为:1.只删除文件,不删除目录,保留 Makefile 及 Kconfig2.使用时,只需要填充一个配置表,其中,可以指定:1.删除某个文件, 比如:drivers/macintosh/adbhid.c2.删除某个目录下的匹配文件, 比如:include/asm-arm/hardware/*.h3.删除某个目录及其子目录下的匹配文件,比如:drivers/block/#.c4.删除某个目录及其子目录下的适合删除文件, 比如:arch/alpha/#3.脚本会根据配置表,将相关的文件移动到一备份目录,并保持原有的目录结构4.需要恢复时,只需要将备份目录下的文件拷贝到原来的目录,既可。 优点如下:1.配置文件一次指定,可反复使用, 对同一内核,不需要更改就可以再次运行。对不同内核,只要稍作修改(内核的目录结构不怎么变化),既可复用。2.配置文件指定后,裁剪及备份内核的操作可以在几秒内完成,大大提高的效率。3.由于我们只删除 *.c, *.h, *.txt 等文件,而不删除编译相关的配置文件,裁剪后的内核特别干净,不会影响编译。打外部 patch 也特别容易。4.需要对外发布版本时,可以直接运行 restore.sh 脚本,瞬间完成。5.由于操作的可反复性,我们可以不断优化裁剪列表,得到最小内核。最大程度地提高研发效率。 以下为例子配置文件:# README #here to specify which files(unused in your project) to move#you can specify a relative directory with file name followed#you can specify # *.c to mean all c files below the dir # #.c to mean all c files below the dir and subdir# # to mean all files of known type below the dir and subdir# # Example:# drivers/macintosh/adbhid.c# drivers/dio/*.c# drivers/block/#.c# drivers/dio/#*kernel version: 2.6.25# arch/#arch/alpha/#arch/avr32/#arch/blackfin/#arch/cris/#arch/frv/#arch/h8300/#arch/ia64/#arch/m32r/#arch/m68k/#arch/m68knommu/#arch/mips/#arch/mn10300/#arch/parisc/#arch/powerpc/#arch/ppc/#arch/s390/#arch/sh/#arch/sparc/#arch/sparc64/#arch/v850/#arch/x86/#arch/xtensa/# arch/arm#arch/arm/mach-s3c2442/#arch/arm/mach-imx/#arch/arm/mach-s3c2440/#arch/arm/mach-omap2/#arch/arm/mach-clps711x/#arch/arm/mach-s3c2443/#arch/arm/plat-iop/#arch/arm/mach-davinci/#arch/arm/mach-ixp2000/#arch/arm/mach-iop13xx/#arch/arm/mach-integrator/#arch/arm/mach-iop33x/#arch/arm/plat-s3c24xx/#arch/arm/plat-s3c/#arch/arm/plat-omap/#arch/arm/mach-sa1100/#arch/arm/mach-omap1/#arch/arm/mach-aaec2000/#arch/arm/mach-ixp23xx/#arch/arm/mach-mx3/#arch/arm/mach-l7200/#arch/arm/mach-ixp4xx/#arch/arm/mach-at91/#arch/arm/mach-clps7500/#arch/arm/mach-rpc/#arch/arm/mach-s3c2400/#arch/arm/plat-mxc/#arch/arm/mach-iop32x/#arch/arm/mach-footbridge/#arch/arm/mach-h720x/#arch/arm/mach-ep93xx/#arch/arm/mach-ebsa110/#arch/arm/mach-realview/#arch/arm/mach-s3c2412/#arch/arm/mach-ns9xxx/#arch/arm/mach-orion/#arch/arm/mach-shark/#arch/arm/mach-netx/#arch/arm/mach-pnx4008/#arch/arm/mach-s3c2410/#arch/arm/mach-lh7a40x/#arch/arm/mach-ks8695/#arch/arm/mach-versatile/#arch/arm/mach-msm/# Documetation#Documentation/# drivers #drivers/acorn/#drivers/acpi/#drivers/amba/#drivers/ata/#drivers/atm/#drivers/auxdisplay/#drivers/cdrom/#drivers/dca/#drivers/dio/#drivers/edac/#drivers/eisa/#drivers/ide/#drivers/ieee1394/#drivers/infiniband/#drivers/isdn/#drivers/macintosh/#drivers/mca/#drivers/md/#drivers/memstick/#drivers/nubus/#drivers/of/#drivers/parisc/#drivers/parport/#drivers/pci/#drivers/pcmcia/#drivers/pnp/#drivers/ps3/#drivers/rapidio/#drivers/s390/#drivers/sbus/#drivers/sh/#drivers/sn/#drivers/ssb/#drivers/telephony/#drivers/thermal/#drivers/xen/#drivers/zorro/# drivers/char #drivers/char/agp/#drivers/char/mwave/#drivers/char/pcmcia/#drivers/char/rio/#drivers/char/drm/# drivers/net #drivers/net/appletalk/#drivers/net/ibm_emac/#drivers/net/ibm_newemac/#drivers/net/ixp2000/#drivers/net/pcmcia/#drivers/net/tokenring/# drivers/scsi #drivers/scsi/aic7xxx/#drivers/scsi/aic7xxx_old/#drivers/scsi/aic94xx/#drivers/scsi/lpfc/#drivers/scsi/pcmcia/#drivers/scsi/qla2xxx/#drivers/scsi/qla4xxx/#drivers/scsi/sym53c8xx_2/# drivers/media #drivers/media/dvb/# drivers/media/video #drivers/media/video/bt8xx/#drivers/media/video/cpia2/#drivers/media/video/cx23885/#drivers/media/video/cx25840/#drivers/media/video/em28xx/#drivers/media/video/ivtv/#drivers/media/video/pvrusb2/#drivers/media/video/saa7134/#drivers/media/video/sn9c102/#drivers/media/video/zc0301/# fs #fs/9p/#fs/afs/#fs/adfs/#fs/affs/#fs/bfs/#fs/befs/#fs/coda/#fs/dlm/#fs/freevxfs/#fs/gfs2/#fs/hfs/#fs/hfsplus/#fs/hpfs/#fs/isofs/#fs/jbd/#fs/jbd2/#fs/jfs/#fs/minix/#fs/ntfs/#fs/ncpfs/#fs/ocfs2/#fs/qnx4/#fs/udf/#fs/ufs/#fs/xfs/# include #include/acpi/#include/asm-alpha/#include/asm-avr32/#include/asm-blackfin/#include/asm-cris/#include/asm-frv/#include/asm-h8300/#include/asm-ia64/#include/asm-m32r/#include/asm-m68k/#include/asm-m68knommu/#include/asm-mips/#include/asm-mn10300/#include/asm-parisc/#include/asm-powerpc/#include/asm-ppc/#include/asm-s390/#include/asm-sh/#include/asm-sparc/#include/asm-sparc64/#include/asm-um/#include/asm-v850/#include/asm-x86/#include/asm-xtensa/#include/pcmcia/# include/asm-arm #include/asm-arm/arch-ks8695/#include/asm-arm/arch-iop33x/#include/asm-arm/arch-mxc/#include/asm-arm/arch-iop32x/#include/asm-arm/arch-ep93xx/#include/asm-arm/arch-h720x/#include/asm-arm/arch-iop13xx/#include/asm-arm/arch-ns9xxx/#include/asm-arm/arch-ebsa285/#include/asm-arm/arch-orion/#include/asm-arm/arch-ixp2000/#include/asm-arm/arch-s3c2400/#include/asm-arm/arch-msm/#include/asm-arm/arch-ixp4xx/#include/asm-arm/arch-lh7a40x/#include/asm-arm/arch-ebsa110/#include/asm-arm/arch-netx/#include/asm-arm/arch-imx/#include/asm-arm/arch-ixp23xx/#include/asm-arm/arch-davinci/#include/asm-arm/arch-sa1100/#include/asm-arm/plat-s3c24xx/#include/asm-arm/plat-s3c/#include/asm-arm/arch-l7200/#include/asm-arm/arch-versatile/#include/asm-arm/arch-clps711x/#include/asm-arm/arch-aaec2000/#include/asm-arm/arch-cl7500/#.h include/asm-arm/arch-pnx4008/#include/asm-arm/arch-integrator/#include/asm-arm/arch-at91/#include/asm-arm/arch-shark/#include/asm-arm/arch-rpc/#include/asm-arm/arch-s3c2410/#include/asm-arm/arch-realview/# net/#net/ax25/#net/can/#net/decnet/#net/ipv6/#net/x25/# sound/#sound/aoa/#sound/isa/#sound/mips/#sound/oss/#sound/parisc/#sound/pci/#sound/pcmcia/#sound/ppc/#sound/sh/#sound/sparc/#以下为备份脚本:#! /bin/bash#name: move.sh#function: move unused files from kernel to make size smaller#set -x function usage() echo Usage: $0 filename echo filename is the file that includes files to be deleted echo if not provided, filename default to to_delete_files if $# -ne 1 ; then INPUT_FILE=to_cutoff_files echo inputfile default to $INPUT_FILEelse if $1 = -h ; then usage exit 0 fi INPUT_FILE=$1fi BASE_ORIG=cd .; pwd/BASE_NEW=cd files; pwd/FILES_LIST=.$INPUT_FILE_detailedrm -f $FILES_LIST #echo restore files#cp -a files/* ./ 2/dev/null#rm -rf files/* 2 /dev/null echo generate detailed file list.cat $INPUT_FILE | grep -v # | while read LINEdo if ! -z $LINE ; then if expr index $LINE # != 0 ; then DIR_ORIG=$BASE_ORIG$LINE DIR_ORIG=$DIR_ORIG%/* find $DIR_ORIG -name *.h $FILES_LIST find $DIR_ORIG -name *.c $FILES_LIST find $DIR_ORIG -name *.S $FILES_LIST find $DIR_ORIG -nam
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 县审计局党风廉政工作总结
- 公司用人制度管理制度
- 公司财务招待管理制度
- 2025合作协议包括哪些内容
- 河北省石家庄市2024-2025学年高二下册3月月考数学试卷附解析
- 广东省东莞市2024-2025学年高二下册第一次月考数学试卷附解析
- 2024~2025学年 浙江省宁波市高二语文上册9月学情诊断试卷附答案
- 重庆市彭水中学高级高考文综政治练习短卷发展质量和效益
- 2024年泗县事业单位招聘真题
- 乡镇防水排渍工作汇报
- 农村三资管理
- 【初中地理】七年级地理下册全册期末总复习(课件)-2024-2025学年七年级地理课件(人教版2024年)
- 2025年全国青少年禁毒知识竞赛题库附答案(共150题)
- 道路工程外文文献翻译
- 王洪图黄帝内经80课时讲稿
- A4作文格子纸打印版文档
- dsa技师试题1全国大型医用设备工程技术人员上岗资质考核试卷DSA
- 五年级下册语文第七单元复习(人物描写复习)(课堂PPT)
- 胶水化学品安全技术说明书(MSDS)
- BIM与Revit软件简介PPT课件
- 患者翻身记录表
评论
0/150
提交评论