Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 file'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?

like image 613
user48956 Avatar asked Oct 10 '22 13:10

user48956


1 Answers

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) ?
like image 139
synthesizerpatel Avatar answered Oct 14 '22 02:10

synthesizerpatel