Class Syscalls
Defined in File Syscalls.h
Class Documentation
-
class Syscalls
A wrapper class for common system calls with error checking.
Public Static Functions
-
static int open(const char *file, int oflag)
Wraps the open system call with error checking.
- Parameters:
file – The path to the file.
oflag – The flags for opening the file.
- Throws:
ExpKitError – if the system call fails.
- Returns:
The file descriptor.
-
static void read(fd fd, void *buf, size_t n)
Wraps the read system call with error checking.
- Parameters:
fd – The file descriptor to read from.
buf – The buffer to store the read data.
n – The number of bytes to read.
- Throws:
ExpKitError – if the system call fails or reads an unexpected number of bytes.
-
static void write(fd fd, const void *buf, size_t n)
Wraps the write system call with error checking.
- Parameters:
fd – The file descriptor to write to.
buf – The buffer containing the data to write.
n – The number of bytes to write.
- Throws:
ExpKitError – if the system call fails or writes an unexpected number of bytes.
-
static int ioctl(int fd, unsigned long int request, void *arg)
Wraps the ioctl system call with error checking.
- Parameters:
fd – The file descriptor.
request – The ioctl request.
arg – The argument for the ioctl request.
- Throws:
ExpKitError – if the system call fails.
- Returns:
The result of the ioctl system call.
-
static void close(fd fd)
Wraps the close system call with error checking.
- Parameters:
fd – The file descriptor to close.
- Throws:
ExpKitError – if the system call fails.
-
static void pipe(pipefds pipefds)
Wraps the pipe system call with error checking.
- Parameters:
pipefds – An array to hold the file descriptors for the read and write ends of the pipe.
- Throws:
ExpKitError – if the system call fails.
-
static struct stat stat(const char *path)
Wraps the stat() system call with error checking.
- Parameters:
path – The path argument passed to the stat() syscall.
- Throws:
ExpKitError – if the system call fails.
Wraps the unshare() system call with error checking.
- Parameters:
flags – The flags argument passed to the unshare() syscall.
- Throws:
ExpKitError – if the system call fails.
-
static std::string readlink(const char *path, size_t bufsize = 256)
Wraps the readlink() system call with error checking.
- Parameters:
path – The path argument passed to the unshare() syscall.
bufsize – Maximum expected size of the result path.
- Throws:
ExpKitError – if the system call fails or if the bufsize was not big enough.
-
static int open(const char *file, int oflag)