PatchworkOS  19e446b
A non-POSIX operating system.
Loading...
Searching...
No Matches
fs.h File Reference
#include <alloca.h>
#include <assert.h>
#include <errno.h>
#include <stdarg.h>
#include <stdint.h>
#include <stdlib.h>
#include "_libstd/ERR.h"
#include "_libstd/MAX_NAME.h"
#include "_libstd/MAX_PATH.h"
#include "_libstd/NULL.h"
#include "_libstd/SEEK.h"
#include "_libstd/clock_t.h"
#include "_libstd/config.h"
#include "_libstd/fd_t.h"
#include "_libstd/ssize_t.h"
#include "_libstd/time_t.h"
Include dependency graph for fs.h:

Go to the source code of this file.

Data Structures

struct  pollfd_t
 Poll file descriptor structure. More...
 
struct  vattr_t
 Vnode attributes structure. More...
 
struct  stat_t
 Stat type. More...
 
struct  dirent_t
 Directory entry struct. More...
 

Macros

#define STDIN_FILENO   0
 Standard input file descriptor.
 
#define STDOUT_FILENO   1
 Standard output file descriptor.
 
#define STDERR_FILENO   2
 Standard error file descriptor.
 
#define PIPE_READ   0
 Pipe read end.
 
#define PIPE_WRITE   1
 Pipe write end.
 
#define F_MAX_SIZE   512
 Maximum buffer size for the F() macro.
 
#define F(format, ...)
 Allocates a formatted string on the stack.
 
#define POLL_SPECIAL   (POLLERR | POLLHUP | POLLNVAL)
 Poll event values that will always be checked and included even if not specified.
 
#define KEY_MAX   128
 Maximum size of a key generated by share().
 
#define KEY_128BIT   25
 The size of a buffer needed to hold a 128-bit key.
 
#define KEY_256BIT   45
 The size of a buffer needed to hold a 256-bit key.
 
#define KEY_512BIT   89
 The size of a buffer needed to hold a 512-bit key.
 
#define RETRY_EINTR(expr)
 Macro to automatically retry a function that returns an integer if it errors and errno == EINTR.
 
#define RETRY_EINTR_PTR(expr)
 Macro to automatically retry a function that returns a pointer if it errors and errno == EINTR.
 

Typedefs

typedef uint8_t seek_origin_t
 Type for the seek() origin argument.
 
typedef uint64_t sbid_t
 A suberblock identifier that uniquely identifies a superblock within the system.
 

Enumerations

enum  poll_events_t {
  POLLNONE = 0 , POLLIN = (1 << 0) , POLLOUT = (1 << 1) , POLLERR = (1 << 2) ,
  POLLHUP = (1 << 3) , POLLNVAL = (1 << 4)
}
 Poll events type. More...
 
enum  vtype_t { VREG , VDIR , VSYMLINK }
 Vnode type enum. More...
 
enum  dirent_flags_t { DIRENT_NONE = 0 , DIRENT_MOUNTED = 1 << 0 }
 Directory entry flags. More...
 

Functions

fd_t open (const char *path)
 System call for opening files.
 
uint64_t open2 (const char *path, fd_t fd[2])
 System call for opening 2 file descriptors from one file.
 
fd_t openat (fd_t from, const char *path)
 System call for opening files relative to another file descriptor.
 
uint64_t close (fd_t fd)
 System call for closing files.
 
size_t read (fd_t fd, void *buffer, size_t count)
 System call for reading from files.
 
char * reads (fd_t fd)
 Wrapper for reading a file directly into a null-terminated string.
 
size_t readfile (const char *path, void *buffer, size_t count, size_t offset)
 Wrapper for reading a file directly using a path.
 
char * readfiles (const char *path)
 Wrapper for reading an entire file directly into a null-terminated string.
 
size_t write (fd_t fd, const void *buffer, size_t count)
 System call for writing to files.
 
size_t writes (fd_t fd, const char *string)
 Wrapper for writing a null-terminated string to a file.
 
size_t writefile (const char *path, const void *buffer, size_t count, size_t offset)
 Wrapper for writing to a file directly using a path.
 
size_t writefiles (const char *path, const char *string)
 Wrapper for writing a null-terminated string directly to a file using a path.
 
uint64_t scan (fd_t fd, const char *format,...)
 Wrapper for reading from a file descriptor using scan formatting.
 
uint64_t vscan (fd_t fd, const char *format, va_list args)
 Wrapper for reading from a file descriptor using scan formatting with va_list.
 
uint64_t scanfile (const char *path, const char *format,...)
 Wrapper for reading from a file path using scan formatting.
 
uint64_t vscanfile (const char *path, const char *format, va_list args)
 Wrapper for reading from a file path using scan formatting with va_list.
 
size_t seek (fd_t fd, ssize_t offset, seek_origin_t origin)
 System call for changing the file offset.
 
uint64_t chdir (const char *path)
 System call for changing the cwd.
 
uint64_t poll (pollfd_t *fds, uint64_t amount, clock_t timeout)
 System call for polling files.
 
poll_events_t poll1 (fd_t fd, poll_events_t events, clock_t timeout)
 Wrapper for polling one file.
 
uint64_t stat (const char *path, stat_t *stat)
 System call for retrieving info about a file or directory.
 
uint64_t ioctl (fd_t fd, uint64_t request, void *argp, size_t size)
 System call for extended driver behaviour.
 
fd_t dup (fd_t oldFd)
 System call for duplicating file descriptors.
 
fd_t dup2 (fd_t oldFd, fd_t newFd)
 System call for duplicating file descriptors, with a destination.
 
size_t getdents (fd_t fd, dirent_t *buffer, uint64_t count)
 System call for reading directory entires.
 
size_t readdir (fd_t fd, dirent_t **buffer, uint64_t *count)
 Helper for reading all directory entries.
 
uint64_t mkdir (const char *path)
 Wrapper for creating a directory.
 
uint64_t rmdir (const char *path)
 Wrapper for removing a directory.
 
uint64_t link (const char *oldPath, const char *newPath)
 System call for creating a hardlink.
 
uint64_t unlink (const char *path)
 Wrapper for removing a file.
 
uint64_t share (char *key, uint64_t size, fd_t fd, clock_t timeout)
 System call for sharing a file descriptor with another process.
 
uint64_t sharefile (char *key, uint64_t size, const char *path, clock_t timeout)
 Helper for sharing a file by its path.
 
fd_t claim (const char *key)
 System call for claiming a shared file descriptor.
 
uint64_t bind (const char *mountpoint, fd_t source)
 System call for binding a file descriptor to a mountpoint.
 
uint64_t mount (const char *mountpoint, const char *fs, const char *options)
 System call for mounting a filesystem.
 
uint64_t unmount (const char *mountpoint)
 System call for unmounting a filesystem.
 
size_t readlink (const char *path, char *buffer, uint64_t count)
 System call for reading the target of a symbolic link.
 
uint64_t symlink (const char *target, const char *linkpath)
 System call for creating a symbolic link.