日本a√视频在线,久久青青亚洲国产,亚洲一区欧美二区,免费g片在线观看网站

        <style id="k3y6c"><u id="k3y6c"></u></style>
        <s id="k3y6c"></s>
        <mark id="k3y6c"></mark>
          
          

          <mark id="k3y6c"></mark>

          新聞中心

          EEPW首頁(yè) > 嵌入式系統(tǒng) > 設(shè)計(jì)應(yīng)用 > 利用udev、sys動(dòng)態(tài)創(chuàng)建linux設(shè)備結(jié)點(diǎn)

          利用udev、sys動(dòng)態(tài)創(chuàng)建linux設(shè)備結(jié)點(diǎn)

          作者: 時(shí)間:2012-08-27 來(lái)源:網(wǎng)絡(luò) 收藏

          在Linux2.6內(nèi)核中,devfs被認(rèn)為是過(guò)時(shí)的方法,并最終被拋棄,取代了它。Devfs的一個(gè)很重要的特點(diǎn)就是可以。那我們現(xiàn)在如何通過(guò)文件系統(tǒng)呢?

          本文引用地址:http://yuyingmama.com.cn/article/148527.htm

          下面通過(guò)一個(gè)實(shí)例,說(shuō)明、的方法。注意代碼中紅色的部分是為了實(shí)現(xiàn)動(dòng)態(tài)創(chuàng)建設(shè)備結(jié)點(diǎn)添加的。

          #include

          #include

          #include

          #include

          #include

          #include

          #include

          MODULE_LICENSE (GPL);

          int hello_major = 252;

          int hello_minor = 0;

          int number_of_devices = 1;

          char data[50]=foobar not equal to barfoo;

          STruct cdev cdev;

          dev_t dev = 0;

          staTIc int hello_open (struct inode *inode, struct file *file)

          {

          printk (KERN_INFO Hey! device openedn);

          return 0;

          }

          static int hello_release (struct inode *inode, struct file *file)

          {

          printk (KERN_INFO Hmmm... device closedn);

          return 0;

          }

          ssize_t hello_read (struct file *filp, char *buff, size_t count, loff_t *offp)

          {

          ssize_t result = 0;

          if (copy_to_user (buff, data, sizeof(data)-1))

          result = -EFAULT;

          else

          printk (KERN_INFO wrote %d bytesn, count);

          return result;

          }

          ssize_t hello_write (struct file *filp, cONst char *buf, size_t count, loff_t *f_pos)

          {

          ssize_t ret = 0;

          printk (KERN_INFO Writing %d bytesn, count);

          if (count>127) return -ENOMEM;

          if (count0) return -EINVAL;

          if (copy_from_user (data, buf, count)) {

          ret = -EFAULT;

          }

          else {

          data[127]='