{"id":2306,"date":"2015-10-25T17:37:38","date_gmt":"2015-10-25T08:37:38","guid":{"rendered":"http:\/\/tech.akat.info\/?p=2306"},"modified":"2015-10-25T17:37:38","modified_gmt":"2015-10-25T08:37:38","slug":"linux%e3%83%89%e3%83%a9%e3%82%a4%e3%83%90%e3%82%92%e4%bd%9c%e6%88%90%e3%81%97%e3%81%a6%e3%81%bf%e3%82%8b","status":"publish","type":"post","link":"https:\/\/tech.akat.info\/?p=2306","title":{"rendered":"Linux\u30c9\u30e9\u30a4\u30d0\u3092\u4f5c\u6210\u3057\u3066\u307f\u308b"},"content":{"rendered":"<p><a href=\"http:\/\/www.linux-dvr.biz\/archives\/category\/%E3%83%87%E3%83%90%E3%82%A4%E3%82%B9%E3%83%89%E3%83%A9%E3%82%A4%E3%83%90%E9%96%8B%E7%99%BA%E5%85%A5%E9%96%80\">Linux\u30c7\u30d0\u30a4\u30b9\u30c9\u30e9\u30a4\u30d0\u958b\u767a\u5165\u9580<\/a>\u3092\u3084\u3063\u3066\u307f\u305f<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nroot@hostname:\/home\/shimizu\/driver# cat \/etc\/debian_version\r\n8.2\r\nroot@hostname:\/home\/shimizu\/driver# uname -a\r\nLinux hostname 3.16.0-4-amd64 #1 SMP Debian 3.16.7-ckt11-1+deb8u3 (2015-08-04) x86_64 GNU\/Linux\r\nroot@hostname:\/home\/shimizu\/driver# aptitude install linux-headers-3.16.0-4-amd64\r\n...\r\n\r\nroot@hostname:\/home\/shimizu\/driver# cat hello.c\r\n#include &lt;linux\/module.h&gt;\r\n#include &lt;linux\/init.h&gt;\r\n\r\nMODULE_LICENSE(&quot;Dual BSD\/GPL&quot;);\r\n\r\nstatic int hello_init(void)\r\n{\r\n      printk(KERN_ALERT &quot;driver loaded\\n&quot;);\r\n      printk(KERN_ALERT &quot;Hello World\\n&quot;);\r\n      return 0;\r\n}\r\n\r\nstatic void hello_exit(void)\r\n{\r\n      printk(KERN_ALERT &quot;driver unloaded\\n&quot;);\r\n}\r\n\r\nmodule_init(hello_init);\r\nmodule_exit(hello_exit);\r\n\r\nroot@hostname:\/home\/shimizu\/driver# cat Makefile\r\nobj-m := hello.o\r\n\r\nall:\r\n      make -C \/lib\/modules\/$(shell uname -r)\/build M=$(PWD) modules\r\n\r\nclean:\r\n      make -C \/lib\/modules\/$(shell uname -r)\/build M=$(PWD) clean\r\n\r\nroot@hostname:\/home\/shimizu\/driver# make\r\nmake -C \/lib\/modules\/3.16.0-4-amd64\/build M=\/home\/shimizu\/driver modules\r\nmake&#x5B;1]: Entering directory '\/usr\/src\/linux-headers-3.16.0-4-amd64'\r\nMakefile:10: *** mixed implicit and normal rules: deprecated syntax\r\nmake&#x5B;1]: Entering directory `\/usr\/src\/linux-headers-3.16.0-4-amd64'\r\n  CC &#x5B;M]  \/home\/shimizu\/driver\/hello.o\r\n  Building modules, stage 2.\r\n  MODPOST 1 modules\r\n  CC      \/home\/shimizu\/driver\/hello.mod.o\r\n  LD &#x5B;M]  \/home\/shimizu\/driver\/hello.ko\r\nmake&#x5B;1]: Leaving directory '\/usr\/src\/linux-headers-3.16.0-4-amd64'\r\n\r\nroot@hostname:\/home\/shimizu\/driver# ls\r\nMakefile  Module.symvers  hello.c  hello.ko  hello.mod.c  hello.mod.o  hello.o  modules.order\r\n\r\nroot@hostname:\/home\/shimizu\/driver# insmod hello.ko\r\nroot@hostname:\/home\/shimizu\/driver# lsmod | grep hello\r\nhello                  12458  0\r\n\r\nroot@hostname:\/home\/shimizu\/driver# rmmod hello\r\nroot@hostname:\/home\/shimizu\/driver# lsmod | grep hello\r\n\r\n### hello.c\u306b\u8a18\u8f09\u3057\u3066\u3044\u308b\u901a\u308a\u3001\u30e2\u30b8\u30e5\u30fc\u30eb\u30ed\u30fc\u30c9\u6642\u3068\u524a\u9664\u6642\u306bsyslog\u306b\u8a18\u8f09\u3055\u308c\u308b ###\r\nroot@hostname:\/home\/shimizu\/driver# tail -n 3 \/var\/log\/syslog\r\nOct 25 17:29:44 hostname kernel: &#x5B;4858346.340042] driver loaded\r\nOct 25 17:29:44 hostname kernel: &#x5B;4858346.340050] Hello World\r\nOct 25 17:29:59 hostname kernel: &#x5B;4858361.365712] driver unloaded\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Linux\u30c7\u30d0\u30a4\u30b9\u30c9\u30e9\u30a4\u30d0\u958b\u767a\u5165\u9580\u3092\u3084\u3063\u3066\u307f\u305f root@hostname:\/home\/shimizu\/driver# cat \/etc\/debian_version 8.2 root@hostname:\/home\/sh [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[2],"tags":[],"_links":{"self":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/2306"}],"collection":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2306"}],"version-history":[{"count":1,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/2306\/revisions"}],"predecessor-version":[{"id":2307,"href":"https:\/\/tech.akat.info\/index.php?rest_route=\/wp\/v2\/posts\/2306\/revisions\/2307"}],"wp:attachment":[{"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2306"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2306"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tech.akat.info\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2306"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}