|
AquilaOS documentation
How it works, and its code
|
minix: inodes, and the zones of a file. More...
Go to the source code of this file.
Functions | |
| static off_t | minix_inode_off (struct minix *desc, ino_t ino) |
| Returns where an inode is on the disk, in bytes, or -EINVAL for an inode number that doesn't exist. | |
| int | minix_inode_read (struct minix *desc, ino_t ino, struct minix_inode *ref) |
| Reads an inode from the disk. | |
| int | minix_inode_write (struct minix *desc, ino_t ino, struct minix_inode *ref) |
| Writes an inode to the disk. | |
| static int | zone_tree (struct minix *desc, size_t idx, int *slot, size_t *rel) |
| Finds where zone idx of a file is in its tree: the slot of zones[] it hangs from (0 to 6 for the direct zones, 7 for the singly indirect one, 8 for the doubly indirect one) in *slot, and its index under that slot in *rel. | |
| static size_t | zone_span (struct minix *desc, int depth) |
| Returns how many data zones are under one pointer of an indirect zone that is depth levels above them. | |
| ssize_t | minix_inode_block_read (struct minix *desc, struct minix_inode *m_inode, size_t idx, void *buf) |
| Reads a zone of a file. | |
| static int | table_alloc (struct minix *desc, blk_t *zone) |
| Allocates a zone for an indirect table, zeroed on the disk, and drops any cached copy of it (the zone may have been a table before). | |
| ssize_t | minix_inode_block_write (struct minix *desc, struct minix_inode *inode, ino_t ino, size_t idx, void *buf) |
| Writes a zone of a file, allocating it and the indirect zones above it if they don't exist yet. | |
| static blk_t | free_tree (struct minix *desc, blk_t zone, int depth, size_t from) |
| Frees the zones of the tree at zone (a data zone at depth 0, or an indirect zone depth levels above the data), from data zone from of the tree on. | |
| void | minix_zones_free (struct minix *desc, struct minix_inode *inode, size_t from) |
| Frees a file's zones, from a zone on, when the file is truncated or removed. | |
| ino_t | minix_inode_alloc (struct minix *desc) |
| Allocates a free inode: its bit is set in the inode bitmap, which is written back to the disk at once. | |
| void | minix_inode_free (struct minix *desc, ino_t ino) |
| Frees an inode: its bit is cleared in the inode bitmap, which is written back at once. | |
minix: inodes, and the zones of a file.
A file's zones are found through its inode's 7 direct zones, then a singly and a doubly indirect one: a tree of zones of 16-bit zone numbers. The indirect zones are read through the block cache.
Definition in file inode.c.
Frees the zones of the tree at zone (a data zone at depth 0, or an indirect zone depth levels above the data), from data zone from of the tree on.
Returns the zone, or 0 if it was freed. A table that can't be read stays, with what's under it.
Definition at line 281 of file inode.c.
References minix::bs, free_tree(), minix_bcache_get(), minix_block_free(), minix_block_write(), table(), and zone_span().
Referenced by ext2_blocks_free(), free_tree(), free_tree(), and minix_zones_free().
Allocates a free inode: its bit is set in the inode bitmap, which is written back to the disk at once.
| desc | the mounted filesystem |
Definition at line 340 of file inode.c.
References minix::bs, minix::imap, minix_superblock::imap_blocks, minix::imap_off, bitmap::map, bitmap::max_idx, minix_inode_alloc(), minix::superblock, minix::supernode, and vfs_write().
Referenced by minix_inode_alloc(), and minix_vmknod().
| ssize_t minix_inode_block_read | ( | struct minix * | desc, |
| struct minix_inode * | m_inode, | ||
| size_t | idx, | ||
| void * | buf ) |
Reads a zone of a file.
A zone that was never written (the file is sparse there) reads as zeros.
| desc | the mounted filesystem |
| m_inode | the file's inode |
| idx | the zone's index in the file |
| buf | where it goes, a block's size |
Definition at line 141 of file inode.c.
References minix::bs, memset(), minix_bcache_get(), minix_block_read(), minix_inode_block_read(), minix_inode::size, table(), zone_span(), zone_tree(), and minix_inode::zones.
Referenced by minix_dentry_create(), minix_dentry_find(), minix_inode_block_read(), minix_read(), minix_readdir(), minix_trunc(), and minix_write().
| ssize_t minix_inode_block_write | ( | struct minix * | desc, |
| struct minix_inode * | inode, | ||
| ino_t | ino, | ||
| size_t | idx, | ||
| void * | buf ) |
Writes a zone of a file, allocating it and the indirect zones above it if they don't exist yet.
The inode is written back if its zones changed.
| desc | the mounted filesystem |
| inode | the file's inode |
| ino | its inode number |
| idx | the zone's index in the file |
| buf | the zone's new contents |
Definition at line 208 of file inode.c.
References minix::bs, minix_bcache_get(), minix_block_alloc(), minix_block_write(), minix_inode_block_write(), minix_inode_write(), table(), table_alloc(), zone_span(), zone_tree(), and minix_inode::zones.
Referenced by minix_dentry_create(), minix_inode_block_write(), minix_trunc(), minix_vmknod(), and minix_write().
Frees an inode: its bit is cleared in the inode bitmap, which is written back at once.
| desc | the mounted filesystem |
| ino | the inode number |
Definition at line 366 of file inode.c.
References minix::bs, minix::imap, minix_superblock::imap_blocks, minix::imap_off, bitmap::map, bitmap::max_idx, minix_inode_free(), minix::superblock, minix::supernode, and vfs_write().
Referenced by minix_inode_free(), and minix_vmknod().
Returns where an inode is on the disk, in bytes, or -EINVAL for an inode number that doesn't exist.
Definition at line 13 of file inode.c.
References minix::inode_size, minix::inode_table, minix_inode_off(), minix_superblock::ninodes, and minix::superblock.
Referenced by minix_inode_off(), minix_inode_read(), and minix_inode_write().
| int minix_inode_read | ( | struct minix * | desc, |
| ino_t | ino, | ||
| struct minix_inode * | ref ) |
Reads an inode from the disk.
| desc | the mounted filesystem |
| ino | the inode number |
| ref | where it goes; NULL only checks the number |
Definition at line 31 of file inode.c.
References minix_inode_off(), minix_inode_read(), minix_inode::size, minix::supernode, and vfs_read().
Referenced by minix_dentry_create(), minix_finddir(), minix_inode_build(), minix_inode_read(), minix_inode_sync(), minix_read(), minix_readdir(), minix_trunc(), minix_vmknod(), and minix_write().
| int minix_inode_write | ( | struct minix * | desc, |
| ino_t | ino, | ||
| struct minix_inode * | ref ) |
Writes an inode to the disk.
| desc | the mounted filesystem |
| ino | the inode number |
| ref | the inode; NULL only checks the number |
Definition at line 63 of file inode.c.
References minix_inode_off(), minix_inode_write(), minix_inode::size, minix::supernode, and vfs_write().
Referenced by minix_dentry_create(), minix_inode_block_write(), minix_inode_sync(), minix_inode_write(), minix_trunc(), minix_vmknod(), and minix_write().
| void minix_zones_free | ( | struct minix * | desc, |
| struct minix_inode * | inode, | ||
| size_t | from ) |
Frees a file's zones, from a zone on, when the file is truncated or removed.
| desc | the mounted filesystem |
| inode | the file's inode, its zone pointers cleared here |
| from | the index of the first zone to free |
Definition at line 315 of file inode.c.
References minix::bs, free_tree(), MINIX_DIRECT_ZONES, minix_zones_free(), minix_inode::mode, and minix_inode::zones.
Referenced by minix_trunc(), minix_vmknod(), and minix_zones_free().
Allocates a zone for an indirect table, zeroed on the disk, and drops any cached copy of it (the zone may have been a table before).
Definition at line 180 of file inode.c.
References minix::bcache, bcache_remove(), minix::bs, kfree(), kmalloc(), M_ZERO, minix_block_alloc(), minix_block_write(), and table_alloc().
Returns how many data zones are under one pointer of an indirect zone that is depth levels above them.
Definition at line 125 of file inode.c.
References minix::bs, and zone_span().
Referenced by free_tree(), minix_inode_block_read(), minix_inode_block_write(), and zone_span().
Finds where zone idx of a file is in its tree: the slot of zones[] it hangs from (0 to 6 for the direct zones, 7 for the singly indirect one, 8 for the doubly indirect one) in *slot, and its index under that slot in *rel.
Returns the depth: 0 if the slot is the zone itself, 1 or 2 for the levels of indirect zones above it, or -EFBIG past the largest file.
Definition at line 94 of file inode.c.
References minix::bs, MINIX_DIRECT_ZONES, and zone_tree().
Referenced by minix_inode_block_read(), minix_inode_block_write(), and zone_tree().