2020-01-18 09:38:21 +01:00
|
|
|
/*
|
2021-08-14 16:03:38 +02:00
|
|
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
2020-01-18 09:38:21 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
|
2018-10-14 22:57:41 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
2020-08-08 17:32:34 +02:00
|
|
|
#include <AK/DistinctNumeric.h>
|
2019-04-06 14:29:29 +02:00
|
|
|
#include <AK/Types.h>
|
2021-08-14 18:52:14 +02:00
|
|
|
#include <Kernel/API/POSIX/dirent.h>
|
2021-08-14 15:36:26 +02:00
|
|
|
#include <Kernel/API/POSIX/fcntl.h>
|
2021-08-14 17:12:54 +02:00
|
|
|
#include <Kernel/API/POSIX/futex.h>
|
2021-08-14 18:06:44 +02:00
|
|
|
#include <Kernel/API/POSIX/net/if.h>
|
|
|
|
|
#include <Kernel/API/POSIX/net/if_arp.h>
|
|
|
|
|
#include <Kernel/API/POSIX/net/route.h>
|
2021-08-14 16:53:38 +02:00
|
|
|
#include <Kernel/API/POSIX/netinet/in.h>
|
2021-08-14 18:28:05 +02:00
|
|
|
#include <Kernel/API/POSIX/serenity.h>
|
2021-08-14 17:05:53 +02:00
|
|
|
#include <Kernel/API/POSIX/signal.h>
|
2021-08-14 16:03:38 +02:00
|
|
|
#include <Kernel/API/POSIX/sys/mman.h>
|
2021-08-14 16:34:29 +02:00
|
|
|
#include <Kernel/API/POSIX/sys/socket.h>
|
2021-08-14 15:42:24 +02:00
|
|
|
#include <Kernel/API/POSIX/sys/stat.h>
|
2021-08-14 16:34:29 +02:00
|
|
|
#include <Kernel/API/POSIX/sys/un.h>
|
2021-08-14 18:55:39 +02:00
|
|
|
#include <Kernel/API/POSIX/sys/utsname.h>
|
2021-08-14 18:18:30 +02:00
|
|
|
#include <Kernel/API/POSIX/sys/wait.h>
|
2021-08-14 16:14:32 +02:00
|
|
|
#include <Kernel/API/POSIX/termios.h>
|
2021-08-14 15:42:24 +02:00
|
|
|
#include <Kernel/API/POSIX/time.h>
|
2020-05-28 17:52:02 +03:00
|
|
|
|
|
|
|
|
// Kernel internal options.
|
|
|
|
|
#define O_NOFOLLOW_NOERROR (1 << 29)
|
|
|
|
|
#define O_UNLINK_INTERNAL (1 << 30)
|
|
|
|
|
|
|
|
|
|
#define MS_NODEV (1 << 0)
|
|
|
|
|
#define MS_NOEXEC (1 << 1)
|
|
|
|
|
#define MS_NOSUID (1 << 2)
|
|
|
|
|
#define MS_BIND (1 << 3)
|
2020-05-28 17:56:25 +03:00
|
|
|
#define MS_RDONLY (1 << 4)
|
2020-05-28 21:12:13 +03:00
|
|
|
#define MS_REMOUNT (1 << 5)
|
2020-05-28 17:52:02 +03:00
|
|
|
|
2020-07-14 16:41:59 -04:00
|
|
|
enum {
|
2021-06-04 01:45:04 +02:00
|
|
|
_SC_MONOTONIC_CLOCK,
|
2020-07-14 16:41:59 -04:00
|
|
|
_SC_NPROCESSORS_CONF,
|
|
|
|
|
_SC_NPROCESSORS_ONLN,
|
2021-01-18 09:51:21 +01:00
|
|
|
_SC_OPEN_MAX,
|
|
|
|
|
_SC_TTY_NAME_MAX,
|
2021-01-29 20:28:19 +02:00
|
|
|
_SC_PAGESIZE,
|
2021-02-12 05:41:50 +03:30
|
|
|
_SC_GETPW_R_SIZE_MAX,
|
2021-03-16 11:05:23 -07:00
|
|
|
_SC_CLK_TCK,
|
2020-07-14 16:41:59 -04:00
|
|
|
};
|
|
|
|
|
|
2019-02-26 15:57:59 +01:00
|
|
|
#define R_OK 4
|
|
|
|
|
#define W_OK 2
|
|
|
|
|
#define X_OK 1
|
|
|
|
|
#define F_OK 0
|
|
|
|
|
|
2018-10-14 22:57:41 +02:00
|
|
|
#define SEEK_SET 0
|
|
|
|
|
#define SEEK_CUR 1
|
|
|
|
|
#define SEEK_END 2
|
|
|
|
|
|
2019-12-09 19:12:38 +01:00
|
|
|
#define MADV_SET_VOLATILE 0x100
|
|
|
|
|
#define MADV_SET_NONVOLATILE 0x200
|
|
|
|
|
|
2018-11-11 15:36:40 +01:00
|
|
|
#define F_DUPFD 0
|
|
|
|
|
#define F_GETFD 1
|
|
|
|
|
#define F_SETFD 2
|
|
|
|
|
#define F_GETFL 3
|
|
|
|
|
#define F_SETFL 4
|
2020-05-19 20:34:45 +03:00
|
|
|
#define F_ISTTY 5
|
2021-07-18 23:29:56 -06:00
|
|
|
#define F_GETLK 6
|
|
|
|
|
#define F_SETLK 7
|
|
|
|
|
#define F_SETLKW 8
|
2018-11-11 15:36:40 +01:00
|
|
|
|
2018-11-13 01:36:31 +01:00
|
|
|
#define FD_CLOEXEC 1
|
|
|
|
|
|
2020-08-08 17:32:34 +02:00
|
|
|
// Avoid interference with AK/Types.h and LibC/sys/types.h by defining *separate* names:
|
|
|
|
|
TYPEDEF_DISTINCT_ORDERED_ID(pid_t, ProcessID);
|
|
|
|
|
TYPEDEF_DISTINCT_ORDERED_ID(pid_t, ThreadID);
|
|
|
|
|
TYPEDEF_DISTINCT_ORDERED_ID(pid_t, SessionID);
|
|
|
|
|
TYPEDEF_DISTINCT_ORDERED_ID(pid_t, ProcessGroupID);
|
2018-12-03 01:12:26 +01:00
|
|
|
|
|
|
|
|
struct tms {
|
|
|
|
|
clock_t tms_utime;
|
|
|
|
|
clock_t tms_stime;
|
|
|
|
|
clock_t tms_cutime;
|
|
|
|
|
clock_t tms_cstime;
|
|
|
|
|
};
|
2018-10-17 10:55:43 +02:00
|
|
|
|
2021-03-13 22:02:54 +01:00
|
|
|
typedef i64 off_t;
|
2020-01-27 10:56:04 +01:00
|
|
|
typedef i64 time_t;
|
2018-10-17 10:55:43 +02:00
|
|
|
|
2019-07-03 21:17:35 +02:00
|
|
|
typedef u32 blksize_t;
|
|
|
|
|
typedef u32 blkcnt_t;
|
2018-10-14 22:57:41 +02:00
|
|
|
|
2019-05-28 11:53:16 +02:00
|
|
|
#define POLLIN (1u << 0)
|
2020-11-29 16:05:27 -07:00
|
|
|
#define POLLPRI (1u << 1)
|
|
|
|
|
#define POLLOUT (1u << 2)
|
|
|
|
|
#define POLLERR (1u << 3)
|
|
|
|
|
#define POLLHUP (1u << 4)
|
|
|
|
|
#define POLLNVAL (1u << 5)
|
|
|
|
|
#define POLLRDHUP (1u << 13)
|
2019-01-23 07:27:41 +01:00
|
|
|
|
|
|
|
|
struct pollfd {
|
2019-05-28 11:53:16 +02:00
|
|
|
int fd;
|
2019-01-23 07:27:41 +01:00
|
|
|
short events;
|
|
|
|
|
short revents;
|
|
|
|
|
};
|
2019-02-14 14:17:38 +01:00
|
|
|
|
2019-07-03 21:17:35 +02:00
|
|
|
typedef u32 __u32;
|
|
|
|
|
typedef u16 __u16;
|
|
|
|
|
typedef u8 __u8;
|
2019-04-06 14:29:29 +02:00
|
|
|
typedef int __s32;
|
|
|
|
|
typedef short __s16;
|
|
|
|
|
|
2019-07-03 21:17:35 +02:00
|
|
|
typedef u32 useconds_t;
|
|
|
|
|
typedef i32 suseconds_t;
|
2019-04-06 14:29:29 +02:00
|
|
|
|
|
|
|
|
struct timeval {
|
|
|
|
|
time_t tv_sec;
|
|
|
|
|
suseconds_t tv_usec;
|
|
|
|
|
};
|
|
|
|
|
|
2019-05-10 03:19:25 +02:00
|
|
|
struct iovec {
|
|
|
|
|
void* iov_base;
|
|
|
|
|
size_t iov_len;
|
|
|
|
|
};
|
2019-05-29 23:20:51 +02:00
|
|
|
|
|
|
|
|
struct sched_param {
|
|
|
|
|
int sched_priority;
|
|
|
|
|
};
|
2019-09-23 19:06:03 +02:00
|
|
|
|
2019-11-10 13:47:02 +01:00
|
|
|
#define AT_FDCWD -100
|
2021-05-14 20:34:31 +02:00
|
|
|
#define AT_SYMLINK_NOFOLLOW 0x100
|
2019-11-10 13:47:02 +01:00
|
|
|
|
2020-03-28 11:47:16 +03:00
|
|
|
#define PT_TRACE_ME 1
|
|
|
|
|
#define PT_ATTACH 2
|
|
|
|
|
#define PT_CONTINUE 3
|
|
|
|
|
#define PT_SYSCALL 4
|
|
|
|
|
#define PT_GETREGS 5
|
|
|
|
|
#define PT_DETACH 6
|
2020-04-04 11:26:56 +03:00
|
|
|
#define PT_PEEK 7
|
2020-04-05 22:58:44 +03:00
|
|
|
#define PT_POKE 8
|
2020-04-07 18:23:37 +03:00
|
|
|
#define PT_SETREGS 9
|
2021-04-15 12:34:51 -04:00
|
|
|
#define PT_POKEDEBUG 10
|
|
|
|
|
#define PT_PEEKDEBUG 11
|
2020-08-28 16:15:51 +03:00
|
|
|
|
2021-05-19 11:31:43 +02:00
|
|
|
typedef uint64_t fsblkcnt_t;
|
|
|
|
|
typedef uint64_t fsfilcnt_t;
|
|
|
|
|
|
|
|
|
|
#define ST_RDONLY 0x1
|
|
|
|
|
#define ST_NOSUID 0x2
|
|
|
|
|
|
|
|
|
|
struct statvfs {
|
|
|
|
|
unsigned long f_bsize;
|
|
|
|
|
unsigned long f_frsize;
|
|
|
|
|
fsblkcnt_t f_blocks;
|
|
|
|
|
fsblkcnt_t f_bfree;
|
|
|
|
|
fsblkcnt_t f_bavail;
|
|
|
|
|
|
|
|
|
|
fsfilcnt_t f_files;
|
|
|
|
|
fsfilcnt_t f_ffree;
|
|
|
|
|
fsfilcnt_t f_favail;
|
|
|
|
|
|
|
|
|
|
unsigned long f_fsid;
|
|
|
|
|
unsigned long f_flag;
|
|
|
|
|
unsigned long f_namemax;
|
|
|
|
|
};
|