日期:2014-5-16 浏览次数:20143次

Linux raw device 裸设备
  ┌────────────────────────────────────────────────────────── RAW driver (/dev/raw/rawN) 
  │ CONFIG_RAW_DRIVER:                                                                                                                             
  │ The raw driver permits block devices to be bound to /dev/raw/rawN.                                                                             
  │ Once bound, I/O against /dev/raw/rawN uses efficient zero-copy I/O.                                                                            
  │ See the raw(8) manpage for more details.                                                                                                         │  
  │ Applications should preferably open the device (eg /dev/hda1)                                                                                 
  │ with the O_DIRECT flag.
  ----------------------------
  上面是在内核版本3.5.3中的RAW设备相关的配置选项。


 - 在一个块设备安装到一个节点之前,对该设备的访问通常是作为一个线性的无结构的字节流来访问的,
   称为“原始设备(raw device)”。设备上的文件系统是不可访问的。经过安装以后,设备上的文件系统
   就以访问了。[1]
 
 -     Once  bound  to  a  block  device, a raw device can be opened, read and
       written, just like the block device it is bound to.  However,  the  raw
       device  does  not behave exactly like the block device.  In particular,
       access to the raw device  bypasses  the  kernel's  block  buffer  cache
       entirely: all I/O is done directly to and from the address space of the
       process performing the I/O.  If the underlying block device driver  can
       support  DMA,  then  no data copying at all is required to complete the
       I/O.


       Because raw I/O involves direct hardware access to a process's  memory,
       a  few extra restrictions must be observed.  All I/Os must be correctly
       aligned in memory and on disk: they must start at a  sector  offset  on
       disk, they must be an exact number of sectors long, and the data buffer
       in virtual memory must also be aligned to  a  multiple  of  the  sector
       size.  The sector size is 512 bytes for most devices. [2] 


 - Starting with the Linux 2.6 kernel, raw devices are being ph