MentOS
0.8.0
The Mentoring Operating System
|
Headers for Virtual File System (VFS). More...
Go to the source code of this file.
Macros | |
#define | MAX_OPEN_FD 16 |
Maximum number of opened file. | |
Functions | |
void | vfs_init (void) |
Initialize the Virtual File System (VFS). This function sets up necessary resources and structures for the VFS. It must be called before any other VFS functions. | |
int | vfs_register_filesystem (file_system_type *fs) |
Register a new filesystem. More... | |
int | vfs_unregister_filesystem (file_system_type *fs) |
Unregister a new filesystem. More... | |
int | vfs_register_superblock (const char *name, const char *path, file_system_type *type, vfs_file_t *root) |
Register a superblock for the filesystem. More... | |
int | vfs_unregister_superblock (super_block_t *sb) |
Unregister a superblock. More... | |
super_block_t * | vfs_get_superblock (const char *absolute_path) |
Searches for the mountpoint of the given path. More... | |
vfs_file_t * | vfs_open_abspath (const char *absolute_path, int flags, mode_t mode) |
Open a file given its absolute path. More... | |
vfs_file_t * | vfs_open (const char *path, int flags, mode_t mode) |
Given a pathname for a file, vfs_open() returns a file struct, used to access the file. More... | |
int | vfs_close (vfs_file_t *file) |
Decreases the number of references to a given file, if the references number reaches 0, close the file. More... | |
ssize_t | vfs_read (vfs_file_t *file, void *buf, size_t offset, size_t nbytes) |
Read data from a file. More... | |
ssize_t | vfs_write (vfs_file_t *file, const void *buf, size_t offset, size_t nbytes) |
Write data to a file. More... | |
off_t | vfs_lseek (vfs_file_t *file, off_t offset, int whence) |
Repositions the file offset inside a file. More... | |
ssize_t | vfs_getdents (vfs_file_t *file, dirent_t *dirp, off_t off, size_t count) |
int | vfs_ioctl (vfs_file_t *file, int request, void *data) |
Perform the I/O control operation specified by REQUEST on FD. One argument may follow; its presence and type depend on REQUEST. More... | |
int | vfs_unlink (const char *path) |
Delete a name and possibly the file it refers to. More... | |
int | vfs_mkdir (const char *path, mode_t mode) |
Creates a new directory at the given path. More... | |
int | vfs_rmdir (const char *path) |
Removes the given directory. More... | |
vfs_file_t * | vfs_creat (const char *path, mode_t mode) |
Creates a new file or rewrite an existing one. More... | |
ssize_t | vfs_readlink (const char *path, char *buffer, size_t bufsize) |
Read the symbolic link, if present. More... | |
int | vfs_symlink (const char *linkname, const char *path) |
Creates a symbolic link. More... | |
int | vfs_stat (const char *path, stat_t *buf) |
Stat the file at the given path. More... | |
int | vfs_fstat (vfs_file_t *file, stat_t *buf) |
Stat the given file. More... | |
int | vfs_mount (const char *type, const char *path, const char *args) |
Mount the path as a filesystem of the given type. More... | |
void | vfs_lock (vfs_file_t *file) |
Locks the access to the given file. More... | |
int | vfs_extend_task_fd_list (struct task_struct *task) |
Extends the file descriptor list for the given task. More... | |
int | vfs_init_task (struct task_struct *task) |
Initialize the file descriptor list for the given task. More... | |
int | vfs_dup_task (struct task_struct *new_task, struct task_struct *old_task) |
Duplicate the file descriptor list of old_task into new_task. More... | |
int | vfs_destroy_task (struct task_struct *task) |
Destroy the file descriptor list for the given task. More... | |
int | get_unused_fd (void) |
Find the smallest available fd. More... | |
int | sys_dup (int fd) |
Return new smallest available file desriptor. More... | |
int | vfs_valid_open_permissions (int flags, mode_t mask, uid_t uid, gid_t gid) |
Check if the requested open flags against the file mask. More... | |
int | vfs_valid_exec_permission (struct task_struct *task, vfs_file_t *file) |
Check if the file is exectuable. More... | |
Variables | |
kmem_cache_t * | vfs_file_cache |
Cache for file structures in the VFS. More... | |
Headers for Virtual File System (VFS).
int get_unused_fd | ( | void | ) |
Find the smallest available fd.
int sys_dup | ( | int | fd | ) |
Return new smallest available file desriptor.
fd | the descriptor of the file we want to duplicate. |
int vfs_close | ( | vfs_file_t * | file | ) |
Decreases the number of references to a given file, if the references number reaches 0, close the file.
file | A pointer to the file structure. |
vfs_file_t* vfs_creat | ( | const char * | path, |
mode_t | mode | ||
) |
Creates a new file or rewrite an existing one.
path | path to the file. |
mode | mode for file creation. |
It is equivalent to: open(path, O_WRONLY|O_CREAT|O_TRUNC, mode)
int vfs_destroy_task | ( | struct task_struct * | task | ) |
Destroy the file descriptor list for the given task.
task | The task for which we destroy the file descriptor list. |
int vfs_dup_task | ( | struct task_struct * | new_task, |
struct task_struct * | old_task | ||
) |
Duplicate the file descriptor list of old_task into new_task.
new_task | The task where we clone the file descriptor list. |
old_task | The task from which we clone the file descriptor list. |
int vfs_extend_task_fd_list | ( | struct task_struct * | task | ) |
Extends the file descriptor list for the given task.
task | The task for which we extend the file descriptor list. |
int vfs_fstat | ( | vfs_file_t * | file, |
stat_t * | buf | ||
) |
Stat the given file.
file | Pointer to the file for which we are retrieving the statistics. |
buf | Buffer where we are storing the statistics. |
super_block_t* vfs_get_superblock | ( | const char * | absolute_path | ) |
Searches for the mountpoint of the given path.
absolute_path | Path for which we want to search the mountpoint. |
ssize_t vfs_getdents | ( | vfs_file_t * | file, |
dirent_t * | dirp, | ||
off_t | off, | ||
size_t | count | ||
) |
Provide access to the directory entries.
file | The directory for which we accessing the entries. |
dirp | The buffer where de data should be placed. |
off | The offset from which we start reading the entries. |
count | The size of the buffer. |
int vfs_init_task | ( | struct task_struct * | task | ) |
Initialize the file descriptor list for the given task.
task | The task for which we initialize the file descriptor list. |
int vfs_ioctl | ( | vfs_file_t * | file, |
int | request, | ||
void * | data | ||
) |
Perform the I/O control operation specified by REQUEST on FD. One argument may follow; its presence and type depend on REQUEST.
file | The file for which we are executing the operations. |
request | The device-dependent request code |
data | An untyped pointer to memory. |
void vfs_lock | ( | vfs_file_t * | file | ) |
Locks the access to the given file.
file | The file to lock. |
off_t vfs_lseek | ( | vfs_file_t * | file, |
off_t | offset, | ||
int | whence | ||
) |
Repositions the file offset inside a file.
file | The file for which we reposition the offest. |
offset | The offest to use for the operation. |
whence | The type of operation. |
int vfs_mkdir | ( | const char * | path, |
mode_t | mode | ||
) |
Creates a new directory at the given path.
path | The path of the new directory. |
mode | The permission of the new directory. |
int vfs_mount | ( | const char * | type, |
const char * | path, | ||
const char * | args | ||
) |
Mount the path as a filesystem of the given type.
type | The type of filesystem |
path | The path to where it should be mounter. |
args | The arguments passed to the filesystem mount callback. |
vfs_file_t* vfs_open | ( | const char * | path, |
int | flags, | ||
mode_t | mode | ||
) |
Given a pathname for a file, vfs_open() returns a file struct, used to access the file.
path | A pathname for a file. |
flags | Used to set the file status flags and file access modes of the open file description. |
mode | Specifies the file mode bits be applied when a new file is created. |
vfs_file_t* vfs_open_abspath | ( | const char * | absolute_path, |
int | flags, | ||
mode_t | mode | ||
) |
Open a file given its absolute path.
absolute_path | An absolute path to the file. |
flags | Used to set the file status flags and access modes. |
mode | Specifies the file mode bits to apply when creating a new file. |
ssize_t vfs_read | ( | vfs_file_t * | file, |
void * | buf, | ||
size_t | offset, | ||
size_t | nbytes | ||
) |
Read data from a file.
file | The file structure used to reference a file. |
buf | The buffer. |
offset | The offset from which the function starts to read. |
nbytes | The number of bytes to read. |
Read the symbolic link, if present.
path | the path to the symbolic link. |
buffer | the buffer where we will store the symbolic link path. |
bufsize | the size of the buffer. |
int vfs_register_filesystem | ( | file_system_type * | fs | ) |
Register a new filesystem.
fs | A pointer to the information concerning the new filesystem. |
int vfs_register_superblock | ( | const char * | name, |
const char * | path, | ||
file_system_type * | type, | ||
vfs_file_t * | root | ||
) |
Register a superblock for the filesystem.
name | The name of the superblock. |
path | The path associated with the superblock. |
type | A pointer to the filesystem type. |
root | A pointer to the root file of the filesystem. |
int vfs_rmdir | ( | const char * | path | ) |
Removes the given directory.
path | The path to the directory to remove. |
int vfs_stat | ( | const char * | path, |
stat_t * | buf | ||
) |
Stat the file at the given path.
path | Path to the file for which we are retrieving the statistics. |
buf | Buffer where we are storing the statistics. |
int vfs_symlink | ( | const char * | linkname, |
const char * | path | ||
) |
Creates a symbolic link.
linkname | the name of the link. |
path | the entity it is linking to. |
int vfs_unlink | ( | const char * | path | ) |
Delete a name and possibly the file it refers to.
path | The path to the file. |
int vfs_unregister_filesystem | ( | file_system_type * | fs | ) |
Unregister a new filesystem.
fs | A pointer to the information concerning the filesystem. |
int vfs_unregister_superblock | ( | super_block_t * | sb | ) |
Unregister a superblock.
sb | A pointer to the superblock to unregister. |
int vfs_valid_exec_permission | ( | struct task_struct * | task, |
vfs_file_t * | file | ||
) |
Check if the file is exectuable.
task | The task to execute the file. |
file | The file to execute. |
Check if the requested open flags against the file mask.
flags | The requested open flags. |
mask | The permissions of the file. |
uid | The owner of the task opening the file. |
gid | The group of the task opening the file. |
ssize_t vfs_write | ( | vfs_file_t * | file, |
const void * | buf, | ||
size_t | offset, | ||
size_t | nbytes | ||
) |
Write data to a file.
file | The file structure used to reference a file. |
buf | The buffer. |
offset | The offset from which the function starts to write. |
nbytes | The number of bytes to write. |
|
extern |
Cache for file structures in the VFS.
Cache for file structures in the VFS.