Skip to content

Commit

Permalink
Add notes for section 12.3.
Browse files Browse the repository at this point in the history
  • Loading branch information
lorenzo-stoakes committed May 9, 2016
1 parent 558c819 commit bb58424
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions 12.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,37 @@ static struct inode_operations shmem_symlink_inode_operations = {
sees no difference between pages backed by a real file and those backed by
virtual files.

## 12.3 Creating files in tmpfs

* Because `tmpfs` is mounted as a proper filesystem that is visible to the user
it must support directory inode operations, as provided for by
[shmem_dir_inode_operations][shmem_dir_inode_operations], discussed in the
previous section.

* The implementation of most of the functions used by
`shmem_dir_inode_operations` are rather small but they are all very
interconnected.

* The majority of the inode fields provided by the VFS are filled by
[shmem_get_inode()][shmem_get_inode].

* When creating a new file [shmem_create()][shmem_create] is used - this is a
small wrapper around [shmem_mknod()][shmem_mknod] which is called with the
`S_IFREG` flag set so a regular file will be created.

* Again `shmem_mknod()` is really just a wrapper around `shmem_get_inode()`
which creates an inode and fills in the [struct inode][inode] fields as
required.

* The 3 most interesting fields that are populated are
`inode->i_mapping->a_ops`, `inode->i_op` and `inode->i_fop` fields.

* After the inode has been created, `shmem_mknod()` updates the directory
inode's `size` and `mtime` statistics before creating the new inode.

* Files are created differently in `shm` despite the fact the filesystems are
basically the same - this is looked at in more detail in 12.7.

[mmap]:http://man7.org/linux/man-pages/man2/mmap.2.html
[fork]:http://man7.org/linux/man-pages/man2/fork.2.html
[shmget]:http://man7.org/linux/man-pages/man2/shmget.2.html
Expand Down Expand Up @@ -297,3 +328,8 @@ static struct inode_operations shmem_symlink_inode_operations = {
[shmem_truncate]:https://github.com/lorenzo-stoakes/linux-historical/blob/v2.4.22/mm/shmem.c#L351
[shmem_notify_change]:https://github.com/lorenzo-stoakes/linux-historical/blob/v2.4.22/mm/shmem.c#L375
[shmem_getpage]:https://github.com/lorenzo-stoakes/linux-historical/blob/v2.4.22/mm/shmem.c#L583

[shmem_get_inode]:https://github.com/lorenzo-stoakes/linux-historical/blob/v2.4.22/mm/shmem.c#L809
[shmem_create]:https://github.com/lorenzo-stoakes/linux-historical/blob/v2.4.22/mm/shmem.c#L1164
[shmem_mknod]:https://github.com/lorenzo-stoakes/linux-historical/blob/v2.4.22/mm/shmem.c#L1139
[inode]:https://github.com/lorenzo-stoakes/linux-historical/blob/v2.4.22/include/linux/fs.h#L438

0 comments on commit bb58424

Please sign in to comment.