PatchworkOS
Loading...
Searching...
No Matches
io.h File Reference
#include <stdarg.h>
#include <stdint.h>
#include "_internal/ERR.h"
#include "_internal/MAX_NAME.h"
#include "_internal/MAX_PATH.h"
#include "_internal/NULL.h"
#include "_internal/SEEK.h"
#include "_internal/clock_t.h"
#include "_internal/config.h"
#include "_internal/fd_t.h"
#include "_internal/time_t.h"

Go to the source code of this file.

Data Structures

struct  pollfd_t
 Poll file descriptor structure. More...
 
struct  stat_t
 Stat type. More...
 
struct  dirent_t
 Directory entry struct. More...
 
struct  key_t
 Key type. More...
 

Macros

#define STDIN_FILENO   0
 
#define STDOUT_FILENO   1
 
#define STDERR_FILENO   2
 
#define PIPE_READ   0
 Pipe read end.
 
#define PIPE_WRITE   1
 Pipe write end.
 
#define POLL_SPECIAL   (POLLERR | POLLHUP | POLLNVAL)
 Poll event values that will always be checked and included even if not specified.
 
#define KEY_SIZE   16
 Size of keys in bytes.
 

Typedefs

typedef uint8_t seek_origin_t
 Type for the seek() origin argument.
 
typedef uint64_t inode_number_t
 Inode number enum.
 

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  inode_type_t {
  INODE_FILE ,
  INODE_DIR
}
 Inode type enum. More...
 

Functions

fd_t open (const char *path)
 System call for opening files.
 
fd_t openf (const char *_RESTRICT format,...)
 Wrapper for opening files with a formatted path.
 
fd_t vopenf (const char *_RESTRICT format, va_list args)
 Wrapper for opening files with a formatted path, using a va_list.
 
uint64_t open2 (const char *path, fd_t fd[2])
 System call for opening 2 file descriptors from one file.
 
uint64_t close (fd_t fd)
 System call for closing files.
 
uint64_t read (fd_t fd, void *buffer, uint64_t count)
 System call for reading from files.
 
uint64_t readf (fd_t fd, const char *_RESTRICT format,...)
 Wrapper for reading a formatted string from a file.
 
uint64_t vreadf (fd_t fd, const char *_RESTRICT format, va_list args)
 Wrapper for reading a formatted string from a file with a va_list.
 
uint64_t write (fd_t fd, const void *buffer, uint64_t count)
 System call for writing to files.
 
uint64_t writef (fd_t fd, const char *_RESTRICT format,...)
 Wrapper for writing a formatted string to a file.
 
uint64_t vwritef (fd_t fd, const char *_RESTRICT format, va_list args)
 Wrapper for writing a formatted string to a file with a va_list.
 
uint64_t readfile (const char *path, void *buffer, uint64_t count, uint64_t offset)
 Wrapper for reading a file directly using a path.
 
uint64_t readfilef (const char *path, const char *_RESTRICT format,...)
 Wrapper for reading a formatted string from a file directly using a path.
 
uint64_t vreadfilef (const char *path, const char *_RESTRICT format, va_list args)
 Wrapper for reading a formatted string from a file directly using a path with a va_list.
 
uint64_t writefile (const char *path, const void *buffer, uint64_t count, uint64_t offset)
 Wrapper for writing a file directly using a path.
 
uint64_t writefilef (const char *path, const char *_RESTRICT format,...)
 Wrapper for writing a formatted string to a file directly using a path.
 
uint64_t vwritefilef (const char *path, const char *_RESTRICT format, va_list args)
 Wrapper for writing a formatted string to a file directly using a path with a va_list.
 
uint64_t seek (fd_t fd, int64_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, uint64_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.
 
uint64_t getdents (fd_t fd, dirent_t *buffer, uint64_t count)
 System call for reading directory entires.
 
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 removef (const char *format,...)
 Wrapper for removing a file with a formatted path.
 
uint64_t vremovef (const char *format, va_list args)
 Wrapper for removing a file with a formatted path, using a va_list.
 
uint64_t share (key_t *key, fd_t fd, clock_t timeout)
 System call for sharing a file descriptor with another process.
 
fd_t claim (key_t *key)
 System call for claiming a shared file descriptor.
 
uint64_t bind (fd_t source, const char *mountpoint)
 System call for binding a file descriptor to a mountpoint.