????????????????????????豸????????????????豸???1??????LANANA????????豸??10?????????豸??????????????????????????Щ??????????????й???????г??Щ???豸???????????????????塣

??1 ???????豸??1????????豸??

?????Щ?豸?????????????????/dev/null???????豸??????????????????????????Щ???豸???漰????????????????????к??????????????1?????豸???1??memory_fops?ж???????Щ??????????????£?

????driver/char/mem.c

static const struct file_operations memory_fops = {
 .open = memory_open??
 .llseek = noop_llseek??
};

???????к???memory_open???????????????????豸????????豸??????????

static int memory_open(struct inode *inode?? struct file *filp)
{
 int minor;
 const struct memdev *dev;

 minor = iminor(inode); /* get the minor device number commented by guoqingbo */
 if (minor >= ARRAY_SIZE(devlist))
  return -ENXIO;

 dev = &devlist[minor];/* select the specific file_operations */
 if (!dev->fops)
  return -ENXIO;

 filp->f_op = dev->fops;
 if (dev->dev_info)
  filp->f_mapping->backing_dev_info = dev->dev_info;

 /* Is /dev/mem or /dev/kmem ? */
 if (dev->dev_info == &directly_mappable_cdev_bdi)
  filp->f_mode |= FMODE_UNSIGNED_OFFSET;

 if (dev->fops->open)  //open the device
  return dev->fops->open(inode?? filp);

 return 0;
}