????????????????:
????????裺
????(1) ??/usr/src/linux/??????make menuconfig???????????????????(M)?????沢?????
????(2) ????make modules???????????/usr/src/linux/??????*.o??*.ko?????
????(3) ????make modeules_install?????????????????.o??ko?????????/lib/modules/`uname -r`/???
?????????????????????????飬???????????????????????
????(1) ?????????????????.config?????
??????/usr/src/linux/arch???????????????????????á???????????????????????????/usr/src/linux???£??????.config??
????cp /usr/src/linux/arch/x86/xxconfig /usr/src/linux/.config
????(2) ???.config??????????????飬??????????????顣
??????.config???????XXXX=m??????Щ??????????????? ?????????????????????Щ??飬???????XXXX=m?????????????????????????????飬???罫# CONFIG_NTFS_FS is not set ???CONFIG_NTFS_FS=m ?????????????????????????????????
????(3) ????NTFS??顣
??????/usr/src/linux????????????make modules?????????????????顣
????(4) ?????顣
?????????????.o?????/usr/src/linux/???£???????????????????????
????????cp /usr/src/linux/fs/ntfs/ntfs.o /lib/modules/2.2.16-22/fs/
????????????????????make modules_install???????????????????????????????е???????飬?????????????饗ntfs.o????
?????????????????????????????????
??????linux?м???????й??????????????£?
????depmod?? modprobe?? lsmod
????????????depmod????
????depmod????? ????????modules.dep??map??????????modules.dep????п???к???’#'??????н???????.depmod??????/lib /modules/version???μ???????????????????????????????б??????б???/lib/modules/version???μ? modules.dep??depmod?????/lib/modules/version???′??????map????????? modules.dep??modules.isapnpmap??modules.pcimap??modules.alias??Щ???????hotplug ?????
????OPTIONS:
????-a –all Probe all modules. This option is enabled by default if no
????file names are given in the command-line.
??????????е???飬???????????????????????????????????
????-A –quick This option scans to see if any modules are newer than the
????modules.dep file before any work is done%3
????????????modprobe????
????modprobe ?????????depmod -a?????/lib/modules/version/modules.dep??????????????????顣???????modprobe -l?????????????????????顣modprobe ????????????????????????·?????????????????.o ??.ko?? ??insmod ???????????????????·?????????????????????????????(modulefile.o ??modulesfile.ko ???? insmod????????????????????????????????????????????modprobe??
?????÷???modprobe xxx.ko #??????????
????modprobe -r xxx.ko #ж????????
????lsmod:
????lsmod ??????????????? ??飬????cat /proc/modules????????????趨?????????????飬????ntfs??????????????lsmod???б???????ntfs?????????????????? mount -t ntfs xxx?????lsmod???б??????ntfs?????????
?????????????lsmod???????????????????????(alias)??
????????????????????“Automatic kernel module loading”???????????????С???????????????????????????????????????????????顣???????????????????????????????????
?????????豸????Verdon ID?? Device ID?? SubVendor ID??????????????豸????????????????????????ЩVerdon ID?? Deviece
????ID?? SubVendor ID???豸????????PCI?豸???????????????pci_device_id????????????????????????磺RTL8139??pci_device_id???????
????static struct pci_device_id rtl8139_pci_tbl[] = {
????{0x10ec?? 0×8139?? PCI_ANY_ID?? PCI_ANY_ID?? 0?? 0?? RTL8139 }??
????{0x10ec?? 0×8138?? PCI_ANY_ID?? PCI_ANY_ID?? 0?? 0?? RTL8139 }??
????……
??????
????????鰲??????depmod?????????е?rtl8139_pci_tbl????????????????????????浽/lib/modules/uname-r /modules.alias????У??????????£?
????alias pci:v000010ECd00008138sv*sd*bc*sc*i* 8139too
????alias pci:v000010ECd00008139sv*sd*bc*sc*i* 8139too
????……
??????????/lib/modules/uname-r /modules.dep????л????????????????????????????????£?
????(????????·???????)
????8139too.ko:mii.ko
?????????????????У???????????????????Э????????????(??????????????????????????У??????????鷽??????????????make menuconfig????Bus options??????????????????????????Y??N???????????M.)????????????豸????????豸????????????????????kset?????? ???豸????????????kobject????kobject??????kset?????????????????????????????豸?豸?????????????????????????? ?????????赽???豸?????豸?????????????kobject????????????????豸???У????????kobject_uevent()?????(??????? ????)??????????????(?????豸??VendorID??DeviceID???????)???netlink??????????С?????????udevd?????? ??????????????Щ???????/lib/modules/uname-r /modules.alias????????? alias pci:v000010ECd00008138sv*sd*bc*sc*i* 8139too
??????????????赽???豸????????8139too??????modprobe????????8139too???????????modprobe???? modules.dep????????8139too??????mii.ko?????mii.ko??м????modprobe?????mii.ko??????????? 8139too.ko??
????????
?????????shell?У????У?
????# ps aux | grep udevd
????# kill -9 25063 ??????udevd????shell?????У?
????# strace -f /sbin/udevd –daemon
????????????????udevd????????£? ……
????close(8) = 0
????munmap(0xb7f8c000?? 4096) = 0
????select(7?? [3 4 5 6]?? NULL?? NULL?? NULL
???????????udevd????????????select()?????С? select??????????£? int select(int nfds?? fd_set *readfds?? fd_set *writefds?? fd_set *exceptfds?? struct timeval *timeout);
???????????????nfds???????????????????????7(??????6 ?)??
???????????????readfds??????????????????????3??4??5??6.
????????????????writefds?д???????????????????NULL??
???????????????exceptfds??????????????????????NULL??
???????????????timeout??????????????NULL??
????select????????????????readfds?е??κ?????????????????????witefds?е??κ???????????д??????exceptfds?е??? ???????????????????????????????????????????????????????????????????????timeout?????????????????????select?? ??? ???????????udevd???3??4??5??6????????????????????????????????shell?????У? # ps aux | grep udevd
????root 27615 …… strace -o /tmp/udevd.debug -f /sbin/udevd –daemon
????root 27617 …… /sbin/udevd –daemon
????udevd?????id?27617????????????????select????????????? # cd /proc/27615/fd
????# ls -l
????udevd???????????????????????????/dev/null.
????0 -> /dev/null
????1 -> /dev/null
????2 -> /dev/null
????udevd???????????????????
????3 -> /inotify
????4 -> socket:[331468]
????5 -> socket:[331469]
????6 -> pipe:[331470]
????7 -> pipe:[331470]
????????????????????в??????8139????????????????????????U?????????飬??????????U?????????strace??????????????????????? udevd??select???????????modprobe??????????飬????????sys_mknod????dev????????????????
????execve(“/sbin/modprobe”?? ["/sbin/modprobe"?? "-Q"?? "usb:v05ACp1301d0100dc00dsc00dp00"...]
????……
????mknod(“/dev/sdb”?? S_IFBLK|0660?? makedev(8?? 16)) = 0
????……
????????modprobe?????”usb:v05AC…”???modules.alias?е??????顣 ???????udevmonitor??????????netlink?????udevd?????????shell?????У? # udevmonitor –env
????????????U???????????????udevd???????
??????????????????????
?????????????????????????飬?????????????????modprobe?????????????????????????/etc/modprobe.conf????opensuse?У??????й?????modprobe.d/??????μ?????????modprobe.conf.local??????? /etc/modprobe.conf???include?????????????????????modprobe.conf.local?????????????á? /etc/modprobe.conf????????? д????????????????????????????man modprobe.conf:
????alias my-mod really_long_modulename???鶨????????????????
????options modulename option…???????????????
????install modulename command…???????????????????????????飬??install fred /sbin/modprobe barney; /sbin/modprobe
????–ignore-install fred” ??μ???fred???????????? “/sbin/modprobe barney; /sbin/modprobe
????–ignore-install fred”????
????remove modulename command…????????????????????????顣
????include filename ???????????
????blacklist modulename ?????????????
?????塢????????????????
????????????????????飬??redhat???????????????????????У?init???/etc/rc.d/rc.sysinit?????????????? ?????/etc/modprobe.conf??????????2.4??????У? ? ???????/etc/modprobe.conf????install xxx???ɡ?2.6??????????/etc/rc.d/rc.sysinit???????????????????http://blog.csdn.net /ioriqqe/archive/2009/11/05/4772033.aspx
????????suse????????root????/etc/sysconfig/kernel??????????????????顣