{"id":277,"date":"2013-06-07T09:15:09","date_gmt":"2013-06-07T09:15:09","guid":{"rendered":"http:\/\/www.selinuxplus.com\/?p=277"},"modified":"2013-06-07T09:15:09","modified_gmt":"2013-06-07T09:15:09","slug":"linux-kernel%e5%ae%9a%e5%88%b6%ef%bc%88%e4%ba%8c%ef%bc%89","status":"publish","type":"post","link":"http:\/\/www.selinuxplus.com\/?p=277","title":{"rendered":"linux kernel\u5b9a\u5236\uff08\u4e8c\uff09"},"content":{"rendered":"<p>2.2\u5bfb\u627e\u78c1\u76d8\u63a7\u5236\u5668<br \/>\n\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904 <a href=\" http:\/\/www.selinuxplus.com\/?p=277\" title=\"selinuxplus.com\">[By SELinux+]<\/a><br \/>\n\u672c\u8282\u4e3a\u6765\u5b9e\u9a8c\u6548\u679c\uff0c\u6211\u4eec\u5c06\u8fdb\u884c\u7a0d\u5fae\u7684\u53bb\u6389\u67d0\u4e2a\u9a71\u52a8\uff0c\u4ee5\u8fbe\u5230\u8bbe\u5907\u65e0\u6cd5\u8fd0\u884c\u7684\u6d4b\u8bd5\u6548\u679c\u3002<br \/>\n\u6240\u6709\u7684\u5757\u8bbe\u5907\u90fd\u663e\u793a\u5728\/sys\/block\u548c\/sys\/class\/block\u4e2d<\/p>\n<pre class=\"lang:default decode:true \" >[root@qfong.com ~]# tree -d \/sys\/block\/ |egrep \"hd|sd|sr\"\r\n\u251c\u2500\u2500 sda -&gt; ..\/devices\/pci0000:00\/0000:00:1f.2\/host0\/target0:0:0\/0:0:0:0\/block\/sda\r\n\u2514\u2500\u2500 sr0 -&gt; ..\/devices\/pci0000:00\/0000:00:1f.2\/host2\/target2:0:0\/2:0:0:0\/block\/sr0<\/pre>\n<p>\u548c\u4e4b\u524d\u7684\u7f51\u7edc\u8bbe\u5907\u4e00\u6837\uff0c\u6211\u4eec\u8fd9\u91cc\u5bfb\u627esr\u8bbe\u5907\uff0c\u8be5\u8bbe\u5907\u662f\u4e00\u4e2acdrom\uff0c\u672c\u8282\u6211\u4eec\u8981\u5378\u8f7dcdrom\u9a71\u52a8\u3002<\/p>\n<pre class=\"lang:default decode:true \" >[root@qfong.com ~]# ll \/sys\/block\/sr0\/\r\ntotal 0\r\n-r--r--r--. 1 root root 4096 Oct  9 02:14 alignment_offset\r\nlrwxrwxrwx. 1 root root    0 Oct  9 02:14 bdi -&gt; ..\/..\/..\/..\/..\/..\/..\/virtual\/bdi\/11:0\r\n-r--r--r--. 1 root root 4096 Oct  9 02:14 capability\r\n-r--r--r--. 1 root root 4096 Oct  8 20:46 dev\r\nlrwxrwxrwx. 1 root root    0 Oct  9 02:14 device -&gt; ..\/..\/..\/2:0:0:0\r\n-r--r--r--. 1 root root 4096 Oct  9 02:14 discard_alignment\r\n-r--r--r--. 1 root root 4096 Oct  9 02:14 events\r\n-r--r--r--. 1 root root 4096 Oct  9 02:14 events_async\r\n-rw-r--r--. 1 root root 4096 Oct  8 20:45 events_poll_msecs\r\n-r--r--r--. 1 root root 4096 Oct  9 02:14 ext_range\r\ndrwxr-xr-x. 2 root root    0 Oct  8 20:46 holders\r\n-r--r--r--. 1 root root 4096 Oct  9 02:14 inflight\r\ndrwxr-xr-x. 2 root root    0 Oct  9 01:07 power\r\ndrwxr-xr-x. 3 root root    0 Oct  8 20:46 queue\r\n-r--r--r--. 1 root root 4096 Oct  8 20:46 range\r\n-r--r--r--. 1 root root 4096 Oct  8 20:46 removable\r\n-r--r--r--. 1 root root 4096 Oct  9 02:14 ro\r\n-r--r--r--. 1 root root 4096 Oct  9 02:14 size\r\ndrwxr-xr-x. 2 root root    0 Oct  8 20:46 slaves\r\n-r--r--r--. 1 root root 4096 Oct  9 02:14 stat\r\nlrwxrwxrwx. 1 root root    0 Oct  8 20:46 subsystem -&gt; ..\/..\/..\/..\/..\/..\/..\/..\/class\/block\r\ndrwxr-xr-x. 2 root root    0 Oct  9 01:07 trace\r\n-rw-r--r--. 1 root root 4096 Oct  8 20:46 uevent<\/pre>\n<p>\u6211\u4eec\u73b0\u5728\u6cbf\u7740sysfs\u4e2d\u7684\u8bbe\u5907\u8fdb\u884c\u5bfb\u627e\u8fd9\u4e2a\u8bbe\u5907\u9a71\u52a8<\/p>\n<pre class=\"lang:default decode:true \" >[root@qfong.com sr0]#ll \/sys\/devices\/pci0000\\:00\/0000\\:00\\:1f.2\/host2\/target2\\:0\\:0\/2\\:0\\:0\\:0\/\r\ntotal 0\r\ndrwxr-xr-x. 3 root root    0 Oct  8 20:46 block\r\ndrwxr-xr-x. 3 root root    0 Oct  8 20:46 bsg\r\n--w-------. 1 root root 4096 Oct  9 02:17 delete\r\n-r--r--r--. 1 root root 4096 Oct  9 02:17 device_blocked\r\n-rw-r--r--. 1 root root 4096 Oct  9 02:17 dh_state\r\nlrwxrwxrwx. 1 root root    0 Oct  9 02:17 driver -&gt; ..\/..\/..\/..\/..\/..\/bus\/scsi\/drivers\/sr\r\n-r--r--r--. 1 root root 4096 Oct  8 20:46 evt_media_change\r\nlrwxrwxrwx. 1 root root    0 Oct  9 02:17 generic -&gt; scsi_generic\/sg1\r\n-r--r--r--. 1 root root 4096 Oct  9 02:17 iocounterbits\r\n-r--r--r--. 1 root root 4096 Oct  9 02:17 iodone_cnt\r\n-r--r--r--. 1 root root 4096 Oct  9 02:17 ioerr_cnt\r\n-r--r--r--. 1 root root 4096 Oct  9 02:17 iorequest_cnt\r\n-r--r--r--. 1 root root 4096 Oct  9 01:07 modalias\r\n-r--r--r--. 1 root root 4096 Oct  8 20:46 model\r\ndrwxr-xr-x. 2 root root    0 Oct  9 01:07 power\r\n-rw-r--r--. 1 root root 4096 Oct  9 02:17 queue_depth\r\n-rw-r--r--. 1 root root 4096 Oct  9 02:17 queue_ramp_up_period\r\n-r--r--r--. 1 root root 4096 Oct  9 02:17 queue_type\r\n--w-------. 1 root root 4096 Oct  9 02:17 rescan\r\n-r--r--r--. 1 root root 4096 Oct  9 02:17 rev\r\ndrwxr-xr-x. 3 root root    0 Oct  8 20:46 scsi_device\r\ndrwxr-xr-x. 3 root root    0 Oct  8 20:46 scsi_generic\r\n-r--r--r--. 1 root root 4096 Oct  8 20:46 scsi_level\r\n-rw-r--r--. 1 root root 4096 Oct  9 02:17 state\r\nlrwxrwxrwx. 1 root root    0 Oct  8 20:46 subsystem -&gt; ..\/..\/..\/..\/..\/..\/bus\/scsi\r\n-rw-r--r--. 1 root root 4096 Oct  9 02:17 sw_activity\r\n-rw-r--r--. 1 root root 4096 Oct  9 02:17 timeout\r\n-r--r--r--. 1 root root 4096 Oct  8 20:46 type\r\n-rw-r--r--. 1 root root 4096 Oct  8 20:46 uevent\r\n-rw-r--r--. 1 root root 4096 Oct  9 02:17 unload_heads\r\n-r--r--r--. 1 root root 4096 Oct  8 20:46 vendor<\/pre>\n<p>\u6211\u4eec\u770b\u5230\u8fd9\u4e2ascsi\u78c1\u76d8\u63a7\u5236\u5668\u63a7\u5236\u7740\u8be5\u8bbe\u5907\uff0c\u56e0\u6b64scsi\u8bbe\u5907\u662f\u6211\u4eec\u5fc5\u987b\u8981\u52a0\u5230\u6211\u4eec\u5185\u6838\u914d\u7f6e\u91cc\u9762\u7684\uff0c\u56e0\u4e3ascsi\u63a7\u5236\u7740scsi\u603b\u7ebf\u4e0a\u7684\u6240\u6709\u78c1\u76d8\u8bbe\u5907\u3002\u6211\u4eec\u4e3b\u8981\u76ee\u6807\u662f\u627e\u5230\u63a7\u5236\u8be5\u8bbe\u5907\u7684\u786c\u4ef6\u9a71\u52a8<br \/>\n\u63a5\u7740\u6211\u4eec\u7ee7\u7eed\u5bfb\u627e\u786c\u4ef6\u7684\u9a71\u52a8<br \/>\n\u5728sysfs\u94fe\u63a5\u4e2d\u8fd4\u56de\u4e0a\u4e00\u7ea7\u76ee\u5f55\uff0c\u7ee7\u7eed\u5bfb\u627e\uff0c\u8bd5\u7740\u627e\u51fa\u63a7\u5236\u786c\u4ef6\u7684\u9a71\u52a8<\/p>\n<pre class=\"lang:default decode:true \" >[root@qfong.com 2:0:0:0]# cd ..\r\n[root@qfong.com target2:0:0]# ll\r\ntotal 0\r\ndrwxr-xr-x. 7 root root    0 Oct  8 20:46 2:0:0:0\r\ndrwxr-xr-x. 2 root root    0 Oct  9 01:07 power\r\nlrwxrwxrwx. 1 root root    0 Oct  8 20:46 subsystem -&gt; ..\/..\/..\/..\/..\/bus\/scsi\r\n-rw-r--r--. 1 root root 4096 Oct  8 20:46 uevent<\/pre>\n<p>\u8be5\u76ee\u5f55\u4e0b\u6ca1\u6709driver\u7684\u94fe\u63a5\uff0c\u6211\u4eec\u7ee7\u7eed\u8fd4\u56de\u4e0a\u4e00\u7ea7\u76ee\u5f55<\/p>\n<pre class=\"lang:default decode:true \" >[root@qfong.com target2:0:0]# cd ..\r\n[root@qfong.com host2]# ll\r\ntotal 0\r\ndrwxr-xr-x. 2 root root    0 Oct  9 01:07 power\r\ndrwxr-xr-x. 3 root root    0 Oct  8 20:46 scsi_host\r\nlrwxrwxrwx. 1 root root    0 Oct  8 20:46 subsystem -&gt; ..\/..\/..\/..\/bus\/scsi\r\ndrwxr-xr-x. 4 root root    0 Oct  8 20:46 target2:0:0\r\n-rw-r--r--. 1 root root 4096 Oct  8 20:46 uevent<\/pre>\n<p>\u8be5\u76ee\u5f55\u4e0b\u4ecd\u6ca1\u6709driver\u7684\u94fe\u63a5\uff0c\u6211\u4eec\u7ee7\u7eed\u8fd4\u56de\u4e0a\u4e00\u7ea7\u76ee\u5f55<\/p>\n<pre class=\"lang:default decode:true \" >[root@qfong.com host2]# cd ..\r\n[root@qfong.com 0000:00:1f.2]# ll\r\ntotal 0\r\ndrwxr-xr-x. 5 root root    0 Oct  8 20:46 ata1\r\ndrwxr-xr-x. 5 root root    0 Oct  8 20:46 ata2\r\ndrwxr-xr-x. 5 root root    0 Oct  8 20:46 ata3\r\ndrwxr-xr-x. 5 root root    0 Oct  8 20:46 ata4\r\ndrwxr-xr-x. 5 root root    0 Oct  8 20:46 ata5\r\ndrwxr-xr-x. 5 root root    0 Oct  8 20:46 ata6\r\n-rw-r--r--. 1 root root 4096 Oct  9 04:35 broken_parity_status\r\n-r--r--r--. 1 root root 4096 Oct  8 20:46 class\r\n-rw-r--r--. 1 root root  256 Oct  8 20:46 config\r\n-r--r--r--. 1 root root 4096 Oct  9 04:35 consistent_dma_mask_bits\r\n-r--r--r--. 1 root root 4096 Oct  8 20:46 device\r\n-r--r--r--. 1 root root 4096 Oct  9 04:35 dma_mask_bits\r\nlrwxrwxrwx. 1 root root    0 Oct  8 20:46 driver -&gt; ..\/..\/..\/bus\/pci\/drivers\/ahci\r\n-rw-------. 1 root root 4096 Oct  9 04:35 enable\r\nlrwxrwxrwx. 1 root root    0 Oct  9 04:35 firmware_node -&gt; ..\/..\/LNXSYSTM:00\/device:00\/PNP0A03:00\/device:1f<\/pre>\n<p>\u8be5\u76ee\u5f55\u4e0b\u6211\u4eec\u770b\u5230\u4e86\u4e3a\u7684\u9a71\u52a8\u7a0b\u5e8f\u4e86\u3002\u8be5\u9a71\u52a8\u4e3a  driver -> ..\/..\/..\/bus\/pci\/drivers\/ahci<br \/>\nachi\u4fbf\u662f\u6211\u4eec\u8981\u5bfb\u627e\u7684\u9a71\u52a8,\u4f46\u662fachi\u9a71\u52a8\u662finter\u82af\u7247\u7ec4\u7684\u9a71\u52a8\uff0c\u5bf9\u6211\u4eec\u6765\u8bf4\u8fd9\u4e2a\u9a71\u52a8\u4e0d\u662f\u6211\u4eec\u771f\u6b63\u60f3\u8981\u7684\uff0c\u6211\u4eec\u8981\u5206\u6790\u6211\u4eec\u7684\u8bbe\u5907\uff0ccdrom\u662f\u5728scsi\u8bbe\u5907\u4e0a\u7684\uff0c\u6211\u4eec\u8981\u627e\u5230scsi\u7684\u63a5\u53e3\u3002\u63a5\u4e0b\u6765\uff0c\u6211\u4eec\u7ee7\u7eed\u5bfb\u627e\u6700\u7ec8\u7684\u9a71\u52a8<\/p>\n<pre class=\"lang:default decode:true \" >[root@qfong.com linux-2.6.38.x86_64]# find -type f -name Makefile |xargs grep \"ahci\"\r\n.\/drivers\/ata\/Makefile:obj-$(CONFIG_SATA_AHCI)+= ahci.o libahci.o\r\n.\/drivers\/ata\/Makefile:obj-$(CONFIG_SATA_ACARD_AHCI)+= acard-ahci.o libahci.o\r\n.\/drivers\/ata\/Makefile:obj-$(CONFIG_SATA_AHCI_PLATFORM)+= ahci_platform.o libahci.o<\/pre>\n<p>\u6211\u4eec\u56de\u5230\u4e0a\u4e00\u5c42driver -> ..\/..\/..\/..\/..\/..\/bus\/scsi\/drivers\/sr<br \/>\n\u6211\u4eec\u770b\u5230\u6211\u4eec\u7684\u9a71\u52a8\u6307\u5411\u7684\u662fsr<\/p>\n<pre class=\"lang:default decode:true \" >[root@qfong.com linux-2.6.38.x86_64]# find -type f -name \"Makefile\" |xargs grep  \"sr\" |grep \"CONFIG_\" |grep \"scsi\"\r\n.\/drivers\/scsi\/Makefile:obj-$(CONFIG_SCSI_SRP_ATTRS)+= scsi_transport_srp.o\r\n.\/drivers\/scsi\/Makefile:obj-$(CONFIG_SCSI_ARCMSR)+= arcmsr\/\r\n.\/drivers\/scsi\/Makefile:obj-$(CONFIG_SCSI_SRP)+= libsrp.o\r\n.\/drivers\/scsi\/Makefile:obj-$(CONFIG_BLK_DEV_SR)+= sr_mod.o\r\n.\/drivers\/scsi\/arcmsr\/Makefile:obj-$(CONFIG_SCSI_ARCMSR)\uff1a= arcmsr.o<\/pre>\n<p>\u6211\u4eec\u731c\u60f3\u4e0a\u56fe\u7684sr_mod.o\u5e94\u8be5\u662f\u6211\u4eec\u6240\u8981\u5bfb\u627e\u7684\u9a71\u52a8\u3002<br \/>\n\u90a3\u4e48\u4ed6\u6307\u5411\u7684\u9a71\u52a8\u4e3aCONFIG_BLK_DEV_SR<br \/>\n<a href=\"http:\/\/www.selinuxplus.com\/wp-content\/uploads\/2013\/06\/make_kernel_5.png\"><img loading=\"lazy\" src=\"http:\/\/www.selinuxplus.com\/wp-content\/uploads\/2013\/06\/make_kernel_5-300x204.png\" alt=\"\" title=\"make_kernel_5\" width=\"300\" height=\"204\" class=\"alignnone size-medium wp-image-278\" srcset=\"http:\/\/www.selinuxplus.com\/wp-content\/uploads\/2013\/06\/make_kernel_5-300x204.png 300w, http:\/\/www.selinuxplus.com\/wp-content\/uploads\/2013\/06\/make_kernel_5-150x102.png 150w, http:\/\/www.selinuxplus.com\/wp-content\/uploads\/2013\/06\/make_kernel_5-400x272.png 400w, http:\/\/www.selinuxplus.com\/wp-content\/uploads\/2013\/06\/make_kernel_5.png 737w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><br \/>\n\u5982\u4e0a\u56fe\u6240\u793a\uff1a\u6211\u4eec\u770b\u5230\u6765scsi CDROM \u652f\u6301\u7684\u9009\u9879\u3002<br \/>\n\u5f53\u7136\u4e86\uff0c\u5bfb\u627e\u9a71\u52a8\u5f88\u9ebb\u70e6\uff0c\u6211\u7ed9\u5927\u5bb6\u51c6\u5907\u4e86\u4e00\u4e2a\u811a\u672c\uff0c\u53ef\u4ee5\u8f7b\u6613\u7684\u83b7\u5f97\u9a71\u52a8\u3002\u4ee5\u4e0a\u4ec5\u662f\u5bf9\u5176\u5206\u6790\u7684\u65b9\u6cd5\u8fdb\u884c\u8bf4\u660e<\/p>\n","protected":false},"excerpt":{"rendered":"<p>2.2\u5bfb\u627e\u78c1\u76d8\u63a7\u5236\u5668 \u8f6c\u8f7d\u8bf7\u6ce8\u660e\u51fa\u5904 [By SE&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[45,5],"tags":[48,37,38],"_links":{"self":[{"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/posts\/277"}],"collection":[{"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=277"}],"version-history":[{"count":1,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/posts\/277\/revisions"}],"predecessor-version":[{"id":279,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=\/wp\/v2\/posts\/277\/revisions\/279"}],"wp:attachment":[{"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=277"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=277"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.selinuxplus.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=277"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}