|
ginnOS
The reference: libc, the libraries and the kernel
|
generic filesystem layer. More...
Functions | |
| bool | fs_mount (fs_mount_t *mount, block_device_t *device) |
| mount a filesystem on a block device. | |
| kerr_t | fs_open (fs_mount_t *mount, const char *path, fs_file_t *file) |
| open a file or directory by absolute path. | |
| kerr_t | fs_create (fs_mount_t *mount, const char *path) |
| create a regular file at an absolute path. | |
| kerr_t | fs_mkdir (fs_mount_t *mount, const char *path) |
| create a directory at an absolute path. | |
| kerr_t | fs_remove (fs_mount_t *mount, const char *path) |
| remove a file at an absolute path. | |
| kerr_t | fs_rmdir (fs_mount_t *mount, const char *path) |
| remove a directory at an absolute path. | |
| kerr_t | fs_rename (fs_mount_t *mount, const char *old_path, const char *new_path) |
| rename a file or directory. | |
| kerr_t | fs_find_link (fs_mount_t *mount, const char *path, bool follow_last, char *target, uint32_t size, uint32_t *end_out) |
| the link operations (see fs_ops_t). | |
| kerr_t | fs_readlink (fs_mount_t *mount, const char *path, char *target, uint32_t size) |
| kerr_t | fs_symlink (fs_mount_t *mount, const char *path, const char *target) |
| kerr_t | fs_link (fs_mount_t *mount, const char *old_path, const char *new_path) |
| kerr_t | fs_mknod (fs_mount_t *mount, const char *path, uint32_t mode, uint32_t rdev) |
| kerr_t | fs_stat (fs_mount_t *mount, const char *path, fs_stat_t *stat_out) |
| stat a file or directory by absolute path. | |
| uint32_t | fs_read (fs_file_t *file, uint32_t byteCount, void *dataOut) |
| read bytes from an open file into a buffer. | |
| uint32_t | fs_write (fs_file_t *file, uint32_t byteCount, const void *dataIn) |
| write bytes to an open file. | |
| kerr_t | fs_truncate (fs_file_t *file, uint64_t length) |
| cut or grow an open file to length bytes (growth reads as zeros). | |
| kerr_t | fs_read_entry (fs_file_t *file, fs_dirent_t *entryOut) |
| read a directory entry from an open directory file. | |
| void | fs_close (fs_file_t *file) |
| close an open file or directory. | |
| uint8_t | fs_file_type (const fs_file_t *file) |
| get the type of an open file or directory. | |
| int32_t | fs_ioctl (fs_file_t *file, uint32_t request, void *arg) |
| issue a device-control (ioctl) request on an open special file. | |
| int32_t | fs_mmap (fs_file_t *file, addr_space_t as, uintptr_t virt, size_t length, int prot, uint64_t offset) |
| map an open special file's memory into a process address space. | |
| int64_t | fs_seek (fs_file_t *file, int64_t offset, int whence) |
| reposition an open file's cursor via the filesystem's seek op. | |
| int64_t | fs_seek_position (uint64_t current, uint64_t size, int64_t offset, int whence) |
| the position a seek gives, as lseek computes it. | |
| kerr_t | fs_fstat (fs_file_t *file, fs_stat_t *stat_out) |
| stat an open file or directory. | |
| kerr_t | fs_setattr (fs_file_t *file, const fs_attr_t *attr) |
| change an open file's permission bits and/or owner. | |
generic filesystem layer.
fs_* dispatches through the mounted filesystem's operations vtable (fs_ops_t) and never names a concrete filesystem. fs_mount() is the one place that picks a filesystem implementation; today that is always ext2, but adding another means providing its own fs_ops_t and selecting it here.
| bool fs_mount | ( | fs_mount_t * | mount, |
| block_device_t * | device ) |
mount a filesystem on a block device.
| mount | filesystem mount object to initialize. |
| device | initialized block device backend. |
| kerr_t fs_open | ( | fs_mount_t * | mount, |
| const char * | path, | ||
| fs_file_t * | file ) |
open a file or directory by absolute path.
| mount | initialized filesystem mount. |
| path | absolute path to the file or directory. |
| file | output file handle. |
| kerr_t fs_create | ( | fs_mount_t * | mount, |
| const char * | path ) |
create a regular file at an absolute path.
| mount | initialized filesystem mount. |
| path | absolute path to the new file. |
| kerr_t fs_mkdir | ( | fs_mount_t * | mount, |
| const char * | path ) |
create a directory at an absolute path.
| mount | initialized filesystem mount. |
| path | absolute path to the new directory. |
| kerr_t fs_remove | ( | fs_mount_t * | mount, |
| const char * | path ) |
remove a file at an absolute path.
| mount | initialized filesystem mount. |
| path | absolute path to the file to remove. |
| kerr_t fs_rmdir | ( | fs_mount_t * | mount, |
| const char * | path ) |
remove a directory at an absolute path.
| mount | initialized filesystem mount. |
| path | absolute path to the directory to remove. |
| kerr_t fs_rename | ( | fs_mount_t * | mount, |
| const char * | old_path, | ||
| const char * | new_path ) |
rename a file or directory.
| mount | initialized filesystem mount. |
| 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 fs_find_link | ( | fs_mount_t * | mount, |
| const char * | path, | ||
| bool | follow_last, | ||
| char * | target, | ||
| uint32_t | size, | ||
| uint32_t * | end_out ) |
the link operations (see fs_ops_t).
with no such operation: find_link finds none, readlink is KERR_INVAL (not a link), symlink and link are KERR_PERM.
| kerr_t fs_readlink | ( | fs_mount_t * | mount, |
| const char * | path, | ||
| char * | target, | ||
| uint32_t | size ) |
| kerr_t fs_symlink | ( | fs_mount_t * | mount, |
| const char * | path, | ||
| const char * | target ) |
| kerr_t fs_link | ( | fs_mount_t * | mount, |
| const char * | old_path, | ||
| const char * | new_path ) |
| kerr_t fs_mknod | ( | fs_mount_t * | mount, |
| const char * | path, | ||
| uint32_t | mode, | ||
| uint32_t | rdev ) |
| kerr_t fs_stat | ( | fs_mount_t * | mount, |
| const char * | path, | ||
| fs_stat_t * | stat_out ) |
stat a file or directory by absolute path.
| mount | initialized filesystem mount. |
| path | absolute path to the file or directory. |
| stat_out | output stat structure. |
read bytes from an open file into a buffer.
| file | open file handle. |
| byteCount | number of bytes to read. |
| dataOut | destination buffer. |
write bytes to an open file.
| file | open file handle. |
| byteCount | number of bytes to write. |
| dataIn | source buffer. |
cut or grow an open file to length bytes (growth reads as zeros).
| kerr_t fs_read_entry | ( | fs_file_t * | file, |
| fs_dirent_t * | entryOut ) |
read a directory entry from an open directory file.
| file | open directory file handle. |
| entryOut | output directory entry. |
| void fs_close | ( | fs_file_t * | file | ) |
close an open file or directory.
| file | open file handle to close. |
get the type of an open file or directory.
| file | open file handle. |
issue a device-control (ioctl) request on an open special file.
dispatches through the filesystem's ioctl op; filesystems without one (ext2, etc.) return -ENOTTY.
| file | open file handle. |
| request | driver-defined request code. |
| arg | request-specific argument (typically a bounds-checked pointer). |
| int32_t fs_mmap | ( | fs_file_t * | file, |
| addr_space_t | as, | ||
| uintptr_t | virt, | ||
| size_t | length, | ||
| int | prot, | ||
| uint64_t | offset ) |
map an open special file's memory into a process address space.
dispatches through the filesystem's mmap op; filesystems without one return -ENODEV. the frames are mapped eagerly at virt in page_directory.
| file | open file handle. |
| 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. |
reposition an open file's cursor via the filesystem's seek op.
the position a seek gives, as lseek computes it.
| current | the current position. |
| size | the size of the file (for SEEK_END). |
| offset | the offset relative to whence. |
| whence | 0 (SEEK_SET), 1 (SEEK_CUR) or 2 (SEEK_END). |
stat an open file or directory.
| file | open file handle. |
| stat_out | output stat structure. |