{"id":347141,"date":"2023-03-23T15:01:04","date_gmt":"2023-03-23T15:01:04","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=347141"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=347141","title":{"rendered":"<span>\u041a\u0430\u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0434\u0440\u0430\u0439\u0432\u0435\u0440 Linux \u0441 \u043d\u0443\u043b\u044f<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/xg\/q2\/0u\/xgq20uagk7s3wedhylmrea5_10m.jpeg\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/xg\/q2\/0u\/xgq20uagk7s3wedhylmrea5_10m.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u0437\u0430\u043d\u0438\u043c\u0430\u043b\u0441\u044f \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435\u043c IoT \u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u043d\u0435 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u043b\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432, \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0430\u0445 \u0441\u0438\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 \u044f \u0447\u0430\u0441\u0442\u043e \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0441\u044f \u0441 \u043d\u0435\u0438\u043c\u0435\u043d\u0438\u0435\u043c \u043d\u0443\u0436\u043d\u043e\u0433\u043e \/dev\/xxx. \u0422\u0430\u043a \u0447\u0442\u043e \u044f \u0441\u0442\u0430\u043b \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c\u0441\u044f, \u0430 \u043c\u043e\u0433\u0443 \u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u041d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0442\u043e\u0433\u043e, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0436\u043d\u043e \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442, \u0438 \u0443\u0434\u0430\u0441\u0442\u0441\u044f \u043b\u0438 \u0432\u043e\u043f\u043b\u043e\u0442\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0435 \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u0438\u0435, \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b \u043d\u0435 \u043f\u043e\u0436\u0430\u043b\u0435\u0435\u0442\u0435, \u0435\u0441\u043b\u0438 \u043d\u0430\u0443\u0447\u0438\u0442\u0435\u0441\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0434\u0440\u0430\u0439\u0432\u0435\u0440 Linux \u0441 \u043d\u0443\u043b\u044f.<a name=\"habracut\"><\/a><\/p>\n<h2><font color=\"#1c22be\">\u276f<\/font> <font color=\"#454cee\">\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/font><\/h2>\n<p>  \u042f \u043d\u0430\u043f\u0438\u0441\u0430\u043b \u0441\u0435\u0440\u0438\u044e \u0441\u0442\u0430\u0442\u0435\u0439, \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0443, \u043e \u0442\u0435\u043e\u0440\u0438\u0438 \u0442\u0430\u043c \u043c\u0430\u043b\u043e \u0447\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u0442\u0441\u044f. \u0420\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u044b \u044f \u043d\u0430\u0443\u0447\u0438\u043b\u0441\u044f \u043f\u043e \u043a\u043d\u0438\u0433\u0435 Linux Device Drivers, \u0430 \u043a\u043e\u0434 \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c, \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u043c \u0432 \u044d\u0442\u043e\u0439 \u043a\u043d\u0438\u0433\u0435, \u0432\u044b\u043b\u043e\u0436\u0435\u043d \u043d\u0430 <a href=\"https:\/\/github.com\/jesstess\/ldd4\">GitHub<\/a>.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043d\u0430\u0447\u0430\u0442\u044c \u0441 \u0430\u0437\u043e\u0432 \u2013 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u0430\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u0430 Linux \u0434\u0435\u043b\u0438\u0442\u0441\u044f \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u044f\u0434\u0440\u0430 \u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0435 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e. \u0414\u043e\u0441\u0442\u0443\u043f \u043a \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u043c\u0443 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0443 \u0432\u043e\u0437\u043c\u043e\u0436\u0435\u043d \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u043e \u044f\u0434\u0440\u0430, \u0430 \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043c\u043e\u0436\u0435\u0442 \u0442\u0440\u0430\u043a\u0442\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043a\u0430\u043a API, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0439 \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u044f\u0434\u0440\u0430 \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u043a\u043e\u0434\u0443 \u0438\u0437 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u043a \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0443.<\/p>\n<p>  \u041e\u043f\u0438\u0440\u0430\u044f\u0441\u044c \u043d\u0430 \u044d\u0442\u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438, \u044f \u0441\u0444\u043e\u0440\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043b \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438 \u043f\u043e\u0431\u0443\u0434\u0438\u043b\u0438 \u043c\u0435\u043d\u044f \u0438\u0437\u0443\u0447\u0438\u0442\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430.<\/p>\n<ol>\n<li>\u0412 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0443\u0447\u0451\u0431\u0430 \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u044b Hello World, \u0442\u0430\u043a \u043a\u0430\u043a \u0436\u0435 \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443 Hello World?<\/li>\n<li>\u041a\u0430\u043a \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442 \u0444\u0430\u0439\u043b\u044b \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u043f\u043e\u0434 \/dev? <\/li>\n<li>\u041a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0434\u043e\u0441\u0442\u0443\u043f \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u043a \u0438\u043c\u0435\u044e\u0449\u0435\u043c\u0443\u0441\u044f \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u043d\u043e\u043c\u0443 \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044e?<\/li>\n<li>\u041a\u0430\u043a \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434, \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439? \u0418\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0431\u0435\u0437 \u043a\u043e\u0434\u0430? \u0413\u0434\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0434\u0432\u043e\u0438\u0447\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430? \u0412 \u0431\u0443\u0434\u0443\u0449\u0435\u043c \u0432\u0441\u0435 \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c, \u0447\u0442\u043e\u0431\u044b \u0438\u0437\u0443\u0447\u0438\u0442\u044c, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e. <\/li>\n<\/ol>\n<p>  <\/p>\n<h2><font color=\"#1c22be\">\u276f<\/font> <font color=\"#454cee\">\u0412\u0441\u0451 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 Hello World<\/font><\/h2>\n<p>  \u0412\u043e\u0442 \u043a\u0430\u043a\u043e\u0439 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u043c\u043e\u044f \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430 <a href=\"https:\/\/raw.githubusercontent.com\/Hcamael\/Linux_Driver_Study\/master\/hello.c\">Hello World<\/a>:<\/p>\n<pre><code class=\"plaintext\">#include &lt;linux\/init.h> #include &lt;linux\/module.h> MODULE_LICENSE(\"Dual BSD\/GPL\"); MODULE_AUTHOR(\"Hcamal\"); int hello_init(void) {     printk(KERN_INFO \"Hello World\\n\");     return 0; } void hello_exit(void) {     printk(KERN_INFO \"Goodbye World\\n\"); } module_init(hello_init); module_exit(hello_exit);<\/code><\/pre>\n<p>  \u0414\u0440\u0430\u0439\u0432\u0435\u0440 Linux \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 C, \u043f\u0440\u0438\u0447\u0451\u043c, \u043d\u0430 \u0442\u0430\u043a\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0435 \u0441\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u0435 \u043f\u0440\u0438\u0432\u044b\u0447\u0435\u043d. \u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u044f \u0447\u0430\u0441\u0442\u043e \u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0441\u044c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 Libc, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u044f\u0434\u0440\u0435. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u2013 \u044d\u0442\u043e \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0430, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0430\u044f \u0432 \u044f\u0434\u0440\u0435, \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u044f\u0434\u0440\u0435 \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438.<\/p>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, <code>printk<\/code> \u2014 \u044d\u0442\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u044b\u0432\u043e\u0434\u0430, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c\u0430\u044f \u0432 \u044f\u0434\u0440\u0435, \u043e\u043d\u0430 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u0430 printf \u0438\u0437 Libc. \u041d\u043e \u043c\u043d\u0435 \u043e\u043d\u0430 \u0432 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0441\u0442\u0435\u043f\u0435\u043d\u0438 \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0435\u0442 \u043b\u043e\u0433\u0438\u0440\u0443\u044e\u0449\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e \u0438\u0437 Python, \u0442\u0430\u043a \u043a\u0430\u043a \u0432\u044b\u0432\u043e\u0434 <code>printk<\/code> \u0438\u0434\u0451\u0442 \u0440\u0430\u0437\u0443 \u0432 \u043b\u043e\u0433 \u044f\u0434\u0440\u0430, \u0430 \u044d\u0442\u043e\u0442 \u043b\u043e\u0433 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>dmesg<\/code>.<\/p>\n<p>  \u0412 \u043a\u043e\u0434\u0435 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u0435\u0441\u0442\u044c \u0440\u043e\u0432\u043d\u043e \u043e\u0434\u043d\u0430 \u0442\u043e\u0447\u043a\u0430 \u0432\u0445\u043e\u0434\u0430 \u0438 \u043e\u0434\u043d\u0430 \u0442\u043e\u0447\u043a\u0430 \u0432\u044b\u0445\u043e\u0434\u0430. \u041f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u0432 \u044f\u0434\u0440\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>module_init<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432 \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>hello_init<\/code>. \u041f\u0440\u0438 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0435 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u0438\u0437 \u044f\u0434\u0440\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c\u0430\u044f \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>module_exit<\/code>, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0432 \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f <code>hello_exit<\/code>.<\/p>\n<p>  \u0418\u0437 \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0432\u044b\u0448\u0435 \u043a\u043e\u0434\u0430 \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0447\u0442\u043e, \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u044f\u0441\u044c, \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0432\u044b\u0432\u043e\u0434\u0438\u0442 Hello World, \u0430 \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u044f\u0441\u044c \u2014 <code>Goodbye World<\/code>.<\/p>\n<p>  \u041a\u0441\u0442\u0430\u0442\u0438: <code>MODULE_LICENSE<\/code> \u0438 <code>MODULE_AUTHOR<\/code> \u043d\u0435 \u0442\u0430\u043a \u0432\u0430\u0436\u043d\u044b. \u0417\u0434\u0435\u0441\u044c \u044f \u043d\u0435 \u0431\u0443\u0434\u0443 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u0438\u0445 \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c.<\/p>\n<p>  \u0418 \u0435\u0449\u0451: \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 printk \u0434\u043e\u043b\u0436\u0435\u043d \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043d\u0430 \u043d\u043e\u0432\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443, \u0438\u043d\u0430\u0447\u0435 \u043e\u043f\u043e\u0440\u043e\u0436\u043d\u0435\u043d\u0438\u0435 \u0431\u0443\u0444\u0435\u0440\u0430 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442.<\/p>\n<h2><font color=\"#1c22be\">\u276f<\/font> <font color=\"#454cee\">\u041a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \u0434\u0440\u0430\u0439\u0432\u0435\u0440<\/font><\/h2>\n<p>  \u0414\u0440\u0430\u0439\u0432\u0435\u0440 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439 <code>make<\/code>, \u0438 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 Makefile \u043f\u043e\u043a\u0430\u0437\u0430\u043d \u043d\u0438\u0436\u0435:<\/p>\n<pre><code class=\"plaintext\">ifneq ($(KERNELRELEASE),)     obj-m := hello.o else     KERN_DIR ?= \/usr\/src\/linux-headers-$(shell uname -r)\/     PWD := $(shell pwd) default:     $(MAKE) -C $(KERN_DIR) M=$(PWD) modules endif clean:     rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions<\/code><\/pre>\n<p>  \u0412\u043e\u043e\u0431\u0449\u0435 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u044f\u0434\u0440\u0430 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 \/usr\/src\/linux-headers-$(shell uname -r)\/, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"plaintext\">$ uname -r 4.4.0-135-generic\/usr\/src\/linux-headers-4.4.0-135\/ --> \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u044f\u0434\u0440\u0430 \/usr\/src\/linux-headers-4.4.0-135-generic\/ --> \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u044f\u0434\u0440\u0430<\/code><\/pre>\n<p>  \u0410 \u043d\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \u0434\u043b\u044f \u0441\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e <code>\/usr\/src\/linux-headers-4.4.0-135-generic\/<\/code>.<\/p>\n<p>  \u041f\u043e\u0438\u0441\u043a \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432 \u0434\u043b\u044f \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0430.<\/p>\n<p>  \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 M=$(PWD) \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u0447\u0442\u043e \u0432\u044b\u0432\u043e\u0434 \u043e\u0442 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0446\u0438\u0438 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u043f\u043e\u043f\u0430\u0434\u0430\u0435\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u043a\u0430\u0442\u0430\u043b\u043e\u0433.<\/p>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0432\u043e\u0442 \u043a\u043e\u043c\u0430\u043d\u0434\u0430 <code>obj-m := hello.o<\/code>, \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u043d\u0430\u044f \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 <code>hello.o<\/code> \u0432 <code>hello.ko<\/code>, \u0430 ko \u2013 \u044d\u0442\u043e \u0444\u0430\u0439\u043b \u0438\u0437 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0430 \u044f\u0434\u0440\u0430.<\/p>\n<h2><font color=\"#1c22be\">\u276f<\/font> <font color=\"#454cee\">\u0417\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0432 \u044f\u0434\u0440\u043e<\/font><\/h2>\n<p>  \u0412\u043e\u0442 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f:<\/p>\n<ul>\n<li><code>Lsmod<\/code>: \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u043c\u043e\u0434\u0443\u043b\u044f \u044f\u0434\u0440\u0430, \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0435\u043c\u043e\u0433\u043e \u0432 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u043c\u043e\u043c\u0435\u043d\u0442.<\/li>\n<li><code>Insmod<\/code>: \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043c\u043e\u0434\u0443\u043b\u044f \u044f\u0434\u0440\u0430 \u0441 \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043f\u0440\u0430\u0432 \u0430\u0434\u043c\u0438\u043d\u0438\u0441\u0442\u0440\u0430\u0442\u043e\u0440\u0430.<\/li>\n<li><code>Rmmod<\/code>: \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043c\u043e\u0434\u0443\u043b\u044f.<\/li>\n<\/ul>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"plaintext\"># insmod hello.ko        \/\/ Load the hello.ko module into the kernel # rmmod hello          \/\/ Remove the hello module from the kernel<\/code><\/pre>\n<p>  \u0412 \u0441\u0442\u0430\u0440\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 \u044f\u0434\u0440\u0430 \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u043c \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u043b\u043e\u0441\u044c \u0438 \u0443\u0434\u0430\u043b\u044f\u043b\u043e\u0441\u044c \u0441\u0430\u043c\u043e \u044f\u0434\u0440\u043e, \u043d\u043e \u0432 \u043d\u043e\u0432\u044b\u0445 \u0432\u0435\u0440\u0441\u0438\u044f\u0445 \u044f\u0434\u0440\u0430 Linux \u0437\u0434\u0435\u0441\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u0435\u0440\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u043c\u043e\u0434\u0443\u043b\u044f. \u0412\u043e\u0442 \u0432 \u043a\u0430\u043a\u043e\u0439 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438 \u043c\u044b \u0441\u0435\u0439\u0447\u0430\u0441 \u043d\u0430\u0445\u043e\u0434\u0438\u043c\u0441\u044f:<\/p>\n<pre><code class=\"plaintext\"># insmod hello.ko insmod: ERROR: could not insert module hello.ko: Required key not available<\/code><\/pre>\n<p>  \u0421 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u0438 \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u043e\u0435 \u044f\u0434\u0440\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442, \u0447\u0442\u043e \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u0434\u0443\u043b\u044c \u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0434\u043e\u0432\u0435\u0440\u0438\u044f. \u0427\u0442\u043e\u0431\u044b \u044d\u0442\u043e\u0442 \u043c\u043e\u0434\u0443\u043b\u044c \u043c\u043e\u0433 \u0431\u044b\u0442\u044c \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d, \u0435\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u043c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u043c.<\/p>\n<p>  \u042d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u0432\u0443\u043c\u044f \u0441\u043f\u043e\u0441\u043e\u0431\u0430\u043c\u0438:<\/p>\n<ol>\n<li>\u0412\u043e\u0439\u0442\u0438 \u0432 BIOS \u0438 \u043e\u0442\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u0443\u044e \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0443 \u0432 UEFI.<\/li>\n<li>\u0414\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u044f\u0434\u0440\u043e \u0441\u0430\u043c\u043e\u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u044b\u0439 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442, \u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c \u043c\u043e\u0434\u0443\u043b\u044c \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 (\u043f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043e\u0431 \u044d\u0442\u043e\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0442\u0443\u0442).<\/li>\n<\/ol>\n<p>  <\/p>\n<h2><font color=\"#1c22be\">\u276f<\/font> <font color=\"#454cee\">View the Results<\/font><\/h2>\n<p>  <\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/ao\/jk\/5s\/aojk5sphsurukbezs_ipf2rn6jq.png\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/ao\/jk\/5s\/aojk5sphsurukbezs_ipf2rn6jq.png\"\/><\/div>\n<p>  <\/p>\n<h2><font color=\"#1c22be\">\u276f<\/font> <font color=\"#454cee\">\u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0444\u0430\u0439\u043b\u044b \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u043f\u043e\u0434 \/dev<\/font><\/h2>\n<p>  Once again, we firstly provide the code, and then explain the example <a href=\"https:\/\/raw.githubusercontent.com\/Hcamael\/Linux_Driver_Study\/master\/scull.c\">code<\/a>.<\/p>\n<pre><code class=\"plaintext\">#include &lt;linux\/init.h> #include &lt;linux\/module.h> #include &lt;linux\/kernel.h>   \/* printk() *\/ #include &lt;linux\/slab.h>     \/* kmalloc() *\/ #include &lt;linux\/fs.h>       \/* everything... *\/ #include &lt;linux\/errno.h>    \/* error codes *\/ #include &lt;linux\/types.h>    \/* size_t *\/ #include &lt;linux\/fcntl.h>    \/* O_ACCMODE *\/ #include &lt;linux\/cdev.h> #include &lt;asm\/uaccess.h>    \/* copy_*_user *\/ MODULE_LICENSE(\"Dual BSD\/GPL\"); MODULE_AUTHOR(\"Hcamael\"); int scull_major =   0; int scull_minor =   0; int scull_nr_devs = 4; int scull_quantum = 4000; int scull_qset = 1000; struct scull_qset {     void **data;     struct scull_qset *next; }; struct scull_dev {     struct scull_qset *data;  \/* Pointer to first quantum set. *\/     int quantum;              \/* The current quantum size. *\/     int qset;                 \/* The current array size. *\/     unsigned long size;       \/* Amount of data stored here. *\/     unsigned int access_key;  \/* Used by sculluid and scullpriv. *\/     struct mutex mutex;       \/* Mutual exclusion semaphore. *\/     struct cdev cdev;     \/* Char device structure. *\/ }; struct scull_dev *scull_devices;    \/* allocated in scull_init_module *\/ \/*  * Follow the list.  *\/ struct scull_qset *scull_follow(struct scull_dev *dev, int n) {     struct scull_qset *qs = dev->data;         \/* Allocate the first qset explicitly if need be. *\/     if (! qs) {         qs = dev->data = kmalloc(sizeof(struct scull_qset), GFP_KERNEL);         if (qs == NULL)             return NULL;         memset(qs, 0, sizeof(struct scull_qset));     }     \/* Then follow the list. *\/     while (n--) {         if (!qs->next) {             qs->next = kmalloc(sizeof(struct scull_qset), GFP_KERNEL);             if (qs->next == NULL)                 return NULL;             memset(qs->next, 0, sizeof(struct scull_qset));         }         qs = qs->next;         continue;     }     return qs; } \/*  * Data management: read and write.  *\/ ssize_t scull_read(struct file *filp, char __user *buf, size_t count,                 loff_t *f_pos) {     struct scull_dev *dev = filp->private_data;     struct scull_qset *dptr; \/* the first listitem *\/     int quantum = dev->quantum, qset = dev->qset;     int itemsize = quantum * qset; \/* how many bytes in the listitem *\/     int item, s_pos, q_pos, rest;     ssize_t retval = 0;     if (mutex_lock_interruptible(&amp;dev->mutex))         return -ERESTARTSYS;     if (*f_pos >= dev->size)         goto out;     if (*f_pos + count > dev->size)         count = dev->size - *f_pos;     \/* Find listitem, qset index, and offset in the quantum *\/     item = (long)*f_pos \/ itemsize;     rest = (long)*f_pos % itemsize;     s_pos = rest \/ quantum; q_pos = rest % quantum;     \/* follow the list up to the right position (defined elsewhere) *\/     dptr = scull_follow(dev, item);     if (dptr == NULL || !dptr->data || ! dptr->data[s_pos])         goto out; \/* don't fill holes *\/     \/* read only up to the end of this quantum *\/     if (count > quantum - q_pos)         count = quantum - q_pos;     if (raw_copy_to_user(buf, dptr->data[s_pos] + q_pos, count)) {         retval = -EFAULT;         goto out;     }     *f_pos += count;     retval = count;   out:     mutex_unlock(&amp;dev->mutex);     return retval; } ssize_t scull_write(struct file *filp, const char __user *buf, size_t count,                 loff_t *f_pos) {     struct scull_dev *dev = filp->private_data;     struct scull_qset *dptr;     int quantum = dev->quantum, qset = dev->qset;     int itemsize = quantum * qset;     int item, s_pos, q_pos, rest;     ssize_t retval = -ENOMEM; \/* Value used in \"goto out\" statements. *\/     if (mutex_lock_interruptible(&amp;dev->mutex))         return -ERESTARTSYS;     \/* Find the list item, qset index, and offset in the quantum. *\/     item = (long)*f_pos \/ itemsize;     rest = (long)*f_pos % itemsize;     s_pos = rest \/ quantum;     q_pos = rest % quantum;     \/* Follow the list up to the right position. *\/     dptr = scull_follow(dev, item);     if (dptr == NULL)         goto out;     if (!dptr->data) {         dptr->data = kmalloc(qset * sizeof(char *), GFP_KERNEL);         if (!dptr->data)             goto out;         memset(dptr->data, 0, qset * sizeof(char *));     }     if (!dptr->data[s_pos]) {         dptr->data[s_pos] = kmalloc(quantum, GFP_KERNEL);         if (!dptr->data[s_pos])             goto out;     }     \/* Write only up to the end of this quantum. *\/     if (count > quantum - q_pos)         count = quantum - q_pos;     if (raw_copy_from_user(dptr->data[s_pos]+q_pos, buf, count)) {         retval = -EFAULT;         goto out;     }     *f_pos += count;     retval = count;         \/* Update the size. *\/     if (dev->size &lt; *f_pos)         dev->size = *f_pos;   out:     mutex_unlock(&amp;dev->mutex);     return retval; } \/* Beginning of the scull device implementation. *\/ \/*  * Empty out the scull device; must be called with the device  * mutex held.  *\/ int scull_trim(struct scull_dev *dev) {     struct scull_qset *next, *dptr;     int qset = dev->qset;   \/* \"dev\" is not-null *\/     int i;     for (dptr = dev->data; dptr; dptr = next) { \/* all the list items *\/         if (dptr->data) {             for (i = 0; i &lt; qset; i++)                 kfree(dptr->data[i]);             kfree(dptr->data);             dptr->data = NULL;         }         next = dptr->next;         kfree(dptr);     }     dev->size = 0;     dev->quantum = scull_quantum;     dev->qset = scull_qset;     dev->data = NULL;     return 0; } int scull_release(struct inode *inode, struct file *filp) {     printk(KERN_DEBUG \"process %i (%s) success release minor(%u) file\\n\", current->pid, current->comm, iminor(inode));     return 0; } \/*  * Open and close  *\/ int scull_open(struct inode *inode, struct file *filp) {     struct scull_dev *dev; \/* device information *\/     dev = container_of(inode->i_cdev, struct scull_dev, cdev);     filp->private_data = dev; \/* for other methods *\/     \/* If the device was opened write-only, trim it to a length of 0. *\/     if ( (filp->f_flags &amp; O_ACCMODE) == O_WRONLY) {         if (mutex_lock_interruptible(&amp;dev->mutex))             return -ERESTARTSYS;         scull_trim(dev); \/* Ignore errors. *\/         mutex_unlock(&amp;dev->mutex);     }     printk(KERN_DEBUG \"process %i (%s) success open minor(%u) file\\n\", current->pid, current->comm, iminor(inode));     return 0; } \/*  * The \"extended\" operations -- only seek.  *\/ loff_t scull_llseek(struct file *filp, loff_t off, int whence) {     struct scull_dev *dev = filp->private_data;     loff_t newpos;     switch(whence) {       case 0: \/* SEEK_SET *\/         newpos = off;         break;       case 1: \/* SEEK_CUR *\/         newpos = filp->f_pos + off;         break;       case 2: \/* SEEK_END *\/         newpos = dev->size + off;         break;       default: \/* can't happen *\/         return -EINVAL;     }     if (newpos &lt; 0)         return -EINVAL;     filp->f_pos = newpos;     return newpos; } struct file_operations scull_fops = {     .owner =    THIS_MODULE,     .llseek =   scull_llseek,     .read =     scull_read,     .write =    scull_write,     \/\/ .unlocked_ioctl = scull_ioctl,     .open =     scull_open,     .release =  scull_release, }; \/*  * Set up the char_dev structure for this device.  *\/ static void scull_setup_cdev(struct scull_dev *dev, int index) {     int err, devno = MKDEV(scull_major, scull_minor + index);     cdev_init(&amp;dev->cdev, &amp;scull_fops);     dev->cdev.owner = THIS_MODULE;     dev->cdev.ops = &amp;scull_fops;     err = cdev_add (&amp;dev->cdev, devno, 1);     \/* Fail gracefully if need be. *\/     if (err)         printk(KERN_NOTICE \"Error %d adding scull%d\", err, index);     else         printk(KERN_INFO \"scull: %d add success\\n\", index); } void scull_cleanup_module(void) {     int i;     dev_t devno = MKDEV(scull_major, scull_minor);     \/* Get rid of our char dev entries. *\/     if (scull_devices) {         for (i = 0; i &lt; scull_nr_devs; i++) {             scull_trim(scull_devices + i);             cdev_del(&amp;scull_devices[i].cdev);         }         kfree(scull_devices);     }     \/* cleanup_module is never called if registering failed. *\/     unregister_chrdev_region(devno, scull_nr_devs);     printk(KERN_INFO \"scull: cleanup success\\n\"); } int scull_init_module(void) {     int result, i;     dev_t dev = 0;     \/*      * Get a range of minor numbers to work with, asking for a dynamic major      * unless directed otherwise at load time.      *\/     if (scull_major) {         dev = MKDEV(scull_major, scull_minor);         result = register_chrdev_region(dev, scull_nr_devs, \"scull\");     } else {         result = alloc_chrdev_region(&amp;dev, scull_minor, scull_nr_devs, \"scull\");         scull_major = MAJOR(dev);     }     if (result &lt; 0) {         printk(KERN_WARNING \"scull: can't get major %d\\n\", scull_major);         return result;     } else {         printk(KERN_INFO \"scull: get major %d success\\n\", scull_major);     }         \/*      * Allocate the devices. This must be dynamic as the device number can      * be specified at load time.      *\/     scull_devices = kmalloc(scull_nr_devs * sizeof(struct scull_dev), GFP_KERNEL);     if (!scull_devices) {         result = -ENOMEM;         goto fail;     }     memset(scull_devices, 0, scull_nr_devs * sizeof(struct scull_dev));         \/* Initialize each device. *\/     for (i = 0; i &lt; scull_nr_devs; i++) {         scull_devices[i].quantum = scull_quantum;         scull_devices[i].qset = scull_qset;         mutex_init(&amp;scull_devices[i].mutex);         scull_setup_cdev(&amp;scull_devices[i], i);     }     return 0; \/* succeed *\/   fail:     scull_cleanup_module();     return result; } module_init(scull_init_module); module_exit(scull_cleanup_module);<\/code><\/pre>\n<p>  <\/p>\n<h2><font color=\"#1c22be\">\u276f<\/font> <font color=\"#454cee\">\u041a\u043b\u0430\u0441\u0441\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u044f \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u0432<\/font><\/h2>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/je\/f1\/at\/jef1atsvf60cie5_7bfb9r3a44s.png\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/je\/f1\/at\/jef1atsvf60cie5_7bfb9r3a44s.png\"\/><\/p>\n<p>  \u0414\u0440\u0430\u0439\u0432\u0435\u0440\u044b \u0434\u0435\u043b\u044f\u0442\u0441\u044f \u043d\u0430 \u0442\u0440\u0438 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0438: \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u044b\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430, \u0431\u043b\u043e\u0447\u043d\u044b\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0438 \u0441\u0435\u0442\u0435\u0432\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b. \u0412 \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u043c \u043a\u043e\u0434\u0435 \u0431\u044b\u043b\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043d\u043e \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u043e\u0435 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e, \u0430 \u043e\u0431\u0441\u0443\u0436\u0434\u0435\u043d\u0438\u0435 \u0434\u0432\u0443\u0445 \u0434\u0440\u0443\u0433\u0438\u0445 \u043a\u0430\u0442\u0435\u0433\u043e\u0440\u0438\u0439 \u0432\u044b\u0445\u043e\u0434\u0438\u0442 \u0437\u0430 \u0440\u0430\u043c\u043a\u0438 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<p>  \u041a\u0430\u043a \u0431\u044b\u043b\u043e \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432\u044b\u0448\u0435, <code>brw-rw--<\/code> \u2014 \u0441\u0442\u0440\u043e\u043a\u0430 \u043e \u043f\u0440\u0430\u0432\u0430\u0445 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0434\u043b\u044f \u0431\u043b\u043e\u0447\u043d\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u0431\u0443\u043a\u0432\u044b \u00abb\u00bb, \u0430 \u0434\u043b\u044f \u0441\u0438\u043c\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u0431\u0443\u043a\u0432\u044b \u00abc\u00bb.<\/p>\n<h2><font color=\"#1c22be\">\u276f<\/font> <font color=\"#454cee\"> \u041e \u0441\u0442\u0430\u0440\u0448\u0438\u0445 \u0438 \u043c\u043b\u0430\u0434\u0448\u0438\u0445 \u0447\u0438\u0441\u043b\u0430\u0445<\/font><\/h2>\n<p>  \u0421\u0442\u0430\u0440\u0448\u0435\u0435 \u0447\u0438\u0441\u043b\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442 \u043e\u0434\u0438\u043d \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u043e\u0442 \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445. \u0412 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435, \u0435\u0441\u043b\u0438 \u0441\u0442\u0430\u0440\u0448\u0435\u0435 \u0447\u0438\u0441\u043b\u043e \u0443 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432 \u0441\u043e\u0432\u043f\u0430\u0434\u0430\u0435\u0442, \u044d\u0442\u043e \u043e\u0437\u043d\u0430\u0447\u0430\u0435\u0442, \u0447\u0442\u043e \u043e\u043d\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043e\u0434\u043d\u0438\u043c \u0438 \u0442\u0435\u043c \u0436\u0435 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u043c.<br \/>  \u0412 \u043e\u0434\u043d\u043e\u043c \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 drive \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d\u043e \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432, \u0438 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043c\u043b\u0430\u0434\u0448\u0438\u043c\u0438 \u0447\u0438\u0441\u043b\u0430\u043c\u0438. \u0412\u043c\u0435\u0441\u0442\u0435 \u0441\u0442\u0430\u0440\u0448\u0435\u0435 \u0438 \u043c\u043b\u0430\u0434\u0448\u0435\u0435 \u0447\u0438\u0441\u043b\u043e \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0437\u0443\u044e\u0442 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e, \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0435 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u043c (\u043a\u0430\u043a \u043f\u043e\u043a\u0430\u0437\u0430\u043d\u043e \u0432\u044b\u0448\u0435).<\/p>\n<pre><code class=\"plaintext\">brw-rw----  1 root disk      8,   0 Dec 17 13:02 sda brw-rw----  1 root disk      8,   1 Dec 17 13:02 sda1<\/code><\/pre>\n<p>  \u0421\u0442\u0430\u0440\u0448\u0435\u0435 \u0447\u0438\u0441\u043b\u043e \u0430\u043f\u043f\u0430\u0440\u0430\u0442\u0443\u0440\u044b <code>sda<\/code> \u0438 <code>sda1<\/code> \u044d\u0442\u043e 8, \u0430 \u043c\u043b\u0430\u0434\u0448\u0438\u0445 \u0447\u0438\u0441\u0435\u043b \u0437\u0434\u0435\u0441\u044c \u0434\u0432\u0430: \u0443 \u043e\u0434\u043d\u043e\u0433\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 0, \u0430 \u0443 \u0434\u0440\u0443\u0433\u043e\u0433\u043e 1.<\/p>\n<h2><font color=\"#1c22be\">\u276f<\/font> <font color=\"#454cee\"> \u041a\u0430\u043a \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 API<\/font><\/h2>\n<p>  \u042f \u043f\u0440\u0438\u0432\u044b\u043a \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e <code>\/dev\/xxx<\/code> \u2013 \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441, \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0439 \u0444\u0430\u0439\u043b\u043e\u043c, \u0430 \u0432 Linux \u00ab\u0432\u0441\u0451 \u2013 \u0444\u0430\u0439\u043b\u00bb. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u043e\u043f\u0435\u0440\u0438\u0440\u0443\u044f \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u043e\u043c, \u043c\u044b, \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u043e\u043f\u0435\u0440\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b\u043e\u043c, \u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0435 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f define\/open\/read\/write\u2026 \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442 \u0441 <code>\/dev\/xxx<\/code>. \u041b\u044e\u0431\u044b\u0435 \u043c\u044b\u0441\u043b\u0438\u043c\u044b\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0441 API \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430 \u2013 \u044d\u0442\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u0444\u0430\u0439\u043b\u0430\u043c\u0438.<\/p>\n<p>  \u041a\u0430\u043a\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u0437\u0434\u0435\u0441\u044c \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u044e\u0442? \u0412\u0441\u0435 \u043e\u043d\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e\u0442\u0441\u044f \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0435 file_operations \u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u043e\u043c <a href=\"https:\/\/raw.githubusercontent.com\/torvalds\/linux\/master\/include\/linux\/fs.h\">\u0444\u0430\u0439\u043b\u0435 \u044f\u0434\u0440\u0430<\/a> &lt;linux\/fs.h>.<\/p>\n<p>  \u0412 \u043a\u043e\u0434\u0435, \u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u043e\u043c \u0432\u044b\u0448\u0435 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430:<\/p>\n<pre><code class=\"plaintext\">struct file_operations scull_fops = {     .owner =    THIS_MODULE,     .llseek =   scull_llseek,     .read =     scull_read,     .write =    scull_write,     .open =     scull_open,     .release =  scull_release, };<\/code><\/pre>\n<p>  \u042f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u044e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0438 \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u044e \u0435\u0451. \u041d\u0435 \u0441\u0447\u0438\u0442\u0430\u044f owner, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0445 \u0447\u043b\u0435\u043d\u043e\u0432 \u2013 \u044d\u0442\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u0439.<\/p>\n<p>  \u0417\u0430\u0442\u0435\u043c \u044f \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u044e <code>cdev_add<\/code>, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u043b\u044f \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u043f\u043e\u0434 \u043a\u0430\u0436\u0434\u044b\u0439 \u0434\u0440\u0430\u0439\u0432\u0435\u0440, \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>scull_setup_cdev<\/code>.<\/p>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044e \u201copen\u201d (\u043e\u0442\u043a\u0440\u044b\u0442\u044c) \u0441 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e\u043c \u043f\u043e\u0434 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430, \u044f \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e scull_open, \u0447\u0442\u043e \u044d\u043a\u0432\u0438\u0432\u0430\u043b\u0435\u043d\u0442\u043d\u043e \u00ab\u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442\u0443\u00bb \u0444\u0443\u043d\u043a\u0446\u0438\u0438 open \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u043d\u043e\u043c \u0432\u044b\u0437\u043e\u0432\u0435.<\/p>\n<h2><font color=\"#1c22be\">\u276f<\/font> <font color=\"#454cee\">\u041a\u0430\u043a \u0441\u0433\u0435\u043d\u0435\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0443\u0436\u043d\u043e\u0435 \u043d\u0430\u043c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e \u043f\u043e\u0434 \/dev<\/font><\/h2>\n<p>  \u0421\u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u043e\u0432\u0430\u0432 \u0432\u044b\u0448\u0435\u043f\u0440\u0438\u0432\u0435\u0434\u0451\u043d\u043d\u044b\u0439 \u043a\u043e\u0434, \u043f\u043e\u043b\u0443\u0447\u0438\u043c <code>scull.ko<\/code>, \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u0434\u043f\u0438\u0448\u0435\u043c \u0435\u0433\u043e \u0438, \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043c \u0432 \u044f\u0434\u0440\u043e \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 <code>insmod<\/code>.<\/p>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u0438\u043c, \u0443\u0434\u0430\u0447\u043d\u043e \u043b\u0438 \u043e\u043d \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b\u0441\u044f:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/1g\/d7\/fa\/1gd7facfjqjqqmaapez1trkvzn0.png\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/1g\/d7\/fa\/1gd7facfjqjqqmaapez1trkvzn0.png\"\/><\/p>\n<p>  \u0414\u0430, \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u043b\u0441\u044f \u0443\u0441\u043f\u0435\u0448\u043d\u043e, \u043d\u043e \u043e\u043d \u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0444\u0430\u0439\u043b\u0430 \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430 \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 \/dev. \u041d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f mknod \u0434\u043b\u044f \u0441\u0432\u044f\u0437\u044b\u0432\u0430\u043d\u0438\u044f \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u0430:<\/p>\n<div style=\"text-align:center;\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/webt\/yg\/l8\/wt\/ygl8wtvqvcrybn4jd_wcqol0wpo.png\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/yg\/l8\/wt\/ygl8wtvqvcrybn4jd_wcqol0wpo.png\"\/><\/div>\n<p>  <\/p>\n<h2><font color=\"#1c22be\">\u276f<\/font> <font color=\"#454cee\"> \u0418\u0442\u043e\u0433\u0438<\/font><\/h2>\n<p>  \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u043d\u0435 \u0441\u043e\u0432\u0435\u0440\u0448\u0430\u043b\u0438 \u043d\u0438\u043a\u0430\u043a\u0438\u0445 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0439 \u0441 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432\u043e\u043c, \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438\u0441\u044c <code>kmalloc<\/code>, \u0438 \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043b\u0438 \u0431\u043b\u043e\u043a \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 \u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0441\u0442\u0432\u0435 \u044f\u0434\u0440\u0430.<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043d\u0435 \u0431\u0443\u0434\u0443 \u0432\u0434\u0430\u0432\u0430\u0442\u044c\u0441\u044f \u0432 \u0434\u0435\u0442\u0430\u043b\u0438 \u043e \u043a\u043e\u0434\u0435, \u0432\u0441\u0435 \u0438\u0445 \u043c\u043e\u0436\u043d\u043e \u0443\u0442\u043e\u0447\u043d\u0438\u0442\u044c, \u043f\u043e\u0433\u0443\u0433\u043b\u0438\u0432 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0438\u043b\u0438 \u0438\u0437\u0443\u0447\u0438\u0432 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u0447\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b.<\/p>\n<p>  \u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0432\u0430\u043c\u0438, \u043a\u0430\u043a \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0434\u0440\u0430\u0439\u0432\u0435\u0440\u0430: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043d\u0438\u0433\u0438, \u0447\u0442\u043e\u0431\u044b \u0443\u0441\u0432\u043e\u0438\u0442\u044c \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043a\u043e\u043d\u0446\u0435\u043f\u0446\u0438\u0438, \u0430 \u0437\u0430\u0442\u0435\u043c \u0438\u0441\u043a\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043f\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c \u0434\u0435\u0442\u0430\u043b\u044f\u043c, \u043a\u043e\u0433\u0434\u0430 \u0434\u043e\u0439\u0434\u0451\u0442 \u0434\u0435\u043b\u043e \u0434\u043e \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u044f.<\/p>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u044f \u043d\u0435 \u0437\u043d\u0430\u044e, \u043a\u0430\u043a\u043e\u0439 API \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0434\u0440\u0430\u0439\u0432\u0435\u0440. \u0412\u0441\u0451, \u0447\u0442\u043e \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u2013 \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0439 API \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u043c\u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438. \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043c\u043d\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u044f\u043c\u0438 <code>open<\/code>, <code>close<\/code>, <code>read<\/code> \u0438 <code>write<\/code>. \u041a\u0430\u043a \u0434\u0435\u043b\u0430\u044e\u0442\u0441\u044f \u0434\u0440\u0443\u0433\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u0441 \u0444\u0430\u0439\u043b\u0430\u043c\u0438 \u2013 \u043c\u043e\u0436\u043d\u043e \u0443\u0442\u043e\u0447\u043d\u0438\u0442\u044c \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<h3><font color=\"#454cee\">\u0421\u0441\u044b\u043b\u043a\u0438<\/font><\/h3>\n<p>   <\/p>\n<ul>\n<li><a href=\"https:\/\/github.com\/jesstess\/ldd4\">github.com\/jesstess\/ldd4<\/a><\/li>\n<li> <a href=\"https:\/\/raw.githubusercontent.com\/Hcamael\/Linux_Driver_Study\/master\/hello.c\">raw.githubusercontent.com\/Hcamael\/Linux_Driver_Study\/master\/hello.c<\/a><\/li>\n<li> <a href=\"https:\/\/jin-yang.github.io\/post\/kernel-modules.html\">jin-yang.github.io\/post\/kernel-modules.html<\/a><\/li>\n<li> <a href=\"https:\/\/raw.githubusercontent.com\/Hcamael\/Linux_Driver_Study\/master\/scull.c\">raw.githubusercontent.com\/Hcamael\/Linux_Driver_Study\/master\/scull.c<\/a><\/li>\n<li> <a href=\"https:\/\/raw.githubusercontent.com\/torvalds\/linux\/master\/include\/linux\/fs.h\">raw.githubusercontent.com\/torvalds\/linux\/master\/include\/linux\/fs.h<\/a><\/li>\n<\/ul>\n<p>  <a href=\"https:\/\/timeweb.cloud\/vds-vps?utm_source=habr&amp;utm_medium=banner&amp;utm_campaign\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/mx\/ua\/nb\/mxuanbovcusqgmqdgugvpnql8vq.jpeg\" data-src=\"https:\/\/habrastorage.org\/webt\/mx\/ua\/nb\/mxuanbovcusqgmqdgugvpnql8vq.jpeg\" data-blurred=\"true\"\/><\/a><\/div>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/timeweb\/blog\/724282\/\"> https:\/\/habr.com\/ru\/company\/timeweb\/blog\/724282\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-1\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\"><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/webt\/xg\/q2\/0u\/xgq20uagk7s3wedhylmrea5_10m.jpeg\" alt=\"image\" data-src=\"https:\/\/habrastorage.org\/webt\/xg\/q2\/0u\/xgq20uagk7s3wedhylmrea5_10m.jpeg\" data-blurred=\"true\"\/><\/p>\n<p>  \u041d\u0435\u0434\u0430\u0432\u043d\u043e \u044f \u0437\u0430\u043d\u0438\u043c\u0430\u043b\u0441\u044f \u0438\u0437\u0443\u0447\u0435\u043d\u0438\u0435\u043c IoT \u0438, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u043d\u0435 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u043b\u043e \u0443\u0441\u0442\u0440\u043e\u0439\u0441\u0442\u0432, \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0430\u0445 \u0441\u0438\u043c\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0438 \u044f \u0447\u0430\u0441\u0442\u043e \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u043b\u0441\u044f \u0441 \u043d\u0435\u0438\u043c\u0435\u043d\u0438\u0435\u043c \u043d\u0443\u0436\u043d\u043e\u0433\u043e \/dev\/xxx. \u0422\u0430\u043a \u0447\u0442\u043e \u044f \u0441\u0442\u0430\u043b \u0437\u0430\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c\u0441\u044f, \u0430 \u043c\u043e\u0433\u0443 \u043b\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0440\u0430\u0439\u0432\u0435\u0440 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043f\u0440\u043e\u0448\u0438\u0432\u043a\u0443 \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c. \u041d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0442\u043e\u0433\u043e, \u043d\u0430\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0436\u043d\u043e \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442, \u0438 \u0443\u0434\u0430\u0441\u0442\u0441\u044f \u043b\u0438 \u0432\u043e\u043f\u043b\u043e\u0442\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0435 \u043d\u0430\u043c\u0435\u0440\u0435\u043d\u0438\u0435, \u0432 \u043b\u044e\u0431\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b \u043d\u0435 \u043f\u043e\u0436\u0430\u043b\u0435\u0435\u0442\u0435, \u0435\u0441\u043b\u0438 \u043d\u0430\u0443\u0447\u0438\u0442\u0435\u0441\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0434\u0440\u0430\u0439\u0432\u0435\u0440 Linux \u0441 \u043d\u0443\u043b\u044f.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-347141","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/347141","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=347141"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/347141\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=347141"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=347141"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=347141"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}