开发者

In Linux, what kinds of files are memory mapped?

开发者 https://www.devze.com 2023-03-18 03:11 出处:网络
What are the different types of Linux files that can be created entirely in memory? For example, a pipe file may be created, but does the location of where a file is created (or the filesystem type o

What are the different types of Linux files that can be created entirely in memory?

For example, a pipe file may be created, but does the location of where a file is created (or the filesystem type of the fil开发者_开发技巧e's path) make a difference to whether a disk access is involved? If I create a pipe file in an ext3 file system, could a physical disk access result?


Off the top of my head, and without looking at any books :D, I think it breaks down like this:

mmap-able:

  • files (of course)
  • soft-links (final target if it's a file, block device or kernel device)
  • hard-links (final target if it's a file, block device or kernel device)
  • block devices (/dev/ram1, /dev/sda1, etc..)
  • character devices (You can mmap character devices, but in some cases it won't make sense (or work right). For instance an easy way to develop a driver in userland is to have a kernel module handle a basic mmap to your hardware and then expose the hardware via a mmapable character device so that a non-privileged user can access it. (USB, audio, flash cards) use this. A lot of embedded stuff does too.
  • unix domain sockets? Does zerocopy/sendfile count?

mmap-able but not a file?

  • shared memory

un-memmappable?

  • directories
  • fifos (one reader, one writer) ?
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号