In Linux, what kinds of files are memory mapped?
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) ?
精彩评论