Program Listing for File Syscalls.h
↰ Return to documentation for file (/home/runner/work/kernel-research/kernel-research/libxdk/include/xdk/util/Syscalls.h)
/*
* Copyright 2025 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#pragma once
#include <fcntl.h>
#include <keyutils.h>
#include <unistd.h>
#include <sys/ipc.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <sys/msg.h>
#include <sys/socket.h>
#include <string>
typedef int fd;
typedef fd pipefds[2];
class Syscalls {
static void __check(int result, int expected = 0,
const char* syscall_name = __builtin_FUNCTION());
template <typename T>
static T __check_valid(T result,
const char* syscall_name = __builtin_FUNCTION());
public:
static int open(const char* file, int oflag);
static void read(fd fd, void* buf, size_t n);
static void write(fd fd, const void* buf, size_t n);
static int ioctl(int fd, unsigned long int request, void* arg);
static void close(fd fd);
static void pipe(pipefds pipefds);
static struct stat stat(const char* path);
static void unshare(int flags);
static std::string readlink(const char* path, size_t bufsize = 256);
};