PatchworkOS  19e446b
A non-POSIX operating system.
Loading...
Searching...
No Matches
Filesystem IO

Filesystem header. More...

Collaboration diagram for Filesystem IO:

Detailed Description

Filesystem header.

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.
 

Macro Definition Documentation

◆ STDIN_FILENO

#define STDIN_FILENO   0

Standard input file descriptor.

Definition at line 35 of file fs.h.

◆ STDOUT_FILENO

#define STDOUT_FILENO   1

Standard output file descriptor.

Definition at line 36 of file fs.h.

◆ STDERR_FILENO

#define STDERR_FILENO   2

Standard error file descriptor.

Definition at line 37 of file fs.h.

◆ PIPE_READ

#define PIPE_READ   0

Pipe read end.

The PIPE_READ constant defines which file descriptor in fd from a open2 call on the /dev/pipe file will be the read end of the pipe.

Definition at line 46 of file fs.h.

◆ PIPE_WRITE

#define PIPE_WRITE   1

Pipe write end.

The PIPE_WRITE constant defines which file descriptor in fd from a open2 call on the /dev/pipe file will be the write end of the pipe.

Definition at line 55 of file fs.h.

◆ F_MAX_SIZE

#define F_MAX_SIZE   512

Maximum buffer size for the F() macro.

Definition at line 60 of file fs.h.

◆ F

#define F (   format,
  ... 
)
Value:
({ \
char* _buffer = alloca(F_MAX_SIZE); \
int _len = snprintf(_buffer, F_MAX_SIZE, format, __VA_ARGS__); \
if (_len < 0 || _len >= F_MAX_SIZE) \
{ \
abort(); \
} \
_buffer; \
})
#define alloca(size)
Definition alloca.h:11
static char format[MAX_NAME]
Definition screen.c:17
#define F_MAX_SIZE
Maximum buffer size for the F() macro.
Definition fs.h:60
_PUBLIC int snprintf(char *_RESTRICT s, size_t n, const char *_RESTRICT format,...)
Definition snprintf.c:3

Allocates a formatted string on the stack.

Warning
Will terminate the program if the size of the formatted string is too large or if an encoding error occurs.

Definition at line 67 of file fs.h.

◆ POLL_SPECIAL

#define POLL_SPECIAL   (POLLERR | POLLHUP | POLLNVAL)

Poll event values that will always be checked and included even if not specified.

Definition at line 298 of file fs.h.

◆ KEY_MAX

#define KEY_MAX   128

Maximum size of a key generated by share().

Definition at line 518 of file fs.h.

◆ KEY_128BIT

#define KEY_128BIT   25

The size of a buffer needed to hold a 128-bit key.

Definition at line 520 of file fs.h.

◆ KEY_256BIT

#define KEY_256BIT   45

The size of a buffer needed to hold a 256-bit key.

Definition at line 522 of file fs.h.

◆ KEY_512BIT

#define KEY_512BIT   89

The size of a buffer needed to hold a 512-bit key.

Definition at line 524 of file fs.h.

◆ RETRY_EINTR

#define RETRY_EINTR (   expr)
Value:
({ \
uint64_t _result; \
do \
{ \
_result = (expr); \
} while (_result == ERR && errno == EINTR); \
_result; \
})
#define EINTR
Interrupted system call.
Definition errno.h:52
#define errno
Error number variable.
Definition errno.h:27
#define ERR
Integer error value.
Definition ERR.h:17
__UINT64_TYPE__ uint64_t
Definition stdint.h:17

Macro to automatically retry a function that returns an integer if it errors and errno == EINTR.

Parameters
exprThe expression to evaluate.

Definition at line 613 of file fs.h.

◆ RETRY_EINTR_PTR

#define RETRY_EINTR_PTR (   expr)
Value:
({ \
void* _result; \
do \
{ \
_result = (expr); \
} while (_result == NULL && errno == EINTR); \
_result; \
})
#define NULL
Pointer error value.
Definition NULL.h:25

Macro to automatically retry a function that returns a pointer if it errors and errno == EINTR.

Parameters
exprThe expression to evaluate.

Definition at line 628 of file fs.h.

Typedef Documentation

◆ seek_origin_t

Type for the seek() origin argument.

Definition at line 260 of file fs.h.

◆ sbid_t

typedef uint64_t sbid_t

A suberblock identifier that uniquely identifies a superblock within the system.

When combined with a vnode number, this can uniquely identify an vnode within the entire system.

Definition at line 353 of file fs.h.

Enumeration Type Documentation

◆ poll_events_t

Poll events type.

Enumerator
POLLNONE 

None.

POLLIN 

File descriptor is ready to read.

POLLOUT 

File descriptor is ready to write.

POLLERR 

File descriptor caused an error.

POLLHUP 

Stream socket peer closed connection, or shut down writing of connection.

POLLNVAL 

Invalid file descriptor.

Definition at line 285 of file fs.h.

◆ vtype_t

enum vtype_t

Vnode type enum.

Enumerator
VREG 

Is a regular file.

VDIR 

Is a directory.

VSYMLINK 

Is a symbolic link.

Definition at line 341 of file fs.h.

◆ dirent_flags_t

Directory entry flags.

Enumerator
DIRENT_NONE 
DIRENT_MOUNTED 

The directory entry is a mountpoint.

Definition at line 444 of file fs.h.

Function Documentation

◆ open()

fd_t open ( const char *  path)

System call for opening files.

The open() function opens a file located at a given path.

Parameters
pathThe path to the desired file.
Returns
On success, the file descriptor, on failure returns ERR and errno is set.

Definition at line 8 of file open.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ open2()

uint64_t open2 ( const char *  path,
fd_t  fd[2] 
)

System call for opening 2 file descriptors from one file.

This is intended as a more generic implementation of system calls like pipe() in POSIX systems. One example use case of this system call is pipes, if open2 is called on /dev/pipe then fd[0] will store the read end of the pipe and fd[1] will store the write end of the pipe. But if open() is called on /dev/pipe then the returned file descriptor would be both ends.

Parameters
pathThe path to the desired file.
fdAn array of two fd_t where the new file descriptors will be stored.
Returns
On success, 0, on failure returns ERR and errno is set.

Definition at line 8 of file open2.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ openat()

fd_t openat ( fd_t  from,
const char *  path 
)

System call for opening files relative to another file descriptor.

Parameters
fromThe file descriptor to open the file relative to, or FD_NONE to open from the current working directory.
pathThe path to the desired file.
Returns
On success, the file descriptor, on failure returns ERR and errno is set.

Definition at line 8 of file openat.c.

Here is the call graph for this function:

◆ close()

uint64_t close ( fd_t  fd)

System call for closing files.

Parameters
fdThe file descriptor to close.
Returns
On success, 0, on failure returns ERR and errno is set.

Definition at line 8 of file close.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ read()

size_t read ( fd_t  fd,
void *  buffer,
size_t  count 
)

System call for reading from files.

Parameters
fdThe file descriptor to read from.
bufferA pointer to the buffer where the data will be stored.
countThe maximum number of bytes to read.
Returns
On success, the number of bytes read. On end-of-file, 0. On failure, ERR and errno is set.

Definition at line 8 of file read.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ reads()

char * reads ( fd_t  fd)

Wrapper for reading a file directly into a null-terminated string.

The reads() function reads the entire contents of a file into a newly allocated null-terminated string. The caller is responsible for freeing the returned string.

Parameters
fdThe file descriptor to read from.
Returns
On success, a pointer to the null-terminated string. On failure, NULL and errno is set.

Definition at line 5 of file sread.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readfile()

size_t readfile ( const char *  path,
void *  buffer,
size_t  count,
size_t  offset 
)

Wrapper for reading a file directly using a path.

Equivalent to calling open(), seek(), read(), and close() in sequence.

Parameters
pathThe path to the file.
bufferA pointer to the buffer where the data will be stored.
countThe maximum number of bytes to read.
offsetThe offset in the file to start reading from.
Returns
On success, the number of bytes read. On end-of-file, 0. On failure, ERR and errno is set.

Definition at line 3 of file readfile.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readfiles()

char * readfiles ( const char *  path)

Wrapper for reading an entire file directly into a null-terminated string.

The readfiles() function reads the entire contents of a file into a newly allocated null-terminated string. The caller is responsible for freeing the returned string.

Equivalent to calling open(), reads(), and close() in sequence.

Parameters
pathThe path to the file.
Returns
On success, a pointer to the null-terminated string. On failure, NULL and errno is set.

Definition at line 3 of file sreadfile.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ write()

size_t write ( fd_t  fd,
const void *  buffer,
size_t  count 
)

System call for writing to files.

Parameters
fdThe file descriptor to write to.
bufferA pointer to the buffer containing the data to write.
countThe number of bytes to write.
Returns
On success, the number of bytes written. On failure, ERR and errno is set.

Definition at line 8 of file write.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writes()

size_t writes ( fd_t  fd,
const char *  string 
)

Wrapper for writing a null-terminated string to a file.

Parameters
fdThe file descriptor to write to.
stringThe null-terminated string to write.
Returns
On success, the number of bytes written. On failure, ERR and errno is set.

Definition at line 4 of file swrite.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ writefile()

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.

Equivalent to calling open(), seek(), write(), and close() in sequence.

Parameters
pathThe path to the file.
bufferA pointer to the buffer containing the data to write.
countThe number of bytes to write.
offsetThe offset in the file to start writing to.
Returns
On success, the number of bytes written. On failure, ERR and errno is set.

Definition at line 3 of file writefile.c.

Here is the call graph for this function:

◆ writefiles()

size_t writefiles ( const char *  path,
const char *  string 
)

Wrapper for writing a null-terminated string directly to a file using a path.

Equivalent to calling open(), writes(), and close() in sequence.

Parameters
pathThe path to the file.
stringThe null-terminated string to write.
Returns
On success, the number of bytes written. On failure, ERR and errno is set.

Definition at line 4 of file swritefile.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scan()

uint64_t scan ( fd_t  fd,
const char *  format,
  ... 
)

Wrapper for reading from a file descriptor using scan formatting.

Parameters
fdThe file descriptor to read from.
formatThe format string.
Returns
On success, the number of input items successfully matched and assigned. On failure, ERR.

Definition at line 6 of file scan.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vscan()

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.

Parameters
fdThe file descriptor to read from.
formatThe format string.
argsThe va_list of arguments.
Returns
On success, the number of input items successfully matched and assigned. On failure, ERR.

Definition at line 29 of file vscan.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ scanfile()

uint64_t scanfile ( const char *  path,
const char *  format,
  ... 
)

Wrapper for reading from a file path using scan formatting.

Equivalent to calling open(), scan(), and close() in sequence.

Parameters
pathThe path to the file.
formatThe format string.
Returns
On success, the number of input items successfully matched and assigned. On failure, ERR.

Definition at line 6 of file scanfile.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vscanfile()

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.

Equivalent to calling open(), vscan(), and close() in sequence.

Parameters
pathThe path to the file.
formatThe format string.
argsThe va_list of arguments.
Returns
On success, the number of input items successfully matched and assigned. On failure, ERR.

Definition at line 6 of file vscanfile.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ seek()

size_t seek ( fd_t  fd,
ssize_t  offset,
seek_origin_t  origin 
)

System call for changing the file offset.

Parameters
fdThe file descriptor.
offsetThe offset to move the file pointer.
originThe origin that the offset is relative to (e.g., SEEK_SET, SEEK_CUR, SEEK_END).
Returns
On success, the new offset from the beginning of the file. On failure, ERR and errno is set.

Definition at line 8 of file seek.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ chdir()

uint64_t chdir ( const char *  path)

System call for changing the cwd.

Parameters
pathThe path to the new directory.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 8 of file chdir.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ poll()

uint64_t poll ( pollfd_t fds,
uint64_t  amount,
clock_t  timeout 
)

System call for polling files.

Parameters
fdsAn array of pollfd_t structures, each specifying a file descriptor to poll in pollfd_t::fd and the events to wait for in pollfd_t::events.
amountThe number of pollfd_t structures in the fds array.
timeoutThe maximum time (in clock ticks) to wait for an event. If CLOCKS_NEVER, it waits forever.
Returns
On success, the number of file descriptors for which the events occurred. On timeout, 0. On failure, ERR and errno is set.

Definition at line 8 of file poll.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ poll1()

poll_events_t poll1 ( fd_t  fd,
poll_events_t  events,
clock_t  timeout 
)

Wrapper for polling one file.

The poll1() function waits for events on a single file descriptor. Otherwise it is identical to poll() and exists simply for convenience.

Parameters
fdThe file descriptor to poll.
eventsThe events to wait for (e.g., POLLIN, POLLOUT).
timeoutThe maximum time (in clock ticks) to wait for an event. If CLOCKS_NEVER, it waits forever.
Returns
On success, the events that occurred. On timeout, 0. On failure, the POLLERR event bit is set and errno is set.

Definition at line 8 of file poll1.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ stat()

uint64_t stat ( const char *  path,
stat_t stat 
)

System call for retrieving info about a file or directory.

Parameters
pathThe path to the file or directory.
statA pointer to a stat_t structure where the file information will be stored.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 8 of file stat.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ioctl()

uint64_t ioctl ( fd_t  fd,
uint64_t  request,
void *  argp,
size_t  size 
)

System call for extended driver behaviour.

The ioctl() function allows drivers to implement unusual behaviour that would be impossible or impractical with a normal file-based API.

Parameters
fdThe file descriptor of the file.
requestThe driver-dependent request code.
argpA pointer to an argument that depends on the request, can be NULL if size is 0.
sizeThe size of the argument pointed to by argp.
Returns
On success, the return value depends on the driver but is usually 0. On failure, ERR and errno is set.

Definition at line 8 of file ioctl.c.

Here is the call graph for this function:

◆ dup()

fd_t dup ( fd_t  oldFd)

System call for duplicating file descriptors.

Parameters
oldFdThe open file descriptor to duplicate.
Returns
On success, the new file descriptor. On failure, ERR and errno is set.

Definition at line 8 of file dup.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ dup2()

fd_t dup2 ( fd_t  oldFd,
fd_t  newFd 
)

System call for duplicating file descriptors, with a destination.

Parameters
oldFdThe open file descriptor to duplicate.
newFdThe desired new file descriptor.
Returns
On success, the new file descriptor. On failure, ERR and errno is set.

Definition at line 8 of file dup2.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getdents()

size_t getdents ( fd_t  fd,
dirent_t buffer,
uint64_t  count 
)

System call for reading directory entires.

Parameters
fdThe file descriptor of the directory to read.
bufferThe destination buffer.
countThe size of the buffer in bytes.
Returns
On success, the total number of bytes written to the buffer. On failure, returns ERR and errno is set.

Definition at line 8 of file getdents.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ readdir()

size_t readdir ( fd_t  fd,
dirent_t **  buffer,
uint64_t count 
)

Helper for reading all directory entries.

The caller is responsible for freeing the returned pointer.

Parameters
fdThe file descriptor of the directory to read.
bufferOutput pointer to store the allocated buffer containing the directory entries.
countOutput pointer to store the number of bytes written to the buffer.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 8 of file readdir.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mkdir()

uint64_t mkdir ( const char *  path)

Wrapper for creating a directory.

Parameters
pathThe path of the directory to create.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 9 of file mkdir.c.

Here is the call graph for this function:

◆ rmdir()

uint64_t rmdir ( const char *  path)

Wrapper for removing a directory.

Parameters
pathThe path of the directory to remove.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 6 of file rmdir.c.

Here is the call graph for this function:

◆ link()

uint64_t link ( const char *  oldPath,
const char *  newPath 
)

System call for creating a hardlink.

Parameters
oldPath
newPath
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 8 of file link.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unlink()

uint64_t unlink ( const char *  path)

Wrapper for removing a file.

Parameters
pathThe path of the file to remove.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 5 of file unlink.c.

Here is the call graph for this function:

◆ share()

uint64_t share ( char *  key,
uint64_t  size,
fd_t  fd,
clock_t  timeout 
)

System call for sharing a file descriptor with another process.

Parameters
keyOutput buffer to store the generated key.
sizeThe size of the output buffer.
fdThe file descriptor to share.
timeoutThe time until the shared file descriptor expires. If CLOCKS_NEVER, it never expires.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 6 of file share.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ sharefile()

uint64_t sharefile ( char *  key,
uint64_t  size,
const char *  path,
clock_t  timeout 
)

Helper for sharing a file by its path.

Parameters
keyOutput buffer to store the generated key.
sizeThe size of the output buffer.
pathThe path to the file to share.
timeoutThe time until the shared file descriptor expires. If CLOCKS_NEVER, it never expires.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 4 of file sharefile.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ claim()

fd_t claim ( const char *  key)

System call for claiming a shared file descriptor.

After claiming a shared file descriptor, the key is no longer valid and cannot be used again.

Parameters
keyThe key identifying the shared file descriptor.
Returns
On success, the claimed file descriptor. On failure, ERR and errno is set.

Definition at line 6 of file claim.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ bind()

uint64_t bind ( const char *  mountpoint,
fd_t  source 
)

System call for binding a file descriptor to a mountpoint.

The created mount will inherit permissions from the source while the mount behaviour will follow the flags specified in mountpoint.

Parameters
mountpointThe mountpoint path.
sourceThe file descriptor to bind, must represent a directory.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 5 of file bind.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ mount()

uint64_t mount ( const char *  mountpoint,
const char *  fs,
const char *  options 
)

System call for mounting a filesystem.

Parameters
mountpointThe target path to mount to.
fsThe path to the desired filesystem in the fs sysfs directory.
optionsA string containing filesystem defined key=value pairs, with multiple options separated by commas, or NULL.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 5 of file mount.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unmount()

uint64_t unmount ( const char *  mountpoint)

System call for unmounting a filesystem.

Parameters
mountpointThe target path to unmount.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 5 of file unmount.c.

Here is the call graph for this function:

◆ readlink()

size_t readlink ( const char *  path,
char *  buffer,
uint64_t  count 
)

System call for reading the target of a symbolic link.

Parameters
pathThe path to the symbolic link.
bufferA buffer to store the target path.
countThe size of the buffer.
Returns
On success, the number of bytes read. On failure, ERR and errno is set.

Definition at line 8 of file readlink.c.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ symlink()

uint64_t symlink ( const char *  target,
const char *  linkpath 
)

System call for creating a symbolic link.

Parameters
targetThe target path of the symbolic link.
linkpathThe path where the symbolic link will be created.
Returns
On success, 0. On failure, ERR and errno is set.

Definition at line 8 of file symlink.c.

Here is the call graph for this function:
Here is the caller graph for this function: