Jul 12, 2005
onlpara, Fedora Core 3 上で 2.6カーネル・ソースのインストール
--- 2.6カーネル・ソースのインストール #1
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
(http://www-online.kek.jp/~inoue/para-CAMAC/
Work/onlpara-2.6driver1.html)
高エネルギー加速器研究機構
素粒子原子核研究所
物理、オンライングループ
井上 栄二
目的
onlpara で稼動している Fedora Core 3 上に カーネル2.6用のソースを
インストールする。
項目
(1). カーネルソースのインストール
(2). Hello World カーネル・モジュールの作成および実行
--------------------------------------------------------------------
(1). カーネルソースのインストール
カーネルソースをインストールする。
[root@onlpara examples]# yum install kernel-source
Setting up Install Process
Setting up Repos
base 100% |=========================| 1.1 kB 00:00
updates-released 100% |=========================| 951 B 00:00
Reading repository metadata in from local files
base : ################################################## 2622/2622
updates-re: ################################################## 881/881
Parsing package install arguments
No Match for argument: kernel-source
Nothing to do
[root@onlpara examples]#
KDDIミラーサイトから、kernel-2.6.9-1.667.src.rpm をダウンロードした。
[root@onlpara KernelSource]# pwd
/home/inoue/KernelSource
[root@onlpara KernelSource]# ls -l
合計 39396
-rw-rw-r-- 1 inoue inoue 40291006 7月 8 2005 kernel-2.6.9-1.667.src.rpm
[root@onlpara KernelSource]#
[root@onlpara KernelSource]# rpm -ihv ./kernel-2.6.9-1.667.src.rpm
:
/etc/selinux/targeted/contexts/files/file_contexts: invalid context root:object
_r:texrel_shlib_t on line number 995
1:kernel ########################################### [100%]
[root@onlpara KernelSource]#
[root@onlpara KernelSource]# ls -lR /usr/src/redhat
/usr/src/redhat:
合計 40
drwxr-xr-x 2 root root 4096 11月 2 2004 BUILD
drwxr-xr-x 8 root root 4096 7月 7 10:29 RPMS
drwxr-xr-x 2 root root 4096 7月 8 14:17 SOURCES
drwxr-xr-x 2 root root 4096 7月 8 14:17 SPECS
drwxr-xr-x 2 root root 4096 11月 2 2004 SRPMS
/usr/src/redhat/BUILD:
合計 0
/usr/src/redhat/RPMS:
合計 48
drwxr-xr-x 2 root root 4096 11月 2 2004 athlon
drwxr-xr-x 2 root root 4096 11月 2 2004 i386
drwxr-xr-x 2 root root 4096 11月 2 2004 i486
drwxr-xr-x 2 root root 4096 11月 2 2004 i586
drwxr-xr-x 2 root root 4096 11月 2 2004 i686
drwxr-xr-x 2 root root 4096 11月 2 2004 noarch
/usr/src/redhat/RPMS/athlon:
合計 0
/usr/src/redhat/RPMS/i386:
合計 0
/usr/src/redhat/RPMS/i486:
合計 0
/usr/src/redhat/RPMS/i586:
合計 0
/usr/src/redhat/RPMS/i686:
合計 0
/usr/src/redhat/RPMS/noarch:
合計 0
/usr/src/redhat/SOURCES:
合計 41580
-rw-rw-r-- 1 root root 32823 9月 9 2004 COPYING.modules
-rw-rw-r-- 1 root root 139 9月 9 2004 genkey
-rw-rw-r-- 1 root root 50595 11月 3 2004 kernel-2.6.9-i586-smp.config
-rw-rw-r-- 1 root root 50671 11月 3 2004 kernel-2.6.9-i586.config
-rw-rw-r-- 1 root root 50760 11月 3 2004 kernel-2.6.9-i686-smp.config
-rw-rw-r-- 1 root root 50673 11月 3 2004 kernel-2.6.9-i686.config
-rw-rw-r-- 1 root root 48227 11月 3 2004 kernel-2.6.9-ia64.config
-rw-rw-r-- 1 root root 49892 11月 3 2004 kernel-2.6.9-ppc.config
-rw-rw-r-- 1 root root 49045 11月 3 2004 kernel-2.6.9-ppc64.config
-rw-rw-r-- 1 root root 49376 11月 3 2004 kernel-2.6.9-ppc64iseries.config
-rw-rw-r-- 1 root root 48511 11月 3 2004 kernel-2.6.9-s390.config
-rw-rw-r-- 1 root root 48478 11月 3 2004 kernel-2.6.9-s390x.config
-rw-rw-r-- 1 root root 48083 11月 3 2004 kernel-2.6.9-x86_64-smp.config
-rw-rw-r-- 1 root root 48118 11月 3 2004 kernel-2.6.9-x86_64.config
-rw-rw-r-- 1 root root 3448 9月 10 2004 linux-2.4.0-nonintconfig.patch
-rw-rw-r-- 1 root root 477 9月 9 2004 linux-2.4.0-test11-vidfail.patch
-rw-rw-r-- 1 root root 132031 10月 19 2004 linux-2.6.0-4g4g.patch
-rw-rw-r-- 1 root root 34947 10月 29 2004 linux-2.6.0-compile.patch
-rw-rw-r-- 1 root root 2363 9月 10 2004 linux-2.6.0-devmem.patch
-rw-rw-r-- 1 root root 45194 10月 13 2004 linux-2.6.0-exec-shield.patch
-rw-rw-r-- 1 root root 1334 9月 10 2004 linux-2.6.0-must_check.patch
-rw-rw-r-- 1 root root 7524 9月 10 2004 linux-2.6.0-sleepon.patch
-rw-rw-r-- 1 root root 3936 9月 10 2004 linux-2.6.1-s390-compile.patch
-rw-rw-r-- 1 root root 441 9月 20 2004 linux-2.6.2-ppc64-build.patch
-rw-rw-r-- 1 root root 342105 10月 13 2004 linux-2.6.2-tux.patch
-rw-rw-r-- 1 root root 12527 10月 13 2004 linux-2.6.3-crash-driver.patch
-rw-rw-r-- 1 root root 1393 9月 9 2004 linux-2.6.3-ia64-build.patch
-rw-rw-r-- 1 root root 3844 9月 9 2004 linux-2.6.3-printopen.patch
-rw-rw-r-- 1 root root 661 9月 9 2004 linux-2.6.3-sparc-addbzimage.patc
h
-rw-rw-r-- 1 root root 11438 9月 9 2004 linux-2.6.4-stackusage.patch
-rw-rw-r-- 1 root root 66863 10月 5 2004 linux-2.6.5-ext3-online-resize.pa
tch
-rw-rw-r-- 1 root root 41314 9月 10 2004 linux-2.6.5-ext3-reservations.pat
ch
-rw-rw-r-- 1 root root 4039 9月 10 2004 linux-2.6.5-nostack.patch
-rw-rw-r-- 1 root root 3875 9月 14 2004 linux-2.6.7-aic7xxx-diskdump.patc
h
-rw-rw-r-- 1 root root 15472 10月 15 2004 linux-2.6.7-devmem.patch
-rw-rw-r-- 1 root root 2016 9月 20 2004 linux-2.6.7-early-schedule.patch
-rw-rw-r-- 1 root root 4573 9月 9 2004 linux-2.6.7-hugetlb.patch
-rw-rw-r-- 1 root root 2944 9月 9 2004 linux-2.6.7-i8042.patch
-rw-rw-r-- 1 root root 3771 9月 20 2004 linux-2.6.7-iobitmap.patch
-rw-rw-r-- 1 root root 27997 10月 20 2004 linux-2.6.7-modsign-core.patch
-rw-rw-r-- 1 root root 2671 9月 9 2004 linux-2.6.7-modsign-crypto.patch
-rw-rw-r-- 1 root root 13382 10月 15 2004 linux-2.6.7-modsign-include.patch
-rw-rw-r-- 1 root root 36264 10月 15 2004 linux-2.6.7-modsign-ksign.patch
-rw-rw-r-- 1 root root 208518 9月 9 2004 linux-2.6.7-modsign-mpilib.patch
-rw-rw-r-- 1 root root 28528 10月 15 2004 linux-2.6.7-modsign-script.patch
-rw-rw-r-- 1 root root 32869 10月 13 2004 linux-2.6.7-netdump.patch
-rw-rw-r-- 1 root root 6116 11月 2 2004 linux-2.6.7-scsi-whitelist.patch
-rw-rw-r-- 1 root root 10717 9月 10 2004 linux-2.6.7-voluntary-preemption.
patch
-rw-rw-r-- 1 root root 17932 9月 20 2004 linux-2.6.8-4g4g-backout.patch
-rw-rw-r-- 1 root root 51935 10月 13 2004 linux-2.6.8-crashdump-common.patc
h
-rw-rw-r-- 1 root root 50731 10月 13 2004 linux-2.6.8-diskdump-3.patch
-rw-rw-r-- 1 root root 22497 10月 13 2004 linux-2.6.8-diskdump-scsi-3.patch
-rw-rw-r-- 1 root root 6499 9月 10 2004 linux-2.6.8-execshield-vaspace.pa
tch
-rw-rw-r-- 1 root root 30412 10月 15 2004 linux-2.6.8-ext3-reservations-upd
ate.patch
-rw-rw-r-- 1 root root 4330 11月 2 2004 linux-2.6.8-flexmmap-x86-64.patch
-rw-rw-r-- 1 root root 3431 10月 13 2004 linux-2.6.8-ipr-diskdump.patch
-rw-rw-r-- 1 root root 2351 10月 20 2004 linux-2.6.8-lockd-racewarn2.patch
-rw-rw-r-- 1 root root 5089 9月 14 2004 linux-2.6.8-mptfusion-diskdump.pa
tch
-rw-rw-r-- 1 root root 4310 10月 13 2004 linux-2.6.8-netconsole.patch
-rw-rw-r-- 1 root root 1142 10月 6 2004 linux-2.6.8-ppc64-netboot.patch
-rw-rw-r-- 1 root root 3799 9月 9 2004 linux-2.6.8-print-fatal-signals.p
atch
-rw-rw-r-- 1 root root 1856 10月 13 2004 linux-2.6.8-sym53c8xx-diskdump.pa
tch
-rw-rw-r-- 1 root root 7018 10月 23 2004 linux-2.6.9-ac-bits.patch
-rw-rw-r-- 1 root root 19308 10月 22 2004 linux-2.6.9-ac-security-bits.patc
h
-rw-rw-r-- 1 root root 1606 9月 10 2004 linux-2.6.9-blockfixes.patch
-rw-rw-r-- 1 root root 3343 10月 30 2004 linux-2.6.9-e820-EDID.patch
-rw-rw-r-- 1 root root 5196 9月 10 2004 linux-2.6.9-irqfixup.patch
-rw-rw-r-- 1 root root 82710 10月 13 2004 linux-2.6.9-kexec.patch
-rw-rw-r-- 1 root root 1018 10月 23 2004 linux-2.6.9-s390-autoraid.patch
-rw-rw-r-- 1 root root 34435 10月 19 2004 linux-2.6.9-sata.patch
-rw-rw-r-- 1 root root 108222 10月 19 2004 linux-2.6.9-speedtouch.patch
-rw-rw-r-- 1 root root 769 10月 29 2004 linux-2.6.9-vm-tame-oomkiller.pat
ch
-rw-rw-r-- 1 root root 72898 10月 6 2004 linux-2.6.9-xattr-rework-tmpfs-mm
.patch
-rw-rw-r-- 1 root root 36261440 10月 19 2004 linux-2.6.9.tar.bz2
-rw-rw-r-- 1 root root 5045 10月 19 2004 patch-2.6.9-final-bk2.bz2
-rw-rw-r-- 1 root root 3453171 10月 19 2004 patch-2.6.9-final.bz2
/usr/src/redhat/SPECS:
合計 44
-rw-rw-r-- 1 root root 39817 11月 3 2004 kernel-2.6.spec
/usr/src/redhat/SRPMS:
合計 0
[root@onlpara KernelSource]#
[root@onlpara KernelSource]# ls -l /usr/src/redhat/BUILD
合計 8
drwxr-xr-x 3 root root 4096 7月 8 14:29 kernel-2.6.9
[root@onlpara KernelSource]#
[root@onlpara KernelSource]# ls -l /usr/src/redhat/BUILD/kernel-2.6.9
合計 8
drwxr-xr-x 19 root root 4096 7月 8 14:30 linux-2.6.9
[root@onlpara KernelSource]#
[root@onlpara KernelSource]# ls -la /usr/src/redhat/BUILD/kernel-2.6.9/linux-2.6
.9
合計 544
drwxr-xr-x 19 root root 4096 7月 8 14:30 .
drwxr-xr-x 3 root root 4096 7月 8 14:29 ..
-rw-r--r-- 1 root root 50923 7月 8 14:30 .config
-rw-r--r-- 1 root root 4798 7月 8 14:30 .config.cmd
-rw-r--r-- 1 root root 50673 7月 8 14:30 .config.old
-rw-r--r-- 1 root root 18691 10月 19 2004 COPYING
-rw-r--r-- 1 root root 88031 10月 19 2004 CREDITS
drwxr-xr-x 45 root root 4096 7月 8 14:30 Documentation
-rw-r--r-- 1 root root 54798 7月 8 14:30 MAINTAINERS
-rw-r--r-- 1 root root 42219 7月 8 14:30 Makefile
-rw-r--r-- 1 root root 13970 10月 19 2004 README
-rw-r--r-- 1 root root 2815 10月 19 2004 REPORTING-BUGS
drwxr-xr-x 24 root root 4096 10月 19 2004 arch
drwxr-xr-x 2 root root 4096 7月 8 14:30 configs
drwxr-xr-x 4 root root 4096 7月 8 14:30 crypto
drwxr-xr-x 46 root root 4096 10月 19 2004 drivers
drwxr-xr-x 54 root root 4096 7月 8 14:30 fs
drwxr-xr-x 36 root root 4096 10月 19 2004 include
drwxr-xr-x 2 root root 4096 7月 8 14:30 init
drwxr-xr-x 2 root root 4096 10月 19 2004 ipc
drwxr-xr-x 3 root root 4096 7月 8 14:30 kernel
drwxr-xr-x 4 root root 4096 10月 19 2004 lib
drwxr-xr-x 2 root root 4096 7月 8 14:30 mm
drwxr-xr-x 33 root root 4096 7月 8 14:30 net
drwxr-xr-x 10 root root 4096 7月 8 14:30 scripts
drwxr-xr-x 3 root root 4096 10月 19 2004 security
drwxr-xr-x 15 root root 4096 10月 19 2004 sound
drwxr-xr-x 2 root root 4096 10月 19 2004 usr
[root@onlpara KernelSource]#
[root@onlpara KernelSource]# mv /usr/src/redhat/BUILD/kernel-2.6.9/linux-2.6.9 /
usr/src
[root@onlpara KernelSource]#
[root@onlpara KernelSource]# ls /usr/src/linux-2.6.9
COPYING Makefile configs include lib security
CREDITS README crypto init mm sound
Documentation REPORTING-BUGS drivers ipc net usr
MAINTAINERS arch fs kernel scripts
[root@onlpara KernelSource]#
これでカーネルソースのインストールができた。
(2). Hello World カーネル・モジュールの作成および実行
Hello World モジュールを作成して、実行してみる。
[inoue@onlpara examples]$ pwd
/home/inoue/DeviceDriverExamples/Oreilly/examples
[inoue@onlpara examples]$ ls -l
合計 168
-rw-r--r-- 1 inoue inoue 1091 2月 1 05:31 LICENSE
-rw-r--r-- 1 inoue inoue 289 7月 8 15:41 Makefile
-rw-r--r-- 1 inoue inoue 289 7月 8 15:39 Makefile-org
drwxr-xr-x 2 inoue inoue 4096 2月 1 05:31 include
drwxr-xr-x 2 inoue inoue 4096 2月 1 05:31 lddbus
drwxr-xr-x 3 inoue inoue 4096 7月 8 16:39 misc-modules
drwxr-xr-x 2 inoue inoue 4096 7月 8 16:38 misc-progs
drwxr-xr-x 2 inoue inoue 4096 2月 1 05:31 pci
drwxr-xr-x 2 inoue inoue 4096 2月 1 05:31 sbull
drwxr-xr-x 2 inoue inoue 4096 2月 1 05:31 scull
drwxr-xr-x 2 inoue inoue 4096 2月 1 05:31 scullc
drwxr-xr-x 2 inoue inoue 4096 2月 1 05:31 sculld
drwxr-xr-x 2 inoue inoue 4096 2月 1 05:31 scullp
drwxr-xr-x 2 inoue inoue 4096 2月 1 05:31 scullv
drwxr-xr-x 2 inoue inoue 4096 2月 1 05:31 short
drwxr-xr-x 2 inoue inoue 4096 2月 1 05:31 shortprint
drwxr-xr-x 2 inoue inoue 4096 2月 1 05:31 simple
drwxr-xr-x 2 inoue inoue 4096 2月 1 05:31 skull
drwxr-xr-x 2 inoue inoue 4096 2月 1 05:31 snull
drwxr-xr-x 2 inoue inoue 4096 2月 1 05:31 tty
drwxr-xr-x 2 inoue inoue 4096 2月 1 05:31 usb
[inoue@onlpara examples]$
[inoue@onlpara examples]$ make
for n in misc-progs misc-modules skull scull scullc sculld scullp scullv sbull s
null short shortprint pci simple usb tty lddbus; do make -C $n || exit 1; done
make[1]: Entering directory `/home/inoue/DeviceDriverExamples/Oreilly/examples/m
isc-progs'
cc -O2 -fomit-frame-pointer -Wall -I/lib/modules/2.6.9-1.667/build/include in
p.c -o inp
/lib/modules/2.6.9-1.667/build/include/asm/io.h:4 から include されたファイル中,
inp.c:33 から:
/lib/modules/2.6.9-1.667/build/include/linux/config.h:6:2: #error including kern
el header in userspace; use the glibc headers instead!
make[1]: *** [inp] エラー 1
make[1]: Leaving directory `/home/inoue/DeviceDriverExamples/Oreilly/examples/mi
sc-progs'
make: *** [subdirs] エラー 1
[inoue@onlpara examples]$
[inoue@onlpara examples]$ find . -name hello.c -print
./misc-modules/hello.c
[inoue@onlpara examples]$
[inoue@onlpara examples]$ cd misc-modules
[inoue@onlpara misc-modules]$
[inoue@onlpara misc-modules]$ ls -l
合計 108
-rw-r--r-- 1 inoue inoue 987 2月 1 05:31 Makefile
-rw-r--r-- 1 inoue inoue 2128 2月 1 05:31 complete.c
-rw-r--r-- 1 inoue inoue 2000 2月 1 05:31 faulty.c
-rw-r--r-- 1 inoue inoue 463 2月 1 05:31 hello.c
-rw-r--r-- 1 inoue inoue 1130 2月 1 05:31 hellop.c
-rw-r--r-- 1 inoue inoue 6194 2月 1 05:31 jiq.c
-rw-r--r-- 1 inoue inoue 7571 2月 1 05:31 jit.c
-rw-r--r-- 1 inoue inoue 2293 2月 1 05:31 kdataalign.c
-rw-r--r-- 1 inoue inoue 1489 2月 1 05:31 kdatasize.c
-rw-r--r-- 1 inoue inoue 2044 2月 1 05:31 seq.c
-rw-r--r-- 1 inoue inoue 6200 2月 1 05:31 silly.c
-rw-r--r-- 1 inoue inoue 2161 2月 1 05:31 sleepy.c
[inoue@onlpara misc-modules]$
[inoue@onlpara misc-modules]$ make
make -C /lib/modules/2.6.9-1.667/build M=/home/inoue/DeviceDriverExamples/Oreill
y/examples/misc-modules modules
make[1]: Entering directory `/lib/modules/2.6.9-1.667/build'
CC [M] /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/hello.o
CC [M] /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/hellop.
o
CC [M] /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/seq.o
CC [M] /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/jit.o
CC [M] /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/jiq.o
/home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/jiq.c: In functio
n `jiq_read_tasklet':
/home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/jiq.c:190: 警告:
`interruptible_sleep_on' is deprecated (declared at include/linux/wait.h:290)
/home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/jiq.c: In functio
n `jiq_read_run_timer':
/home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/jiq.c:227: 警告:
`interruptible_sleep_on' is deprecated (declared at include/linux/wait.h:290)
CC [M] /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/sleepy.
o
CC [M] /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/complet
e.o
CC [M] /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/silly.o
CC [M] /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/faulty.
o
CC [M] /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/kdatasi
ze.o
CC [M] /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/kdataal
ign.o
Building modules, stage 2.
MODPOST
CC /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/complet
e.mod.o
LD [M] /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/complet
e.ko
CC /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/faulty.
mod.o
LD [M] /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/faulty.
ko
CC /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/hello.m
od.o
LD [M] /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/hello.k
o
CC /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/hellop.
mod.o
LD [M] /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/hellop.
ko
CC /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/jiq.mod
.o
LD [M] /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/jiq.ko
CC /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/jit.mod
.o
LD [M] /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/jit.ko
CC /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/kdataal
ign.mod.o
LD [M] /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/kdataal
ign.ko
CC /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/kdatasi
ze.mod.o
LD [M] /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/kdatasi
ze.ko
CC /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/seq.mod
.o
LD [M] /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/seq.ko
CC /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/silly.m
od.o
LD [M] /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/silly.k
o
CC /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/sleepy.
mod.o
LD [M] /home/inoue/DeviceDriverExamples/Oreilly/examples/misc-modules/sleepy.
ko
make[1]: Leaving directory `/lib/modules/2.6.9-1.667/build'
[inoue@onlpara misc-modules]$
[inoue@onlpara misc-modules]$ ls -l hello*
-rw-r--r-- 1 inoue inoue 463 2月 1 05:31 hello.c
-rw-rw-r-- 1 inoue inoue 50888 7月 12 15:23 hello.ko
-rw-rw-r-- 1 inoue inoue 632 7月 12 15:23 hello.mod.c
-rw-rw-r-- 1 inoue inoue 28300 7月 12 15:23 hello.mod.o
-rw-rw-r-- 1 inoue inoue 23520 7月 12 15:23 hello.o
-rw-r--r-- 1 inoue inoue 1130 2月 1 05:31 hellop.c
-rw-rw-r-- 1 inoue inoue 52481 7月 12 15:23 hellop.ko
-rw-rw-r-- 1 inoue inoue 772 7月 12 15:23 hellop.mod.c
-rw-rw-r-- 1 inoue inoue 28560 7月 12 15:23 hellop.mod.o
-rw-rw-r-- 1 inoue inoue 24792 7月 12 15:23 hellop.o
[inoue@onlpara misc-modules]$
[inoue@onlpara misc-modules]$ cat hello.c
/*
* $Id: hello.c,v 1.5 2004/10/26 03:32:21 corbet Exp $
*/
#include
#include
MODULE_LICENSE("Dual BSD/GPL");
static int hello_init(void)
{
printk(KERN_ALERT "Hello, world\n");
return 0;
}
static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye, cruel world\n");
}
module_init(hello_init);
module_exit(hello_exit);
[inoue@onlpara misc-modules]$
[root@onlpara misc-modules]# /sbin/lsmod
Module Size Used by
loop 15561 0
nfsd 204641 9
exportfs 8001 1 nfsd
lockd 63241 2 nfsd
parport_pc 24705 1
lp 11565 0
parport 41737 2 parport_pc,lp
autofs4 24005 0
i2c_dev 10433 0
i2c_core 22081 1 i2c_dev
sunrpc 160421 19 nfsd,lockd
iptable_filter 2753 0
ip_tables 16193 1 iptable_filter
dm_mod 54741 0
button 6481 0
battery 8517 0
ac 4805 0
md5 4033 1
ipv6 232577 10
uhci_hcd 31449 0
ehci_hcd 31557 0
hw_random 5589 0
snd_intel8x0 34829 0
snd_ac97_codec 64401 1 snd_intel8x0
snd_pcm_oss 47609 0
snd_mixer_oss 17217 1 snd_pcm_oss
snd_pcm 97993 2 snd_intel8x0,snd_pcm_oss
snd_timer 29765 1 snd_pcm
snd_page_alloc 9673 2 snd_intel8x0,snd_pcm
gameport 4801 1 snd_intel8x0
snd_mpu401_uart 8769 1 snd_intel8x0
snd_rawmidi 26725 1 snd_mpu401_uart
snd_seq_device 8137 1 snd_rawmidi
snd 54053 9 snd_intel8x0,snd_ac97_codec,snd_pcm_oss,snd_mixe
r_oss,snd_pcm,snd_timer,snd_mpu401_uart,snd_rawmidi,snd_seq_device
soundcore 9889 1 snd
e100 39364 0
mii 4673 1 e100
floppy 58609 0
ext3 116809 3
jbd 74969 1 ext3
[root@onlpara misc-modules]#
[root@onlpara misc-modules]# /sbin/insmod ./hello.ko
[root@onlpara misc-modules]#
[root@onlpara misc-modules]# /sbin/rmmod hello
[root@onlpara misc-modules]#
[root@onlpara misc-modules]# tail /var/log/messages
Jul 12 15:15:02 onlpara crond(pam_unix)[2771]: session closed for user root
Jul 12 15:20:01 onlpara crond(pam_unix)[2776]: session opened for user root by (
uid=0)
Jul 12 15:20:01 onlpara crond(pam_unix)[2775]: session opened for user root by (
uid=0)
Jul 12 15:20:01 onlpara crond(pam_unix)[2776]: session closed for user root
Jul 12 15:20:01 onlpara crond(pam_unix)[2775]: session closed for user root
Jul 12 15:25:01 onlpara crond(pam_unix)[3070]: session opened for user root by (
uid=0)
Jul 12 15:25:02 onlpara crond(pam_unix)[3070]: session closed for user root
Jul 12 15:25:28 onlpara su(pam_unix)[3073]: session opened for user root by inou
e(uid=500)
Jul 12 15:26:39 onlpara kernel: Hello, world
Jul 12 15:26:57 onlpara kernel: Goodbye, cruel world
[root@onlpara misc-modules]#
[root@onlpara misc-modules]# /sbin/insmod ./hello.ko
[root@onlpara misc-modules]#
[root@onlpara misc-modules]# /sbin/lsmod
Module Size Used by
hello 1536 0
loop 15561 0
nfsd 204641 9
exportfs 8001 1 nfsd
lockd 63241 2 nfsd
parport_pc 24705 1
lp 11565 0
parport 41737 2 parport_pc,lp
autofs4 24005 0
i2c_dev 10433 0
i2c_core 22081 1 i2c_dev
sunrpc 160421 19 nfsd,lockd
iptable_filter 2753 0
ip_tables 16193 1 iptable_filter
dm_mod 54741 0
button 6481 0
battery 8517 0
ac 4805 0
md5 4033 1
ipv6 232577 10
uhci_hcd 31449 0
ehci_hcd 31557 0
hw_random 5589 0
snd_intel8x0 34829 0
snd_ac97_codec 64401 1 snd_intel8x0
snd_pcm_oss 47609 0
snd_mixer_oss 17217 1 snd_pcm_oss
snd_pcm 97993 2 snd_intel8x0,snd_pcm_oss
snd_timer 29765 1 snd_pcm
snd_page_alloc 9673 2 snd_intel8x0,snd_pcm
gameport 4801 1 snd_intel8x0
snd_mpu401_uart 8769 1 snd_intel8x0
snd_rawmidi 26725 1 snd_mpu401_uart
snd_seq_device 8137 1 snd_rawmidi
snd 54053 9 snd_intel8x0,snd_ac97_codec,snd_pcm_oss,snd_mixe
r_oss,snd_pcm,snd_timer,snd_mpu401_uart,snd_rawmidi,snd_seq_device
soundcore 9889 1 snd
e100 39364 0
mii 4673 1 e100
floppy 58609 0
ext3 116809 3
jbd 74969 1 ext3
[root@onlpara misc-modules]#
[root@onlpara misc-modules]# /sbin/rmmod hello
[root@onlpara misc-modules]#
[root@onlpara misc-modules]# /sbin/lsmod
Module Size Used by
loop 15561 0
nfsd 204641 9
exportfs 8001 1 nfsd
lockd 63241 2 nfsd
parport_pc 24705 1
lp 11565 0
parport 41737 2 parport_pc,lp
autofs4 24005 0
i2c_dev 10433 0
i2c_core 22081 1 i2c_dev
sunrpc 160421 19 nfsd,lockd
iptable_filter 2753 0
ip_tables 16193 1 iptable_filter
dm_mod 54741 0
button 6481 0
battery 8517 0
ac 4805 0
md5 4033 1
ipv6 232577 10
uhci_hcd 31449 0
ehci_hcd 31557 0
hw_random 5589 0
snd_intel8x0 34829 0
snd_ac97_codec 64401 1 snd_intel8x0
snd_pcm_oss 47609 0
snd_mixer_oss 17217 1 snd_pcm_oss
snd_pcm 97993 2 snd_intel8x0,snd_pcm_oss
snd_timer 29765 1 snd_pcm
snd_page_alloc 9673 2 snd_intel8x0,snd_pcm
gameport 4801 1 snd_intel8x0
snd_mpu401_uart 8769 1 snd_intel8x0
snd_rawmidi 26725 1 snd_mpu401_uart
snd_seq_device 8137 1 snd_rawmidi
snd 54053 9 snd_intel8x0,snd_ac97_codec,snd_pcm_oss,snd_mixe
r_oss,snd_pcm,snd_timer,snd_mpu401_uart,snd_rawmidi,snd_seq_device
soundcore 9889 1 snd
e100 39364 0
mii 4673 1 e100
floppy 58609 0
ext3 116809 3
jbd 74969 1 ext3
[root@onlpara misc-modules]#
ok. 正常に実行できた。
---xxxx