|
PatchworkOS
966e257
A non-POSIX operating system.
|
Virtual File System. More...
Virtual File System.
The Virtual File System (VFS) provides a single unified interface for any and all filesystems, including virtual filesystems used to expose kernel resources to user space.
Macros | |
| #define | VFS_ROOT_ENTRY_NAME "__root__" |
| The name of the root entry. | |
| #define | VFS_DEVICE_NAME_NONE "__no_device__" |
| The name used to indicate no device. | |
| #define | BUFFER_READ(buffer, count, offset, src, size) |
| Helper macros for implementing file operations dealing with simple buffers. | |
| #define | BUFFER_WRITE(buffer, count, offset, src, size) |
| Helper macro for implementing file operations dealing with simple buffer writes. | |
Functions | |
| file_t * | vfs_open (const pathname_t *pathname, process_t *process) |
| Open a file. | |
| uint64_t | vfs_open2 (const pathname_t *pathname, file_t *files[2], process_t *process) |
| Open one file, returning two file handles. | |
| file_t * | vfs_openat (const path_t *from, const pathname_t *pathname, process_t *process) |
| Open a file relative to another path. | |
| uint64_t | vfs_read (file_t *file, void *buffer, uint64_t count) |
| Read from a file. | |
| uint64_t | vfs_write (file_t *file, const void *buffer, uint64_t count) |
| Write to a file. | |
| uint64_t | vfs_seek (file_t *file, int64_t offset, seek_origin_t origin) |
| Seek in a file. | |
| uint64_t | vfs_ioctl (file_t *file, uint64_t request, void *argp, uint64_t size) |
| Perform an ioctl operation on a file. | |
| void * | vfs_mmap (file_t *file, void *address, uint64_t length, pml_flags_t flags) |
| Memory map a file. | |
| uint64_t | vfs_poll (poll_file_t *files, uint64_t amount, clock_t timeout) |
| Poll multiple files. | |
| uint64_t | vfs_getdents (file_t *file, dirent_t *buffer, uint64_t count) |
| Get directory entries from a directory file. | |
| uint64_t | vfs_stat (const pathname_t *pathname, stat_t *buffer, process_t *process) |
| Get file information. | |
| uint64_t | vfs_link (const pathname_t *oldPathname, const pathname_t *newPathname, process_t *process) |
| Make the same file appear twice in the filesystem. | |
| uint64_t | vfs_remove (const pathname_t *pathname, process_t *process) |
| Remove a file or directory. | |
| uint64_t | vfs_id_get (void) |
| Generates a new unique ID, to be used for any VFS object. | |
| #define VFS_ROOT_ENTRY_NAME "__root__" |
| #define VFS_DEVICE_NAME_NONE "__no_device__" |
Helper macros for implementing file operations dealing with simple buffers.
| buffer | The destination buffer. |
| count | The number of bytes to read/write. |
| offset | A pointer to the current offset, will be updated. |
| src | The source buffer. |
| size | The size of the source buffer. |
Helper macro for implementing file operations dealing with simple buffer writes.
| buffer | The destination buffer. |
| count | The number of bytes to write. |
| offset | A pointer to the current offset, will be updated. |
| src | The source buffer. |
| size | The size of the source buffer. |
| file_t * vfs_open | ( | const pathname_t * | pathname, |
| process_t * | process | ||
| ) |
Open a file.
| pathname | The pathname of the file to open. |
| process | The process opening the file. |
NULL and errno is set. Definition at line 94 of file vfs.c.
| uint64_t vfs_open2 | ( | const pathname_t * | pathname, |
| file_t * | files[2], | ||
| process_t * | process | ||
| ) |
Open one file, returning two file handles.
Used primarily to implement pipes.
| pathname | The pathname of the file to open. |
| files | The output array of two file pointers. |
| process | The process opening the file. |
0. On failure, ERR and errno is set. Definition at line 108 of file vfs.c.
| file_t * vfs_openat | ( | const path_t * | from, |
| const pathname_t * | pathname, | ||
| process_t * | process | ||
| ) |
Open a file relative to another path.
| from | The path to open the file relative to. |
| pathname | The pathname of the file to open. |
| process | The process opening the file. |
NULL and errno is set. Definition at line 158 of file vfs.c.
Read from a file.
Follows POSIX semantics.
| file | The file to read from. |
| buffer | The buffer to read into. |
| count | The number of bytes to read. |
ERR and errno is set. Definition at line 200 of file vfs.c.
Write to a file.
Follows POSIX semantics.
| file | The file to write to. |
| buffer | The buffer to write from. |
| count | The number of bytes to write. |
ERR and errno is set. Definition at line 239 of file vfs.c.
| uint64_t vfs_seek | ( | file_t * | file, |
| int64_t | offset, | ||
| seek_origin_t | origin | ||
| ) |
Seek in a file.
Follows POSIX semantics.
| file | The file to seek in. |
| offset | The offset to seek to. |
| origin | The origin to seek from. |
ERR and errno is set. Definition at line 286 of file vfs.c.
Perform an ioctl operation on a file.
| file | The file to perform the ioctl on. |
| request | The ioctl request. |
| argp | The argument pointer. |
| size | The size of the argument. |
ERR and errno is set. Definition at line 304 of file vfs.c.
| void * vfs_mmap | ( | file_t * | file, |
| void * | address, | ||
| uint64_t | length, | ||
| pml_flags_t | flags | ||
| ) |
Memory map a file.
| file | The file to memory map. |
| address | The address to map to, or NULL to let the kernel choose. |
| length | The length to map. |
| flags | The page table flags for the mapping. |
NULL and errno is set. Definition at line 333 of file vfs.c.
| uint64_t vfs_poll | ( | poll_file_t * | files, |
| uint64_t | amount, | ||
| clock_t | timeout | ||
| ) |
Poll multiple files.
| files | The array of files to poll. |
| amount | The number of files in the array. |
| timeout | The timeout in clock ticks, or CLOCKS_NEVER to wait indefinitely. |
ERR and errno is set. Definition at line 440 of file vfs.c.
Get directory entries from a directory file.
| file | The directory file to read from. |
| buffer | The buffer to read into. |
| count | The number of bytes to read. |
ERR and errno is set. Definition at line 515 of file vfs.c.
| uint64_t vfs_stat | ( | const pathname_t * | pathname, |
| stat_t * | buffer, | ||
| process_t * | process | ||
| ) |
Get file information.
| pathname | The pathname of the file to get information about. |
| buffer | The buffer to store the file information in. |
| process | The process performing the stat. |
0. On failure, ERR and errno is set. Definition at line 556 of file vfs.c.
| uint64_t vfs_link | ( | const pathname_t * | oldPathname, |
| const pathname_t * | newPathname, | ||
| process_t * | process | ||
| ) |
Make the same file appear twice in the filesystem.
| oldPathname | The existing file. |
| newPathname | The new link to create, must not exist and be in the same filesystem as the oldPathname. |
| process | The process performing the linking. |
0. On failure, ERR and errno is set. Definition at line 609 of file vfs.c.
| uint64_t vfs_remove | ( | const pathname_t * | pathname, |
| process_t * | process | ||
| ) |
Remove a file or directory.
| pathname | The pathname of the file or directory to remove. |
| process | The process performing the removal. |
0. On failure, ERR and errno is set. Definition at line 698 of file vfs.c.