|
AquilaOS documentation
How it works, and its code
|
Go to the source code of this file.
Data Structures | |
| struct | ext2_superblock |
| The superblock, as it is on the disk, 1024 bytes into it. More... | |
| struct | ext2_group |
| A block group descriptor, as it is on the disk. More... | |
| struct | ext2_inode |
| An inode, as it is on the disk. More... | |
| struct | ext2_dentry |
| A directory entry, as it is on the disk. More... | |
| struct | ext2 |
| A mounted ext2 filesystem. More... | |
Macros | |
| #define | EXT2_SIGNATURE 0xEF53 |
| #define | EXT2_INCOMPAT_FILETYPE 0x0002 |
| #define | EXT2_RO_COMPAT_SPARSE_SUPER 0x0001 |
| #define | EXT2_RO_COMPAT_LARGE_FILE 0x0002 |
| #define | EXT2_INCOMPAT_SUPPORTED EXT2_INCOMPAT_FILETYPE |
| #define | EXT2_RO_COMPAT_SUPPORTED (EXT2_RO_COMPAT_SPARSE_SUPER | EXT2_RO_COMPAT_LARGE_FILE) |
| #define | EXT2_GOOD_OLD_INODE_SIZE 128 |
| #define | EXT2_DENTRY_TYPE_BAD 0 |
| #define | EXT2_DENTRY_TYPE_RGL 1 |
| #define | EXT2_DENTRY_TYPE_DIR 2 |
| #define | EXT2_DENTRY_TYPE_CHR 3 |
| #define | EXT2_DENTRY_TYPE_BLK 4 |
| #define | EXT2_DENTRY_TYPE_FIFO 5 |
| #define | EXT2_DENTRY_TYPE_SCKT 6 |
| #define | EXT2_DENTRY_TYPE_SLINK 7 |
| #define | EXT2_DIRECT_POINTERS 12 |
Functions | |
| int | ext2_superblock_rewrite (struct ext2 *desc) |
| Writes the in-memory copy of the superblock back to the disk, after a change to its counts of free blocks and inodes. | |
| int | ext2_io (struct ext2 *desc, int write, off_t off, size_t size, void *buf) |
| Reads or writes bytes of the filesystem's disk, all of them. | |
| int | ext2_bgd_table_rewrite (struct ext2 *desc) |
| Writes the block group descriptor table back to the disk, after a change to a group's counts. | |
| int | ext2_block_read (struct ext2 *desc, uint32_t number, void *buf) |
| Reads a block from the disk. | |
| int | ext2_block_write (struct ext2 *desc, uint32_t number, void *buf) |
| Writes a block to the disk. | |
| int | ext2_block_alloc (struct ext2 *desc, uint32_t *block) |
| Allocates a free block: its bit is set in its group's block bitmap, the free counts go down, and the block is zeroed. | |
| int | ext2_block_free (struct ext2 *desc, uint32_t block) |
| Frees a block: its bit is cleared in its group's block bitmap, and the free counts go up. | |
| int | ext2_inode_read (struct ext2 *desc, ino_t inode, struct ext2_inode *ref) |
| Reads an inode from the disk. | |
| int | ext2_inode_write (struct ext2 *desc, ino_t inode, struct ext2_inode *i) |
| Writes an inode to the disk. | |
| int | ext2_inode_block_read (struct ext2 *desc, struct ext2_inode *inode, size_t idx, void *buf) |
| Reads a block of a file. | |
| int | ext2_inode_block_write (struct ext2 *desc, struct ext2_inode *inode, uint32_t inode_nr, size_t idx, void *buf) |
| Writes a block of a file, allocating it and the indirect blocks above it if they don't exist yet. | |
| int | ext2_inode_alloc (struct ext2 *desc, ino_t *ino) |
| Allocates a free inode: its bit is set in its group's inode bitmap, and the free counts go down. | |
| int | ext2_dentry_find (struct ext2 *desc, struct ext2_inode *inode, const char *name, ino_t *ino) |
| Finds the inode number of a name in a directory. | |
| int | ext2_dentry_create (struct vnode *dir, const char *name, ino_t ino, mode_t mode) |
| Adds an entry to a directory. | |
| ssize_t | ext2_read (struct vnode *node, off_t offset, struct iobuf *io) |
| Reads from a file. | |
| ssize_t | ext2_write (struct vnode *node, off_t offset, struct iobuf *io) |
| Writes to a file, which grows if the write goes past its end. | |
| ssize_t | ext2_readdir (struct vnode *dir, off_t offset, struct dirent *dirent) |
| Reads a directory's entry at an offset; unused entries don't count. | |
| int | ext2_finddir (struct vnode *dir, const char *fn, struct dirent *dirent) |
| Finds the entry of a directory that has a name. | |
| int | ext2_trunc (struct vnode *inode, off_t len) |
| Changes a file's length. | |
| int | ext2_vmknod (struct vnode *dir, const char *fn, mode_t mode, dev_t dev, struct uio *uio, struct vnode **ref) |
| Makes a node in a directory: a new inode, and an entry for it. | |
| int | ext2_vget (struct vnode *super, ino_t ino, struct vnode **ref) |
| Gets the vnode of an inode, by its number. | |
| int | ext2_setattr (struct vnode *vnode) |
| Stores a vnode's attributes (mode, owner, times) in its inode. | |
| int | ext2_close (struct vnode *vnode) |
| Releases a vnode when its last reference goes. | |
| int | ext2_vunlink (struct vnode *dir, const char *fn, struct uio *uio) |
| Removes an entry from a directory, and drops a link to its file. | |
| int | ext2_vlink (struct vnode *dir, const char *fn, struct vnode *vnode, struct uio *uio) |
| Adds an entry for an existing file (a hard link) to a directory. | |
| int | ext2_vrename (struct vnode *odir, const char *ofn, struct vnode *ndir, const char *nfn, struct uio *uio) |
| Renames an entry, possibly to another directory, replacing an entry at the new name (the VFS checked its type already). | |
| void | ext2_blocks_free (struct ext2 *desc, struct ext2_inode *inode, size_t from) |
| Frees a file's blocks, from a block on, when the file is truncated or removed. | |
| void | ext2_inode_discard (struct ext2 *desc, ino_t ino) |
| Frees an inode that has no links left, and the blocks it uses. | |
| int | ext2_inode_build (struct ext2 *desc, ino_t ino, struct vnode **ref_inode) |
| Gets the vnode of an inode: the cached one if it's in use, or a new one made from the inode on the disk. | |
| int | ext2_inode_sync (struct vnode *inode) |
| Writes a vnode's attributes back to its inode on the disk. | |
Variables | |
| struct fs | ext2fs |
| #define EXT2_DENTRY_TYPE_BAD 0 |
Definition at line 156 of file ext2.h.
Referenced by ext2_dentry_type().
| #define EXT2_DENTRY_TYPE_BLK 4 |
Definition at line 160 of file ext2.h.
Referenced by ext2_dentry_type().
| #define EXT2_DENTRY_TYPE_CHR 3 |
Definition at line 159 of file ext2.h.
Referenced by ext2_dentry_type().
| #define EXT2_DENTRY_TYPE_DIR 2 |
Definition at line 158 of file ext2.h.
Referenced by ext2_dentry_type(), and ext2_vmknod().
| #define EXT2_DENTRY_TYPE_FIFO 5 |
Definition at line 161 of file ext2.h.
Referenced by ext2_dentry_type().
| #define EXT2_DENTRY_TYPE_RGL 1 |
Definition at line 157 of file ext2.h.
Referenced by ext2_dentry_type().
| #define EXT2_DENTRY_TYPE_SCKT 6 |
Definition at line 162 of file ext2.h.
Referenced by ext2_dentry_type().
| #define EXT2_DENTRY_TYPE_SLINK 7 |
Definition at line 163 of file ext2.h.
Referenced by ext2_dentry_type().
| #define EXT2_DIRECT_POINTERS 12 |
Definition at line 165 of file ext2.h.
Referenced by block_tree(), and ext2_blocks_free().
| #define EXT2_GOOD_OLD_INODE_SIZE 128 |
Definition at line 31 of file ext2.h.
Referenced by ext2_load().
| #define EXT2_INCOMPAT_FILETYPE 0x0002 |
Definition at line 21 of file ext2.h.
Referenced by ext2_load().
| #define EXT2_INCOMPAT_SUPPORTED EXT2_INCOMPAT_FILETYPE |
Definition at line 26 of file ext2.h.
Referenced by ext2_load().
| #define EXT2_RO_COMPAT_SUPPORTED (EXT2_RO_COMPAT_SPARSE_SUPER | EXT2_RO_COMPAT_LARGE_FILE) |
Definition at line 27 of file ext2.h.
Referenced by ext2_load().
| #define EXT2_SIGNATURE 0xEF53 |
Definition at line 16 of file ext2.h.
Referenced by ext2_load().
| int ext2_bgd_table_rewrite | ( | struct ext2 * | desc | ) |
Writes the block group descriptor table back to the disk, after a change to a group's counts.
| desc | the mounted filesystem |
Definition at line 34 of file block.c.
References ext2::bs, ext2_bgd_table_rewrite(), ext2_io(), ext2::groups, and ext2::ngroups.
Referenced by ext2_bgd_table_rewrite(), ext2_block_alloc(), ext2_block_free(), ext2_inode_alloc(), ext2_inode_free(), and ext2_vmknod().
Allocates a free block: its bit is set in its group's block bitmap, the free counts go down, and the block is zeroed.
A bitmap that couldn't be read isn't written back.
| desc | the mounted filesystem |
| block | set to the block's number |
Definition at line 77 of file block.c.
References ext2_group::bmap, ext2::bs, ext2_superblock::dblock, ext2_bgd_table_rewrite(), ext2_block_alloc(), ext2_block_read(), ext2_block_write(), ext2_superblock_rewrite(), ext2_group::free_blocks, ext2_superblock::free_blocks, ext2_superblock::gblocks, ext2::groups, kfree(), kmalloc(), bitmap::map, bitmap::max_idx, memset(), ext2::ngroups, and ext2::superblock.
Referenced by ext2_block_alloc(), and ext2_inode_block_alloc().
Frees a block: its bit is cleared in its group's block bitmap, and the free counts go up.
If the bitmap can't be read, the block stays used.
| desc | the mounted filesystem |
| block | the block's number |
Definition at line 145 of file block.c.
References ext2_group::bmap, ext2::bs, ext2_superblock::dblock, ext2_bgd_table_rewrite(), ext2_block_free(), ext2_block_read(), ext2_block_write(), ext2_superblock_rewrite(), ext2_group::free_blocks, ext2_superblock::free_blocks, ext2_superblock::gblocks, ext2::groups, kfree(), kmalloc(), bitmap::map, ext2_superblock::nblocks, and ext2::superblock.
Referenced by ext2_block_free(), and free_tree().
Reads a block from the disk.
| desc | the mounted filesystem |
| number | the block number |
| buf | where it goes, a block's size |
Definition at line 49 of file block.c.
References ext2::bs, ext2_block_read(), and ext2_io().
Referenced by ext2_block_alloc(), ext2_block_free(), ext2_block_read(), ext2_indirect_block_get(), ext2_inode_alloc(), ext2_inode_block_read(), ext2_inode_free(), and free_tree().
Writes a block to the disk.
| desc | the mounted filesystem |
| number | the block number |
| buf | the block's new contents |
Definition at line 62 of file block.c.
References ext2::bs, ext2_block_write(), and ext2_io().
Referenced by ext2_block_alloc(), ext2_block_free(), ext2_block_write(), ext2_indirect_block_get(), ext2_inode_alloc(), ext2_inode_block_write(), ext2_inode_free(), and free_tree().
| void ext2_blocks_free | ( | struct ext2 * | desc, |
| struct ext2_inode * | inode, | ||
| size_t | from ) |
Frees a file's blocks, from a block on, when the file is truncated or removed.
| desc | the mounted filesystem |
| inode | the file's inode, its block pointers cleared here |
| from | the index of the first block to free |
Definition at line 69 of file remove.c.
References ext2_inode::blocks, ext2::bs, ext2_inode::direct_pointer, ext2_inode::doubly_indirect_pointer, ext2_blocks_free(), EXT2_DIRECT_POINTERS, free_tree(), ext2_inode::mode, ext2_inode::singly_indirect_pointer, and ext2_inode::triply_indirect_pointer.
Referenced by ext2_blocks_free(), ext2_inode_discard(), and ext2_trunc().
| int ext2_close | ( | struct vnode * | vnode | ) |
Releases a vnode when its last reference goes.
A file that was unlinked while it was open is freed now, with its inode and blocks.
| vnode | the vnode |
Definition at line 158 of file remove.c.
References ext2_close(), ext2_inode_discard(), vnode::ino, kfree(), vnode::nlink, vnode::p, ext2::vcache, vcache_remove(), and vnode_pages_free().
Referenced by ext2_close().
Adds an entry to a directory.
It takes an unused entry big enough, or splits an entry that has room after its name, or else gets a new block at the end of the directory.
| dir | the directory |
| name | the new entry's name |
| ino | its inode number |
| mode | its file's mode (for the entry's type) |
Definition at line 87 of file dentry.c.
References ext2::bs, ext2_dentry_create(), ext2_dentry_type(), ext2_inode_block_read(), ext2_inode_block_write(), ext2_inode_read(), ext2_inode_write(), ext2::filetype, ext2_dentry::ino, vnode::ino, kfree(), kmalloc(), ext2_dentry::length, memcpy(), memset(), vnode::mode, ext2_dentry::name, NULL, vnode::p, ext2_dentry::size, ext2_inode::size, vnode::size, and ext2_dentry::type.
Referenced by ext2_dentry_create(), ext2_vlink(), ext2_vmknod(), and ext2_vrename().
| int ext2_dentry_find | ( | struct ext2 * | desc, |
| struct ext2_inode * | inode, | ||
| const char * | name, | ||
| ino_t * | ino ) |
Finds the inode number of a name in a directory.
| desc | the mounted filesystem |
| inode | the directory's inode |
| name | the name |
| ino | set to the inode number |
Definition at line 20 of file dentry.c.
References ext2::bs, ext2_dentry_find(), ext2_inode_block_read(), ext2_dentry::ino, kfree(), kmalloc(), ext2_dentry::length, memcmp(), ext2_inode::mode, ext2_dentry::name, ext2_dentry::size, and ext2_inode::size.
Referenced by ext2_dentry_find(), ext2_finddir(), ext2_vlink(), ext2_vmknod(), and ext2_vrename().
| int ext2_finddir | ( | struct vnode * | dir, |
| const char * | fn, | ||
| struct dirent * | dirent ) |
Finds the entry of a directory that has a name.
Only the entry's inode number is filled in.
| dir | the directory |
| fn | the name |
| dirent | if not NULL, the entry |
Definition at line 414 of file vops.c.
References ext2_dentry_find(), ext2_finddir(), ext2_inode_read(), vnode::ino, and vnode::p.
Referenced by ext2_finddir().
Allocates a free inode: its bit is set in its group's inode bitmap, and the free counts go down.
A bitmap that couldn't be read isn't written back.
| desc | the mounted filesystem |
| ino | set to the inode number |
Definition at line 281 of file inode.c.
References ext2::bs, ext2_bgd_table_rewrite(), ext2_block_read(), ext2_block_write(), ext2_inode_alloc(), ext2_superblock_rewrite(), ext2_group::free_inodes, ext2_superblock::free_inodes, ext2_superblock::ginodes, ext2::groups, ext2_group::imap, kfree(), kmalloc(), LOG_DEBUG, bitmap::map, bitmap::max_idx, ext2::ngroups, and ext2::superblock.
Referenced by ext2_inode_alloc(), and ext2_vmknod().
| int ext2_inode_block_read | ( | struct ext2 * | desc, |
| struct ext2_inode * | inode, | ||
| size_t | idx, | ||
| void * | buf ) |
Reads a block of a file.
A block that was never written (the file is sparse there) reads as zeros.
| desc | the mounted filesystem |
| inode | the file's inode |
| idx | the block's index in the file |
| buf | where it goes, a block's size |
Definition at line 144 of file inode.c.
References block_tree(), ext2::bs, ext2_block_read(), ext2_inode_block_read(), kfree(), kmalloc(), memset(), slot_get(), table(), and tree_span().
Referenced by dentry_update(), ext2_dentry_create(), ext2_dentry_find(), ext2_inode_block_read(), ext2_read(), ext2_readdir(), ext2_trunc(), and ext2_write().
| int ext2_inode_block_write | ( | struct ext2 * | desc, |
| struct ext2_inode * | inode, | ||
| uint32_t | inode_nr, | ||
| size_t | idx, | ||
| void * | buf ) |
Writes a block of a file, allocating it and the indirect blocks above it if they don't exist yet.
The inode is written back if blocks were allocated.
| desc | the mounted filesystem |
| inode | the file's inode |
| inode_nr | its inode number |
| idx | the block's index in the file |
| buf | the block's new contents |
Definition at line 235 of file inode.c.
References block_tree(), ext2_inode::blocks, ext2_block_write(), ext2_indirect_block_get(), ext2_inode_block_alloc(), ext2_inode_block_write(), ext2_inode_write(), slot_get(), slot_set(), and tree_span().
Referenced by dentry_update(), ext2_dentry_create(), ext2_inode_block_write(), ext2_trunc(), ext2_vmknod(), and ext2_write().
Gets the vnode of an inode: the cached one if it's in use, or a new one made from the inode on the disk.
| desc | the mounted filesystem |
| ino | the inode number |
| ref_inode | if not NULL, set to the vnode |
Definition at line 29 of file ext2.c.
References ext2_inode::atime, vnode::atime, ext2_inode::ctime, vnode::ctime, DEV, ext2_inode::direct_pointer, ext2_inode_build(), ext2_inode_read(), ext2fs, vnode::fs, ext2_inode::gid, vnode::gid, vnode::ino, kmalloc(), LOG_DEBUG, M_ZERO, ext2_inode::mode, vnode::mode, ext2_inode::mtime, vnode::mtime, ext2_inode::nlink, vnode::nlink, NULL, vnode::p, vnode::rdev, ext2_inode::size, vnode::size, timespec::tv_nsec, timespec::tv_sec, ext2_inode::uid, vnode::uid, ext2::vcache, vcache_find(), and vcache_insert().
Referenced by ext2_inode_build(), ext2_load(), ext2_vget(), ext2_vmknod(), ext2_vrename(), and ext2_vunlink().
Frees an inode that has no links left, and the blocks it uses.
| desc | the mounted filesystem |
| ino | the inode number |
Definition at line 131 of file remove.c.
References ext2_inode::dtime, ext2_blocks_free(), ext2_inode_discard(), ext2_inode_free(), ext2_inode_read(), ext2_inode_write(), gettime(), ext2_inode::mode, ext2_inode::nlink, ext2_inode::size, and timespec::tv_sec.
Referenced by ext2_close(), ext2_inode_discard(), and ext2_vmknod().
| int ext2_inode_read | ( | struct ext2 * | desc, |
| ino_t | ino, | ||
| struct ext2_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 33 of file inode.c.
References ext2_inode_off(), ext2_inode_read(), and ext2_io().
Referenced by dentry_update(), ext2_dentry_create(), ext2_finddir(), ext2_inode_build(), ext2_inode_discard(), ext2_inode_read(), ext2_inode_sync(), ext2_read(), ext2_readdir(), ext2_setattr(), ext2_trunc(), ext2_vlink(), ext2_vmknod(), ext2_vrename(), and ext2_write().
| int ext2_inode_sync | ( | struct vnode * | inode | ) |
Writes a vnode's attributes back to its inode on the disk.
| inode | the vnode |
Definition at line 93 of file ext2.c.
References ext2_inode::atime, vnode::atime, ext2_inode::ctime, vnode::ctime, ext2_inode_read(), ext2_inode_sync(), ext2_inode_write(), ext2_inode::gid, vnode::gid, vnode::ino, LOG_DEBUG, ext2_inode::mode, vnode::mode, ext2_inode::mtime, vnode::mtime, ext2_inode::nlink, vnode::nlink, vnode::p, ext2_inode::size, vnode::size, timespec::tv_sec, ext2_inode::uid, and vnode::uid.
Referenced by ext2_inode_sync(), ext2_trunc(), ext2_vlink(), ext2_vmknod(), ext2_vrename(), and ext2_vunlink().
| int ext2_inode_write | ( | struct ext2 * | desc, |
| ino_t | ino, | ||
| struct ext2_inode * | ext2_inode ) |
Writes an inode to the disk.
| desc | the mounted filesystem |
| ino | the inode number |
| ext2_inode | the inode |
Definition at line 51 of file inode.c.
References ext2_inode_off(), ext2_inode_write(), and ext2_io().
Referenced by ext2_dentry_create(), ext2_inode_block_write(), ext2_inode_discard(), ext2_inode_sync(), ext2_inode_write(), ext2_setattr(), ext2_trunc(), ext2_vmknod(), and ext2_write().
Reads or writes bytes of the filesystem's disk, all of them.
| desc | the mounted filesystem |
| write | whether to write (1) or read (0) |
| off | where on the disk, in bytes |
| size | how many bytes |
| buf | the data |
Definition at line 19 of file block.c.
References ext2_io(), ext2::supernode, vfs_read(), and vfs_write().
Referenced by ext2_bgd_table_rewrite(), ext2_block_read(), ext2_block_write(), ext2_inode_read(), ext2_inode_write(), ext2_io(), and ext2_superblock_rewrite().
Reads from a file.
| node | the file |
| offset | where to read from |
| io | where the data goes, and how much is wanted |
Definition at line 23 of file vops.c.
References ext2_inode::blocks, ext2::bs, ext2_inode::direct_pointer, ext2_inode_block_read(), ext2_inode_read(), ext2_read(), vnode::ino, iobuf_out(), kfree(), kmalloc(), MIN, ext2_inode::mode, vnode::p, iobuf::resid, and ext2_inode::size.
Referenced by ext2_read().
Reads a directory's entry at an offset; unused entries don't count.
| dir | the directory |
| offset | which entry |
| dirent | the entry, filled in |
Definition at line 174 of file vops.c.
References ext2::bs, ext2_inode_block_read(), ext2_inode_read(), ext2_readdir(), ext2_dentry::ino, vnode::ino, kfree(), kmalloc(), ext2_dentry::length, memcpy(), ext2_inode::mode, vnode::mode, ext2_dentry::name, vnode::p, ext2_dentry::size, and ext2_inode::size.
Referenced by ext2_readdir().
| int ext2_setattr | ( | struct vnode * | vnode | ) |
Stores a vnode's attributes (mode, owner, times) in its inode.
| vnode | the vnode |
Definition at line 456 of file vops.c.
References ext2_inode::atime, vnode::atime, ext2_inode::ctime, vnode::ctime, ext2_inode_read(), ext2_inode_write(), ext2_setattr(), ext2_inode::gid, vnode::gid, vnode::ino, ext2_inode::mode, vnode::mode, ext2_inode::mtime, vnode::mtime, vnode::p, timespec::tv_sec, ext2_inode::uid, and vnode::uid.
Referenced by ext2_setattr().
| int ext2_superblock_rewrite | ( | struct ext2 * | desc | ) |
Writes the in-memory copy of the superblock back to the disk, after a change to its counts of free blocks and inodes.
| desc | the mounted filesystem |
Definition at line 14 of file super.c.
References ext2_io(), ext2_superblock_rewrite(), and ext2::superblock.
Referenced by ext2_block_alloc(), ext2_block_free(), ext2_inode_alloc(), ext2_inode_free(), and ext2_superblock_rewrite().
Changes a file's length.
A file that grows reads zeros past its old end; a file that shrinks frees its blocks past the new end.
| inode | the file |
| len | the new length, in bytes |
Definition at line 252 of file vops.c.
References ext2::bs, ext2_blocks_free(), ext2_inode_block_read(), ext2_inode_block_write(), ext2_inode_read(), ext2_inode_sync(), ext2_inode_write(), ext2_trunc(), vnode::ino, kfree(), kmalloc(), memset(), vnode::p, ext2_inode::size, and vnode::size.
Referenced by ext2_trunc(), and ext2_write().
Gets the vnode of an inode, by its number.
| super | any vnode of the filesystem |
| ino | the inode number |
| ref | if not NULL, set to the vnode |
Definition at line 443 of file vops.c.
References ext2_inode_build(), ext2_vget(), and vnode::p.
Referenced by ext2_vget().
Adds an entry for an existing file (a hard link) to a directory.
| dir | the directory |
| fn | the new name |
| vnode | the file |
| uio | who is asking |
Definition at line 298 of file remove.c.
References vnode::ctime, ext2_dentry_create(), ext2_dentry_find(), ext2_inode_read(), ext2_inode_sync(), ext2_vlink(), gettime(), vnode::ino, vnode::mode, vnode::nlink, and vnode::p.
Referenced by ext2_vlink().
| int ext2_vmknod | ( | struct vnode * | dir, |
| const char * | fn, | ||
| mode_t | mode, | ||
| dev_t | dev, | ||
| struct uio * | uio, | ||
| struct vnode ** | ref ) |
Makes a node in a directory: a new inode, and an entry for it.
A new directory gets a block with its . and .. entries.
| dir | the directory |
| fn | the new node's name |
| mode | its type (S_IF*) and permissions |
| dev | its device number, for a device node |
| uio | who is asking (the owner) |
| ref | if not NULL, set to the new vnode |
Definition at line 312 of file vops.c.
References ext2_inode::atime, ext2::bs, ext2_inode::ctime, DEV, DEV_MAJOR, DEV_MINOR, ext2_inode::direct_pointer, ext2_group::directories_count, ext2_bgd_table_rewrite(), ext2_dentry_create(), ext2_dentry_find(), EXT2_DENTRY_TYPE_DIR, ext2_inode_alloc(), ext2_inode_block_write(), ext2_inode_build(), ext2_inode_discard(), ext2_inode_read(), ext2_inode_sync(), ext2_inode_write(), ext2_vmknod(), ext2::filetype, gettime(), ext2_inode::gid, uio::gid, ext2_superblock::ginodes, ext2::groups, ext2_dentry::ino, vnode::ino, kfree(), kmalloc(), ext2_dentry::length, M_ZERO, memcpy(), memset(), ext2_inode::mode, ext2_inode::mtime, ext2_dentry::name, ext2_inode::nlink, vnode::nlink, vnode::p, ext2_dentry::size, ext2_inode::size, ext2::superblock, timespec::tv_sec, ext2_dentry::type, ext2_inode::uid, and uio::uid.
Referenced by ext2_vmknod().
| int ext2_vrename | ( | struct vnode * | odir, |
| const char * | ofn, | ||
| struct vnode * | ndir, | ||
| const char * | nfn, | ||
| struct uio * | uio ) |
Renames an entry, possibly to another directory, replacing an entry at the new name (the VFS checked its type already).
A directory that moves gets its .. pointed to its new parent.
| odir | the directory the entry is in |
| ofn | its name |
| ndir | the directory it goes to |
| nfn | its new name |
| uio | who is asking |
Definition at line 337 of file remove.c.
References vnode::ctime, dentry_remove(), dentry_set_ino(), dentry_update(), ext2_dentry_create(), ext2_dentry_find(), ext2_inode_build(), ext2_inode_read(), ext2_inode_sync(), ext2_vrename(), ext2_vunlink(), gettime(), vnode::ino, vnode::mode, vnode::mtime, vnode::nlink, NULL, and vnode::p.
Referenced by ext2_vrename().
Removes an entry from a directory, and drops a link to its file.
The file is freed when it has no links and nothing has it open.
| dir | the directory |
| fn | the entry's name |
| uio | who is asking |
Definition at line 249 of file remove.c.
References vnode::ctime, dentry_remove(), dentry_update(), ext2_inode_build(), ext2_inode_sync(), ext2_vunlink(), gettime(), vnode::mode, vnode::mtime, vnode::nlink, NULL, vnode::p, vnode::ref, and vfs_close().
Referenced by ext2_vrename(), and ext2_vunlink().
Writes to a file, which grows if the write goes past its end.
A short symbolic link keeps its target in the inode itself.
| node | the file |
| offset | where to write |
| io | the data, and how much of it |
Definition at line 83 of file vops.c.
References ext2_inode::blocks, ext2::bs, ext2_inode::direct_pointer, ext2_inode_block_read(), ext2_inode_block_write(), ext2_inode_read(), ext2_inode_write(), ext2_trunc(), ext2_write(), vnode::ino, iobuf_in(), kfree(), kmalloc(), LOG_DEBUG, MAX, MIN, vnode::mode, vnode::p, iobuf::resid, ext2_inode::size, and vnode::size.
Referenced by ext2_write().
|
extern |
Definition at line 282 of file ext2.c.
Referenced by ext2_init(), ext2_inode_build(), and ext2_mount().