ArvernOS
Loading...
Searching...
No Matches
syscall.h File Reference
#include <arpa/inet.h>
#include <errno.h>
#include <stdint.h>
#include <stdio.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h>
Include dependency graph for syscall.h:
This graph shows which files directly or indirectly include this file:

Functions

int test (const char *s)
 
ssize_t write (int fd, const void *buf, size_t count)
 
ssize_t read (int fd, void *buf, size_t count)
 
int fstat (int fd, struct stat *statbuf)
 
off_t lseek (int fd, off_t offset, int whence)
 
int gettimeofday (struct timeval *p, void *z)
 
int open (const char *pathname, uint32_t flags)
 
int close (int fd)
 
int reboot (int command)
 
int socket (int domain, int type, int protocol)
 
ssize_t sendto (int sockfd, const void *buf, size_t len, int flags, const struct sockaddr *dst_addr, socklen_t addrlen)
 
ssize_t recvfrom (int sockfd, void *buf, size_t len, int flags, struct sockaddr *src_addr, socklen_t *addrlen)
 
int gethostbyname2 (const char *name, struct in_addr *in)
 
int execv (const char *path, char *const argv[])
 
pid_t getpid ()
 
void exit (int code)
 
int openat (int dirfd, const char *pathname, int flags)
 

Function Documentation

◆ close()

int close ( int fd)

Implements the close syscall.

Parameters
fda file descriptor ID
Returns
zero on success, -1 otherwise

◆ execv()

int execv ( const char * path,
char *const argv[] )

Implements the execv syscall.

Parameters
paththe name of a file that is to be executed
argva list of one or more pointers to null-terminated strings that represent the argument list available to the executed program
Returns
only return if an error has occurred

◆ exit()

void exit ( int code)

Implements the exit syscall.

Parameters
codethe status code

◆ fstat()

int fstat ( int fd,
struct stat * statbuf )

Implements the fstat syscall.

Parameters
fda file descriptor ID
statbufa stat structure
Returns
0 on success or -1 in case of an error

◆ gethostbyname2()

int gethostbyname2 ( const char * name,
struct in_addr * in )

Implements the gethostbyname2 syscall. Most existing systems don't have such a syscall but we do and it performs a DNS lookup.

Parameters
namea hostname
inthe receiving Internet address
Returns
0 on success, a non-zero value otherwise

◆ getpid()

pid_t getpid ( )

Implements the getpid syscall.

Returns
the process ID (PID) of the calling process

◆ gettimeofday()

int gettimeofday ( struct timeval * p,
void * z )

Implements the gettimeofday syscall.

◆ lseek()

off_t lseek ( int fd,
off_t offset,
int whence )

Implements the lseek syscall.

Parameters
fda file descriptor ID
offsetthe offset value
whencea directive to reposition the offset
Returns
the value of the offset on success or -1 in case of an error

◆ open()

int open ( const char * pathname,
uint32_t flags )

Implements the open syscall.

Parameters
pathnamethe name of the file to open
flagscreation or file status flags
Returns
a file descriptor, i.e. a small, non-negative integer that is used in subsequent system calls

◆ openat()

int openat ( int dirfd,
const char * pathname,
int flags )

Implements the openat syscall.

Parameters
dirfda directory file descriptor
pathnamethe name of the file to open
flagscreation or file status flags
Returns
a file descriptor, i.e. a small, non-negative integer that is used in subsequent system calls

◆ read()

ssize_t read ( int fd,
void * buf,
size_t count )

Implements the read syscall. read() attempts to read up to count bytes from file descriptor fd into the buffer starting at buf.

Parameters
fda file descriptor ID
bufa buffer that receives the bytes read
countthe maximum number of bytes to read
Returns
the actual number of bytes read or -1 in case of an error

◆ reboot()

int reboot ( int command)

Implements the reboot syscall.

Parameters
commanda reboot command
Returns
when command is REBOOT_CMD_RESTART, it does not return. -1 is returned in case of an error, 0 otherwise.

◆ recvfrom()

ssize_t recvfrom ( int sockfd,
void * buf,
size_t len,
int flags,
struct sockaddr * src_addr,
socklen_t * addrlen )

Implements the recvfrom syscall.

Parameters
sockfdsocket descriptor ID
bufthe receiving buffer
lenthe size of the receiving buffer
flagssome flags
src_addrthe address of the sender
addrlenthe size of the sender address structure
Returns
the number of bytes actually received

◆ sendto()

ssize_t sendto ( int sockfd,
const void * buf,
size_t len,
int flags,
const struct sockaddr * dst_addr,
socklen_t addrlen )

Implements the sendto syscall.

Parameters
sockfdsocket descriptor ID
bufthe data to send
lenthe length of the data to send
flagssome flags
dst_addrthe destination address
addrlenthe size of the destination address structure
Returns
the number of bytes sent to the destination

◆ socket()

int socket ( int domain,
int type,
int protocol )

Implements the socket syscall.

Parameters
domainthe communication domain (we only support AF_INET so far)
typethe communication semantics (we only support SOCK_DGRAM so far)
protocolthe particular protocol to be used with the socket
Returns
a file descriptor on success, -1 otherwise

◆ test()

int test ( const char * s)

Implements a syscall for testing purpose only. It takes a string as input and prints it to the screen.

Parameters
sa string to print on the screen
Returns
the return value should always be 42

◆ write()

ssize_t write ( int fd,
const void * buf,
size_t count )

Implements the write syscall.

Parameters
fda file descriptor ID
bufa buffer that contains the bytes to write
countthe maximum number of bytes to write
Returns
the actual number of bytes write or -1 in case of an error