|
ginnOS
The reference: libc, the libraries and the kernel
|
Go to the source code of this file.
Data Structures | |
| struct | vfs_file_t |
| virtual file system file handle structure representing an open file or directory. More... | |
Macros | |
| #define | VFS_PATH_MAX 256 |
| #define | VFS_SEEK_SET 0 |
| #define | VFS_SEEK_CUR 1 |
| #define | VFS_SEEK_END 2 |
Typedefs | |
| typedef fs_stat_t | vfs_stat_t |
Functions | |
| kerr_t | vfs_mount_root (fs_mount_t *mount) |
| mount a filesystem as the root filesystem. | |
| kerr_t | vfs_mount (const char *prefix, fs_mount_t *mount) |
| mount a filesystem at a path prefix. | |
| bool | vfs_mount_at (uint32_t index, char *prefix_out, uint32_t prefix_size, fs_mount_t **mount_out) |
| a mounted filesystem, by its place in the mount table (for /proc/mounts). | |
| kerr_t | vfs_umount (const char *prefix) |
| unmount the filesystem at an exact path prefix. | |
| fs_mount_t * | vfs_resolve_mount_path (const char *path, const char **rel_out) |
| find the mounted filesystem responsible for an absolute path, and the sub-path relative to that mount's prefix. | |
| kerr_t | vfs_follow (char *path, uint32_t size, bool follow_last, const char *root) |
| replace the symbolic links along a canonical absolute path by their targets (vfs_link.c). | |
| const char * | vfs_inside_root (const char *path, const char *root) |
| a real path as a process with this root directory sees it. | |
| bool | vfs_join_root (const char *root, const char *virtual_path, char *out, uint32_t size) |
| the real path of a path as a process with this root sees it. | |
| kerr_t | vfs_readlink (const char *path, char *target, uint32_t size) |
| read the target of the symbolic link at path, with a NUL. | |
| kerr_t | vfs_symlink (const char *path, const char *target) |
| make a symbolic link at path to target. | |
| kerr_t | vfs_link (const char *old_path, const char *new_path) |
| give a file one more name (both paths on one mount, else KERR_INVAL). | |
| kerr_t | vfs_mknod (const char *path, uint32_t mode, uint32_t rdev) |
| make a named pipe or a device node (fs_ops_t mknod). | |
| kerr_t | vfs_open (const char *path, vfs_file_t *file) |
| open a file or directory by absolute path in the virtual file system. | |
| kerr_t | vfs_create (const char *path) |
| create a regular file by absolute path. | |
| kerr_t | vfs_mkdir (const char *path) |
| create a directory by absolute path. | |
| kerr_t | vfs_remove (const char *path) |
| remove a file by absolute path. | |
| kerr_t | vfs_rmdir (const char *path) |
| remove a directory by absolute path. | |
| kerr_t | vfs_rename (const char *old_path, const char *new_path) |
| rename a file or directory by absolute paths. | |
| kerr_t | vfs_stat (const char *path, vfs_stat_t *stat_out) |
| stat a file or directory by absolute path. | |
| bool | vfs_resolve_path (const char *cwd, const char *input, char *output, size_t size) |
| resolve an input path against the current working directory. | |
| bool | vfs_join_path (const char *base, const char *name, char *out, size_t size) |
| join two path components into an output buffer. | |
| uint32_t | vfs_read (vfs_file_t *file, uint32_t size, void *buffer) |
| read data from an open file in the virtual file system. | |
| uint32_t | vfs_write (vfs_file_t *file, uint32_t size, const void *buffer) |
| write data to an open file in the virtual file system. | |
| kerr_t | vfs_truncate (vfs_file_t *file, uint64_t length) |
| cut or grow an open file to length bytes (growth reads as zeros). | |
| kerr_t | vfs_read_entry (vfs_file_t *file, fs_dirent_t *entryOut) |
| read a directory entry from an open directory in the virtual file system. | |
| void | vfs_close (vfs_file_t *file) |
| close an open file in the virtual file system. | |
| uint8_t | vfs_file_type (vfs_file_t *file) |
| get the type of an open file in the virtual file system. | |
| int32_t | vfs_ioctl (vfs_file_t *file, uint32_t request, void *arg) |
| issue a device-control (ioctl) request on an open file. | |
| int32_t | vfs_mmap (vfs_file_t *file, addr_space_t as, uintptr_t virt, size_t length, int prot, uint64_t offset) |
| map an open file's memory into a process address space. | |
| int64_t | vfs_lseek (vfs_file_t *file, int64_t offset, int whence) |
| move an open file's offset, as lseek does: through the filesystem's own seek op if it has one (devfs), else the ext2 file cursor. | |
| void | vfs_seek_end (vfs_file_t *file) |
| move an open file's offset to its end (O_APPEND writes). | |
| kerr_t | vfs_fstat (vfs_file_t *file, vfs_stat_t *stat_out) |
| stat an open file or directory. | |
| kerr_t | vfs_setattr (const char *path, const fs_attr_t *attr) |
| change the permission bits and/or owner of a file by path, or of an open file. | |
| kerr_t | vfs_fsetattr (vfs_file_t *file, const fs_attr_t *attr) |
| #define VFS_PATH_MAX 256 |
| #define VFS_SEEK_SET 0 |
| #define VFS_SEEK_CUR 1 |
| #define VFS_SEEK_END 2 |
| typedef fs_stat_t vfs_stat_t |
| kerr_t vfs_mount_root | ( | fs_mount_t * | mount | ) |
mount a filesystem as the root filesystem.
convenience wrapper for vfs_mount("/", mount).
| mount | pointer to the filesystem mount structure to be used as the root filesystem. |
| kerr_t vfs_mount | ( | const char * | prefix, |
| fs_mount_t * | mount ) |
mount a filesystem at a path prefix.
a later, more specific prefix takes precedence over a shorter one during path resolution (e.g. "/dev" wins over "/"). remounting an existing prefix replaces its backing filesystem.
| prefix | absolute mount point, e.g. "/" or "/dev". |
| mount | the filesystem to mount there (must already be mounted). |
| bool vfs_mount_at | ( | uint32_t | index, |
| char * | prefix_out, | ||
| uint32_t | prefix_size, | ||
| fs_mount_t ** | mount_out ) |
a mounted filesystem, by its place in the mount table (for /proc/mounts).
| index | 0, 1, ... the entries in the order they were mounted. |
| prefix_out | gets the mount point. |
| mount_out | gets the filesystem. |
| kerr_t vfs_umount | ( | const char * | prefix | ) |
unmount the filesystem at an exact path prefix.
| prefix | the mount point to remove. |
| fs_mount_t * vfs_resolve_mount_path | ( | const char * | path, |
| const char ** | rel_out ) |
find the mounted filesystem responsible for an absolute path, and the sub-path relative to that mount's prefix.
the backing filesystem is handed a path relative to its own mount point, not the full absolute path: the root mount "/" sees the path unchanged (still leading '/'), while a sub-mount at "/dev" sees "/fb0" for "/dev/fb0" and "/" for "/dev" itself. the relative path always keeps a leading '/'.
| path | absolute path to resolve. |
| rel_out | if non-NULL, receives a pointer into path (or a static "/") for the mount-relative sub-path. only valid while path is. |
replace the symbolic links along a canonical absolute path by their targets (vfs_link.c).
| path | the real path, changed in place. |
| size | the size of the path buffer. |
| follow_last | also the last name, when it is a link. |
| root | the process's root directory ("/" for the real one): an absolute target starts there, and ".." stops there. |
| const char * vfs_inside_root | ( | const char * | path, |
| const char * | root ) |
a real path as a process with this root directory sees it.
the real path of a path as a process with this root sees it.
read the target of the symbolic link at path, with a NUL.
| kerr_t vfs_symlink | ( | const char * | path, |
| const char * | target ) |
make a symbolic link at path to target.
| kerr_t vfs_link | ( | const char * | old_path, |
| const char * | new_path ) |
give a file one more name (both paths on one mount, else KERR_INVAL).
make a named pipe or a device node (fs_ops_t mknod).
| kerr_t vfs_open | ( | const char * | path, |
| vfs_file_t * | file ) |
open a file or directory by absolute path in the virtual file system.
| path | absolute path to the file or directory. |
| file | pointer to a vfs_file_t structure that will be initialized with the opened file |
| kerr_t vfs_create | ( | const char * | path | ) |
create a regular file by absolute path.
| path | absolute path to the new file. |
| kerr_t vfs_mkdir | ( | const char * | path | ) |
create a directory by absolute path.
| path | absolute path to the new directory. |
| kerr_t vfs_remove | ( | const char * | path | ) |
remove a file by absolute path.
| path | absolute path to the file to remove. |
| kerr_t vfs_rmdir | ( | const char * | path | ) |
remove a directory by absolute path.
| path | absolute path to the directory to remove. |
| kerr_t vfs_rename | ( | const char * | old_path, |
| const char * | new_path ) |
rename a file or directory by absolute paths.
| old_path | absolute path to the existing file or directory. |
| new_path | absolute path to the new name for the file or directory. |
| kerr_t vfs_stat | ( | const char * | path, |
| vfs_stat_t * | stat_out ) |
stat a file or directory by absolute path.
| path | absolute path to the file or directory. |
| stat_out | pointer to a vfs_stat_t structure that will be filled with the file's metadata. |
resolve an input path against the current working directory.
absolute paths are returned as-is, relative paths are prefixed with cwd.
| cwd | current working directory. |
| input | user-provided path. |
| output | destination buffer for resolved absolute path. |
| size | size of destination buffer in bytes. |
join two path components into an output buffer.
avoids duplicate separators when base already ends with '/'.
| base | base path component. |
| name | child path component. |
| out | destination buffer. |
| size | destination buffer size in bytes. |
| uint32_t vfs_read | ( | vfs_file_t * | file, |
| uint32_t | size, | ||
| void * | buffer ) |
read data from an open file in the virtual file system.
| file | pointer to the vfs_file_t structure representing the open file. |
| size | number of bytes to read. |
| buffer | pointer to the buffer where the read data will be stored. |
| uint32_t vfs_write | ( | vfs_file_t * | file, |
| uint32_t | size, | ||
| const void * | buffer ) |
write data to an open file in the virtual file system.
| file | pointer to the vfs_file_t structure representing the open file. |
| size | number of bytes to write. |
| buffer | pointer to the source data. |
| kerr_t vfs_truncate | ( | vfs_file_t * | file, |
| uint64_t | length ) |
cut or grow an open file to length bytes (growth reads as zeros).
| kerr_t vfs_read_entry | ( | vfs_file_t * | file, |
| fs_dirent_t * | entryOut ) |
read a directory entry from an open directory in the virtual file system.
| file | pointer to the vfs_file_t structure representing the open directory. |
| entryOut | pointer to output directory entry. |
| void vfs_close | ( | vfs_file_t * | file | ) |
close an open file in the virtual file system.
| file | pointer to the vfs_file_t structure representing the open file. |
| uint8_t vfs_file_type | ( | vfs_file_t * | file | ) |
get the type of an open file in the virtual file system.
| file | pointer to the vfs_file_t structure representing the open file. |
| int32_t vfs_ioctl | ( | vfs_file_t * | file, |
| uint32_t | request, | ||
| void * | arg ) |
issue a device-control (ioctl) request on an open file.
dispatches through the backing filesystem; only special filesystems (devfs) implement it, forwarding to the device. others return -ENOTTY.
| file | pointer to the vfs_file_t representing the open file. |
| request | driver-defined request code. |
| arg | request-specific argument (typically a bounds-checked pointer). |
| int32_t vfs_mmap | ( | vfs_file_t * | file, |
| addr_space_t | as, | ||
| uintptr_t | virt, | ||
| size_t | length, | ||
| int | prot, | ||
| uint64_t | offset ) |
map an open file's memory into a process address space.
dispatches through the backing filesystem; only device nodes (devfs) that forward to a mappable device succeed. others return -ENODEV.
| file | pointer to the vfs_file_t representing the open file. |
| page_directory | physical address of the target process page directory. |
| virt | page-aligned destination virtual address. |
| length | bytes to map (page-multiple). |
| prot | PROT_* bits. |
| offset | page-aligned byte offset into the mapped object. |
| int64_t vfs_lseek | ( | vfs_file_t * | file, |
| int64_t | offset, | ||
| int | whence ) |
move an open file's offset, as lseek does: through the filesystem's own seek op if it has one (devfs), else the ext2 file cursor.
| file | the open file. |
| offset | bytes relative to whence. |
| whence | VFS_SEEK_SET, VFS_SEEK_CUR or VFS_SEEK_END. |
| void vfs_seek_end | ( | vfs_file_t * | file | ) |
move an open file's offset to its end (O_APPEND writes).
| file | the open file. |
| kerr_t vfs_fstat | ( | vfs_file_t * | file, |
| vfs_stat_t * | stat_out ) |
stat an open file or directory.
| file | the open file. |
| stat_out | receives its metadata. |
change the permission bits and/or owner of a file by path, or of an open file.
| kerr_t vfs_fsetattr | ( | vfs_file_t * | file, |
| const fs_attr_t * | attr ) |