text: Virtual filesystem support. More...
  #include <sys/cdefs.h>
  #include <sys/types.h>
  #include <kos/limits.h>
  #include <time.h>
  #include <sys/queue.h>
  #include <stdarg.h>
  #include <kos/nmmgr.h>
  #include <sys/fcntl.h>
  Go to the source code of this file.
  Virtual filesystem support.
  This file contains the interface to the virtual filesystem (VFS) of KOS. The functions defined in this file make up the base of the filesystem operations that can be performed by programs. The functions in here are abstracted by various other layers in libc, and shouldn't be necessarily used (for portability reasons). However, if you want only to interact with KOS in your programs, feel free to use them to your heart's content!
  The number of distinct file descriptors that can be in use at a time.
  Invalid file handle constant (for open failure, etc)
  stat_t.attr: No attributes
  stat_t.attr: Read-capable
  stat_t.attr: Read/Write capable
  stat_t.attr: Write-capable
  stat_t.type: Standard directory
  stat_t.type: Standard file
  stat_t.type: Meta data
  stat_t.type: Unknown / undefined / not relevant
  stat_t.type: A virtual device of some sort (pipe, socket, etc)
  stat_t.type: Symbolic link
  stat_t.unique: Constant to use denoting the file has no unique ID
  <
  Directory entry.
  All VFS handlers must conform to this interface in their directory entries.
  File descriptor type.
  VFS handler interface.
  All VFS handlers must implement this interface.
  Change the current working directory of the current thread.
  This function changes the current working directory for the current thread. Any relative paths passed into file-related functions will be relative to the path that is changed to.
  Close an opened file.
  This function closes the specified file descriptor, releasing all resources associated with the descriptor.
  Perform an I/O completion on the given file descriptor.
  This function is used with asynchronous I/O to perform an I/O completion on the given file descriptor. Most filesystems do not support this operation on KallistiOS.
  Copy a file.
  This function copies the file at src to dst on the filesystem.
  Duplicate a file descriptor.
  This function duplicates the specified file descriptor, returning a new file descriptor that can be used to access the file. This is equivalent to the standard POSIX function dup().
  Duplicate a file descriptor onto the specified descriptor.
  This function duplicates the specified file descriptor onto the other file descriptor provided. If the newfd parameter represents an open file, that file will be closed before the old descriptor is duplicated onto it. This is equivalent to the standard POSIX function dup2().
  Manipulate file control flags.
  This function implements the standard C fcntl function.
  Retrieve the internal handle for a file descriptor.
  This function retrieves the internal file handle data of the specified file descriptor. There is generally no reason to call this function in user code, as it is meant for use internally.
  Retrieve the VFS Handler for a file descriptor.
  This function retrieves the Handler structure for the VFS of the specified file descriptor. There is generally no reason to call this function in user code, as it is meant for use internally.
  Get the current working directory of the running thread.
  Initialize the virtual filesystem.
  This is normally done for you by default when KOS starts. In general, there should be no reason for you to call this function.
  Execute a device-specific command on a file descriptor.
  The types and formats of the commands are device/filesystem specific, and are not documented here. Each filesystem may define any commands that are specific to it with its implementation of this function.
  Create a hard link.
  This function implements the POSIX function link(), which creates a hard link for an existing file.
  Open and read a whole file into RAM.
  This function opens the specified file, reads it into memory (allocating the necessary space with malloc), and closes the file. The caller is responsible for freeing the memory when they are done with it.
  Create a directory.
  This function creates the specified directory, if possible.
  Memory-map a previously opened file.
  This file "maps" the opened file into memory, reading the whole file into a buffer, and returning that buffer. The returned buffer should not be freed, as it will be freed when the file is closed. Bytes written into the buffer, up to the original length of the file, will be written back to the file when it is closed, assuming that the file is opened for writing.
  Note that some of the filesystems in KallistiOS do not support this operation.
  Open a file on the VFS.
  This function opens the specified file, returning a new file descriptor to access the file.
  Create a "transient" file descriptor.
  This function creates and opens a new file descriptor that isn't associated directly with a file on the filesystem. This is used internally to actually open files, and should (in general) not be called by user code. Effectively, if you're trying to implement your own filesystem handler in your code, you may need this function, otherwise you should just ignore it.
  Read from an opened file.
  This function reads into the specified buffer from the file at its current file pointer.
  Read an entry from an opened directory.
  This function reads the next entry from the directory specified by the given file descriptor.
  Rename the specified file to the given filename.
  This function renames the file specified by the first argument to the second argument. The two paths should be on the same filesystem.
  Remove a directory by name.
  This function removes the specified directory. The directory shall only be removed if it is empty.
  Seek to a new position within a file.
  This function moves the file pointer to the specified position within the file (the base of this position is determined by the whence parameter).
  Seek to a new position within a file (64-bit offsets).
  This function moves the file pointer to the specified position within the file (the base of this position is determined by the whence parameter).
  Shut down the virtual filesystem.
  This is done for you by the normal shutdown procedure of KOS. There should not really be any reason for you to call this function yourself.
  Create a symbolic link.
  This function implements the POSIX function symlink(), which creates a symbolic link on the filesystem. Symbolic links are not required to point to an existing file (per POSIX) and may result in circular links if care is not taken. For now, symbolic links cannot cross filesystem boundaries in KOS.
  Retrieve the position of the pointer within a file.
  This function retrieves the current location of the file pointer within an opened file. This is an offset in bytes from the start of the file.
  Retrieve the position of the 64-bit pointer within a file.
  This function retrieves the current location of the file pointer within an opened file. This is an offset in bytes from the start of the file.
  Retrieve the length of an opened file.
  This file retrieves the length of the file associated with the given file descriptor.
  Retrieve the length of an opened file as a 64-bit integer.
  This file retrieves the length of the file associated with the given file descriptor.
  Delete the specified file.
  This function deletes the specified file from the filesystem. This should only be used for files, not for directories. For directories, use fs_rmdir() instead of this function.
  Write to an opened file.
  This function writes the specfied buffer into the file at the current file pointer.