|
AquilaOS documentation
How it works, and its code
|
ext2: the vnode operations: reading and writing files, directories, making nodes, truncating, and attributes. More...
Go to the source code of this file.
Functions | |
| 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_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_finddir (struct vnode *dir, const char *fn, struct dirent *dirent) |
| Finds the entry of a directory that has a name. | |
| 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. | |
ext2: the vnode operations: reading and writing files, directories, making nodes, truncating, and attributes.
Removing, linking and renaming are in remove.c.
A file's data moves one block at a time through a kernel buffer: the block's piece of the iobuf is copied into or out of it.
Definition in file vops.c.
| 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().
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().
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().
| 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().
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().