diff --git a/ext2_root/usr/include/abi-bits/ioctls.h b/ext2_root/usr/include/abi-bits/ioctls.h new file mode 100644 index 0000000..d33a41e --- /dev/null +++ b/ext2_root/usr/include/abi-bits/ioctls.h @@ -0,0 +1,20 @@ +#ifndef _ABIBITS_IOCTLS_H +#define _ABIBITS_IOCTLS_H + +#define TIOCEXCL 0x540C +#define TIOCNXCL 0x540D + +#define SIOCPROTOPRIVATE 0x89E0 +#define SIOCGSTAMP 0x8906 +#define SIOCGIFNAME 0x8910 +#define SIOCGIFCONF 0x8912 +#define SIOCGIFFLAGS 0x8913 +#define SIOCSIFFLAGS 0x8914 +#define SIOCGIFADDR 0x8915 +#define SIOCGIFINDEX 0x8933 +#define SIOCATMARK 0x8905 +#define SIOCGIFHWADDR 0x8927 +#define SIOCGIFBRDADDR 0x8919 +#define SIOCGIFNETMASK 0x891B + +#endif /* _ABIBITS_IOCTLS_H */ \ No newline at end of file diff --git a/ext2_root/usr/include/abi-bits/statx.h b/ext2_root/usr/include/abi-bits/statx.h new file mode 100755 index 0000000..63160db --- /dev/null +++ b/ext2_root/usr/include/abi-bits/statx.h @@ -0,0 +1,77 @@ +#ifndef _ABIBITS_STATX_H +#define _ABIBITS_STATX_H + +#include + +#if !__MLIBC_LINUX_OPTION +# error "statx() is inherently Linux specific. Enable the Linux option or do not use this header." +#endif /* !__MLIBC_LINUX_OPTION */ + +#include + +struct statx_timestamp { + __mlibc_int64 tv_sec; + __mlibc_uint32 tv_nsec; + __mlibc_uint32 __padding; +}; + +#define STATX_TYPE 0x1 +#define STATX_MODE 0x2 +#define STATX_NLINK 0x4 +#define STATX_UID 0x8 +#define STATX_GID 0x10 +#define STATX_ATIME 0x20 +#define STATX_MTIME 0x40 +#define STATX_CTIME 0x80 +#define STATX_INO 0x100 +#define STATX_SIZE 0x200 +#define STATX_BLOCKS 0x400 +#define STATX_BASIC_STATS 0x7ff +#define STATX_BTIME 0x800 +#define STATX_MNT_ID 0x1000 +#define STATX_DIOALIGN 0x2000 +#define STATX_ALL 0xfff + +#define STATX_ATTR_COMPRESSED 0x4 +#define STATX_ATTR_IMMUTABLE 0x10 +#define STATX_ATTR_APPEND 0x20 +#define STATX_ATTR_NODUMP 0x40 +#define STATX_ATTR_ENCRYPTED 0x800 +#define STATX_ATTR_AUTOMOUNT 0x1000 +#define STATX_ATTR_MOUNT_ROOT 0x2000 +#define STATX_ATTR_VERITY 0x100000 +#define STATX_ATTR_DAX 0x200000 + +struct statx { + __mlibc_uint32 stx_mask; + + __mlibc_uint32 stx_blksize; + __mlibc_uint64 stx_attributes; + __mlibc_uint32 stx_nlink; + __mlibc_uint32 stx_uid; + __mlibc_uint32 stx_gid; + __mlibc_uint16 stx_mode; + __mlibc_uint16 __padding; + __mlibc_uint64 stx_ino; + __mlibc_uint64 stx_size; + __mlibc_uint64 stx_blocks; + __mlibc_uint64 stx_attributes_mask; + + struct statx_timestamp stx_atime; + struct statx_timestamp stx_btime; + struct statx_timestamp stx_ctime; + struct statx_timestamp stx_mtime; + + __mlibc_uint32 stx_rdev_major; + __mlibc_uint32 stx_rdev_minor; + __mlibc_uint32 stx_dev_major; + __mlibc_uint32 stx_dev_minor; + + __mlibc_uint64 stx_mnt_id; + __mlibc_uint32 stx_dio_mem_align; + __mlibc_uint32 stx_dio_offset_align; + + __mlibc_uint64 __padding1[12]; +}; + +#endif \ No newline at end of file diff --git a/ext2_root/usr/include/bits/linux/cpu_set.h b/ext2_root/usr/include/bits/linux/cpu_set.h new file mode 100644 index 0000000..0eff228 --- /dev/null +++ b/ext2_root/usr/include/bits/linux/cpu_set.h @@ -0,0 +1,49 @@ +#ifndef _BITS_LINUX_CPU_SET_H +#define _BITS_LINUX_CPU_SET_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include +#include + +#ifndef __MLIBC_ABI_ONLY + +cpu_set_t *__mlibc_cpu_alloc(int __num_cpus); +size_t __mlibc_cpu_alloc_size(int __num_cpus); + +void __mlibc_cpu_zero(const size_t __setsize, cpu_set_t *__set); +void __mlibc_cpu_set(const int __cpu, const size_t __setsize, cpu_set_t *__set); +void __mlibc_cpu_clear(const int __cpu, const size_t __setsize, cpu_set_t *__set); +int __mlibc_cpu_isset(const int __cpu, const size_t __setsize, const cpu_set_t *__set); +int __mlibc_cpu_count(const size_t __setsize, const cpu_set_t *__set); + +#define CPU_ALLOC_SIZE(n) __mlibc_cpu_alloc_size((n)) +#define CPU_ALLOC(n) __mlibc_cpu_alloc((n)) +#define CPU_FREE(set) free((set)) + +#define CPU_ZERO_S(setsize, set) __mlibc_cpu_zero((setsize), (set)) +#define CPU_ZERO(set) CPU_ZERO_S(sizeof(cpu_set_t), set) + +#define CPU_SET_S(cpu, setsize, set) __mlibc_cpu_set((cpu), (setsize), (set)) +#define CPU_SET(cpu, set) CPU_SET_S(cpu, sizeof(cpu_set_t), set) + +#define CPU_CLR_S(cpu, setsize, set) __mlibc_cpu_clear((cpu), (setsize), (set)) +#define CPU_CLR(cpu, set) CPU_CLR_S(cpu, sizeof(cpu_set_t), set) + +#define CPU_ISSET_S(cpu, setsize, set) __mlibc_cpu_isset((cpu), (setsize), (set)) +#define CPU_ISSET(cpu, set) CPU_ISSET_S(cpu, sizeof(cpu_set_t), set) + +#define CPU_COUNT_S(setsize, set) __mlibc_cpu_count((setsize), (set)) +#define CPU_COUNT(set) CPU_COUNT_S(sizeof(cpu_set_t), set) + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* _BITS_LINUX_CPU_SET_H */ diff --git a/ext2_root/usr/include/bits/linux/linux_sched.h b/ext2_root/usr/include/bits/linux/linux_sched.h new file mode 100644 index 0000000..05f8eca --- /dev/null +++ b/ext2_root/usr/include/bits/linux/linux_sched.h @@ -0,0 +1,63 @@ + +#ifndef _BITS_LINUX_SCHED_H +#define _BITS_LINUX_SCHED_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#define CLONE_VM 0x00000100 +#define CLONE_FS 0x00000200 +#define CLONE_FILES 0x00000400 +#define CLONE_SIGHAND 0x00000800 +#define CLONE_PIDFD 0x00001000 +#define CLONE_PTRACE 0x00002000 +#define CLONE_VFORK 0x00004000 +#define CLONE_PARENT 0x00008000 +#define CLONE_THREAD 0x00010000 +#define CLONE_NEWNS 0x00020000 +#define CLONE_SYSVSEM 0x00040000 +#define CLONE_SETTLS 0x00080000 +#define CLONE_PARENT_SETTID 0x00100000 +#define CLONE_CHILD_CLEARTID 0x00200000 +#define CLONE_DETACHED 0x00400000 +#define CLONE_UNTRACED 0x00800000 +#define CLONE_CHILD_SETTID 0x01000000 +#define CLONE_NEWCGROUP 0x02000000 +#define CLONE_NEWUTS 0x04000000 +#define CLONE_NEWIPC 0x08000000 +#define CLONE_NEWUSER 0x10000000 +#define CLONE_NEWPID 0x20000000 +#define CLONE_NEWNET 0x40000000 +#define CLONE_IO 0x80000000 + +#define CLONE_CLEAR_SIGHAND 0x100000000ULL +#define CLONE_INTO_CGROUP 0x200000000ULL + +#ifndef __MLIBC_ABI_ONLY + +int sched_getscheduler(pid_t __pid); +int sched_setaffinity(pid_t __pid, size_t __cpusetsize, const cpu_set_t *__mask); +int sched_getaffinity(pid_t __pid, size_t __cpusetsize, cpu_set_t *__mask); + +int unshare(int flags); +int clone(int (*)(void *), void *, int, void *, ...); + +/* Glibc extension */ +int sched_getcpu(void); + +#if defined(_GNU_SOURCE) +int setns(int fd, int nstype); +#endif /* _GNU_SOURCE */ + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* _BITS_LINUX_SCHED_H */ diff --git a/ext2_root/usr/include/bits/linux/linux_stat.h b/ext2_root/usr/include/bits/linux/linux_stat.h new file mode 100644 index 0000000..eeaaeff --- /dev/null +++ b/ext2_root/usr/include/bits/linux/linux_stat.h @@ -0,0 +1,20 @@ +#ifndef _BITS_LINUX_STAT_H +#define _BITS_LINUX_STAT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifndef __MLIBC_ABI_ONLY + +int statx(int __dirfd, const char *__pathname, int __flags, unsigned int __mask, struct statx *__statxbuf); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* _BITS_LINUX_STAT_H */ diff --git a/ext2_root/usr/include/bits/linux/linux_uio.h b/ext2_root/usr/include/bits/linux/linux_uio.h new file mode 100644 index 0000000..9a90b58 --- /dev/null +++ b/ext2_root/usr/include/bits/linux/linux_uio.h @@ -0,0 +1,30 @@ +#ifndef _BITS_LINUX_UIO_H +#define _BITS_LINUX_UIO_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __MLIBC_ABI_ONLY + +ssize_t process_vm_readv(pid_t pid, + const struct iovec *local_iov, unsigned long liovcnt, + const struct iovec *remote_iov, unsigned long riovcnt, + unsigned long flags); +ssize_t process_vm_writev(pid_t pid, + const struct iovec *local_iov, unsigned long liovcnt, + const struct iovec *remote_iov, unsigned long riovcnt, + unsigned long flags); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* _BITS_LINUX_UIO_H */ diff --git a/ext2_root/usr/include/bits/linux/linux_unistd.h b/ext2_root/usr/include/bits/linux/linux_unistd.h new file mode 100644 index 0000000..7aa4103 --- /dev/null +++ b/ext2_root/usr/include/bits/linux/linux_unistd.h @@ -0,0 +1,21 @@ +#ifndef _BITS_LINUX_UNISTD_H +#define _BITS_LINUX_UNISTD_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __MLIBC_ABI_ONLY + +int dup3(int __fd, int __newfd, int __flags); +int vhangup(void); +int getdtablesize(void); +int syncfs(int __fd); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* _BITS_LINUX_UNISTD_H */ diff --git a/ext2_root/usr/include/bits/linux/linux_utmp.h b/ext2_root/usr/include/bits/linux/linux_utmp.h new file mode 100644 index 0000000..40ea2c6 --- /dev/null +++ b/ext2_root/usr/include/bits/linux/linux_utmp.h @@ -0,0 +1,71 @@ +#ifndef _BITS_LINUX_UTMP_H +#define _BITS_LINUX_UTMP_H + +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define UT_LINESIZE 32 +#define UT_NAMESIZE 32 +#define UT_HOSTSIZE 256 + +#define UTMP_FILENAME UTMP_FILE +#define WTMP_FILENAME WTMP_FILE + +struct exit_status { + short int e_termination; + short int e_exit; +}; + +struct utmp { + short ut_type; + pid_t ut_pid; + char ut_line[UT_LINESIZE]; + char ut_id[4]; + char ut_user[UT_NAMESIZE]; + char ut_host[UT_HOSTSIZE]; + struct exit_status ut_exit; + long ut_session; + struct timeval ut_tv; + __mlibc_int32 ut_addr_v6[4]; + char __unused[20]; +}; + +struct lastlog { + time_t ll_time; + char ll_line[UT_LINESIZE]; + char ll_host[UT_HOSTSIZE]; +}; + +/* Hacks for compability reasons */ +#define ut_name ut_user +#ifndef _NO_UT_TIME +#define ut_time ut_tv.tv_sec +#endif +#define ut_xtime ut_tv.tv_sec +#define ut_addr ut_addr_v6[0] + +#ifndef __MLIBC_ABI_ONLY + +void setutent(void); +struct utmp *getutent(void); +int getutent_r(struct utmp *__buf, struct utmp **__res); +void endutent(void); +struct utmp *pututline(const struct utmp *__line); +struct utmp *getutline(const struct utmp *__line); +struct utmp *getutid(const struct utmp *__id); +int utmpname(const char *__file); +void updwtmp(const char *wtmp_file, const struct utmp *ut); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* _BITS_LINUX_UTMP_H */ diff --git a/ext2_root/usr/include/ifaddrs.h b/ext2_root/usr/include/ifaddrs.h new file mode 100644 index 0000000..c57ff3d --- /dev/null +++ b/ext2_root/usr/include/ifaddrs.h @@ -0,0 +1,37 @@ + +#ifndef _IFADDRS_H +#define _IFADDRS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/* Struct definitions taken from musl */ +struct ifaddrs { + struct ifaddrs *ifa_next; + char *ifa_name; + unsigned ifa_flags; + struct sockaddr *ifa_addr; + struct sockaddr *ifa_netmask; + /* the man page (and glibc) place `ifa_broadaddr` and `ifa_dstaddr` in a union */ + /* TODO: decide whether we should do it, too */ + struct sockaddr *ifa_broadaddr; + struct sockaddr *ifa_dstaddr; + void *ifa_data; +}; + +#ifndef __MLIBC_ABI_ONLY + +int getifaddrs(struct ifaddrs **__ifap); +void freeifaddrs(struct ifaddrs *__ifa); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* _IFADDRS_H */ diff --git a/ext2_root/usr/include/lastlog.h b/ext2_root/usr/include/lastlog.h new file mode 100644 index 0000000..a10b0bb --- /dev/null +++ b/ext2_root/usr/include/lastlog.h @@ -0,0 +1,2 @@ +/* Maches glibc */ +#include \ No newline at end of file diff --git a/ext2_root/usr/include/malloc.h b/ext2_root/usr/include/malloc.h new file mode 100644 index 0000000..382dac2 --- /dev/null +++ b/ext2_root/usr/include/malloc.h @@ -0,0 +1,32 @@ + +#ifndef _MALLOC_H +#define _MALLOC_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +#ifndef __MLIBC_ABI_ONLY + +/* [7.22.3] Memory management functions */ +void *calloc(size_t __count, size_t __size); +void free(void *__pointer); +void *malloc(size_t __size); +void *realloc(void *__pointer, size_t __size); +void *memalign(size_t __alignment, size_t __size); + +#if __MLIBC_GLIBC_OPTION +#include +#endif + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* _MALLOC_H */ + diff --git a/ext2_root/usr/include/memory.h b/ext2_root/usr/include/memory.h index 39adee7..296f8ad 100644 --- a/ext2_root/usr/include/memory.h +++ b/ext2_root/usr/include/memory.h @@ -1,6 +1,9 @@ + #ifndef _MEMORY_H #define _MEMORY_H +/* This is a linux extension */ #include -#endif +#endif /* _MEMORY_H */ + diff --git a/ext2_root/usr/include/mlibc-config.h b/ext2_root/usr/include/mlibc-config.h index 6a7d44c..d921cbb 100644 --- a/ext2_root/usr/include/mlibc-config.h +++ b/ext2_root/usr/include/mlibc-config.h @@ -13,7 +13,7 @@ #define __MLIBC_BSD_OPTION 1 #define __MLIBC_POSIX_OPTION 1 -#define __MLIBC_LINUX_OPTION 0 +#define __MLIBC_LINUX_OPTION 1 #define __MLIBC_GLIBC_OPTION 1 #define __MLIBC_SYSDEP_HAS_BITS_SYSCALL_H 0 diff --git a/ext2_root/usr/include/mntent.h b/ext2_root/usr/include/mntent.h new file mode 100644 index 0000000..284c4b6 --- /dev/null +++ b/ext2_root/usr/include/mntent.h @@ -0,0 +1,50 @@ +#ifndef _MNTENT_H +#define _MNTENT_H + +#include + +/* TODO: Refer to _PATH_MOUNTED */ +#define MOUNTED "/etc/mtab" + +/* Generic mount options */ +#define MNTOPT_DEFAULTS "defaults" /* Use all default options. */ +#define MNTOPT_RO "ro" /* Read only. */ +#define MNTOPT_RW "rw" /* Read/write. */ +#define MNTOPT_SUID "suid" /* Set uid allowed. */ +#define MNTOPT_NOSUID "nosuid" /* No set uid allowed. */ +#define MNTOPT_NOAUTO "noauto" /* Do not auto mount. */ + +#ifdef __cplusplus +extern "C" { +#endif + +struct mntent { + char *mnt_fsname; + char *mnt_dir; + char *mnt_type; + char *mnt_opts; + int mnt_freq; + int mnt_passno; +}; + +#ifndef __MLIBC_ABI_ONLY + +FILE *setmntent(const char *__filename, const char *__type); + +struct mntent *getmntent(FILE *__f); + +int addmntent(FILE *__f, const struct mntent *__mnt); + +int endmntent(FILE *__f); + +char *hasmntopt(const struct mntent *__mnt, const char *__opt); + +struct mntent *getmntent_r(FILE *__f, struct mntent *__mnt, char *__linebuf, int __buflen); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* _MNTENT_H */ diff --git a/ext2_root/usr/include/module.h b/ext2_root/usr/include/module.h new file mode 100644 index 0000000..5d84f72 --- /dev/null +++ b/ext2_root/usr/include/module.h @@ -0,0 +1,25 @@ +#ifndef _MODULE_H +#define _MODULE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __MLIBC_ABI_ONLY + +/* + * Musl adds these, even though they aren't specified, but doesn't export them. + * See https://github.com/bminor/musl/commit/2169265ec6c902cd460bf96a1a0b5103657a4954 + * for more information and the rationale behind it. + * For our infrastructure, we expose them, and make it call into the sysdeps. + */ +int init_module(void *__module, unsigned long __len, const char *__args); +int delete_module(const char *__name, unsigned __flags); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* _MODULE_H */ diff --git a/ext2_root/usr/include/netpacket/packet.h b/ext2_root/usr/include/netpacket/packet.h new file mode 100644 index 0000000..495760f --- /dev/null +++ b/ext2_root/usr/include/netpacket/packet.h @@ -0,0 +1,40 @@ +#ifndef _NETPACKET_PACKET_H +#define _NETPACKET_PACKET_H + +#include + +/* Packet types */ +#define PACKET_HOST 0 +#define PACKET_BROADCAST 1 +#define PACKET_MULTICAST 2 +#define PACKET_OTHERHOST 3 +#define PACKET_OUTGOING 4 +#define PACKET_LOOPBACK 5 +#define PACKET_FASTROUTE 6 + +struct sockaddr_ll { + unsigned short int sll_family; + unsigned short int sll_protocol; + int sll_ifindex; + unsigned short int sll_hatype; + unsigned char sll_pkttype; + unsigned char sll_halen; + unsigned char sll_addr[8]; +}; + +struct packet_mreq { + int mr_ifindex; + unsigned short int mr_type; + unsigned short int mr_alen; + unsigned char mr_address[8]; +}; + +#define PACKET_ADD_MEMBERSHIP 1 +#define PACKET_DROP_MEMBERSHIP 2 + +#define PACKET_MR_MULTICAST 0 +#define PACKET_MR_PROMISC 1 +#define PACKET_MR_ALLMULTI 2 +#define PACKET_MR_UNICAST 3 + +#endif /* _NETPACKET_PACKET_H */ diff --git a/ext2_root/usr/include/scsi/scsi.h b/ext2_root/usr/include/scsi/scsi.h new file mode 100644 index 0000000..fd9cf82 --- /dev/null +++ b/ext2_root/usr/include/scsi/scsi.h @@ -0,0 +1,18 @@ + +#ifndef _LINUX_SCSI_SCSI_H +#define _LINUX_SCSI_SCSI_H + +#define RECOVERED_ERROR 0x01 +#define ILLEGAL_REQUEST 0x05 +#define UNIT_ATTENTION 0x06 +#define INQUIRY 0x12 +#define START_STOP 0x1b +#define ALLOW_MEDIUM_REMOVAL 0x1e + +#define SCSI_IOCTL_GET_IDLUN 0x5382 +#define SCSI_IOCTL_TAGGED_ENABLE 0x5383 +#define SCSI_IOCTL_TAGGED_DISABLE 0x5384 +#define SCSI_IOCTL_PROBE_HOST 0x5385 + +#endif /* _LINUX_SCSI_SCSI_H */ + diff --git a/ext2_root/usr/include/scsi/scsi_ioctl.h b/ext2_root/usr/include/scsi/scsi_ioctl.h new file mode 100644 index 0000000..888ae39 --- /dev/null +++ b/ext2_root/usr/include/scsi/scsi_ioctl.h @@ -0,0 +1,6 @@ + +#ifndef _LINUX_SCSI_SCSI_IOCTL_H +#define _LINUX_SCSI_SCSI_IOCTL_H + +#endif /* _LINUX_SCSI_SCSI_IOCTL_H */ + diff --git a/ext2_root/usr/include/scsi/sg.h b/ext2_root/usr/include/scsi/sg.h new file mode 100644 index 0000000..30288c9 --- /dev/null +++ b/ext2_root/usr/include/scsi/sg.h @@ -0,0 +1,79 @@ + +#ifndef _LINUX_SCSI_SG_H +#define _LINUX_SCSI_SG_H + +#define SG_IO 0x2285 + +#define SG_GET_VERSION_NUM 0x2282 + +#define SG_FLAG_DIRECT_IO 1 +#define SG_FLAG_LUN_INHIBIT 2 + +#define SG_INFO_OK 0x0 +#define SG_INFO_OK_MASK 0x1 + +#define SG_DXFER_NONE (-1) +#define SG_DXFER_TO_DEV (-2) +#define SG_DXFER_FROM_DEV (-3) +#define SG_DXFER_TO_FROM_DEV (-4) + +#define SG_INFO_CHECK 0x1 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct sg_io_hdr { + int interface_id; + int dxfer_direction; + unsigned char cmd_len; + unsigned char mx_sb_len; + unsigned short iovec_count; + unsigned int dxfer_len; + void *dxferp; + unsigned char *cmdp; + unsigned char *sbp; + unsigned int timeout; + unsigned int flags; + int pack_id; + void *usr_ptr; + unsigned char status; + unsigned char masked_status; + unsigned char msg_status; + unsigned char sb_len_wr; + unsigned short host_status; + unsigned short driver_status; + int resid; + unsigned int duration; + unsigned int info; +} sg_io_hdr_t; + +struct sg_scsi_id { + int host_no; + int channel; + int scsi_id; + int lun; + int scsi_type; + short int h_cmd_per_lun; + short int d_queue_depth; + int unused[2]; +}; + +typedef struct sg_req_info { + char req_state; + char orphan; + char sg_io_owned; + char problem; + int pack_id; + void *usr_ptr; + unsigned int duration; + + int unused; +} sg_req_info_t; + +#ifdef __cplusplus +} +#endif + +#endif /* _LINUX_SCSI_SG_H */ + diff --git a/ext2_root/usr/include/sys/epoll.h b/ext2_root/usr/include/sys/epoll.h new file mode 100644 index 0000000..aca9b13 --- /dev/null +++ b/ext2_root/usr/include/sys/epoll.h @@ -0,0 +1,66 @@ +#ifndef _SYS_EPOLL_H +#define _SYS_EPOLL_H + +#include +#include +#include +#include + +#define EPOLL_NONBLOCK O_NONBLOCK + +/* These constants match the Linux definitions. */ +#define EPOLLIN 0x001 +#define EPOLLPRI 0x002 +#define EPOLLOUT 0x004 +#define EPOLLRDNORM 0x040 +#define EPOLLRDBAND 0x080 +#define EPOLLWRNORM 0x100 +#define EPOLLWRBAND 0x200 +#define EPOLLMSG 0x400 +#define EPOLLERR 0x008 +#define EPOLLHUP 0x010 +#define EPOLLRDHUP 0x2000 +#define EPOLLEXCLUSIVE (1U << 28) +#define EPOLLWAKEUP (1U << 29) +#define EPOLLONESHOT (1U << 30) +#define EPOLLET (1U << 31) + +#define EPOLL_CTL_ADD 1 +#define EPOLL_CTL_DEL 2 +#define EPOLL_CTL_MOD 3 + +#ifdef __cplusplus +extern "C" { +#endif + +typedef union epoll_data { + void *ptr; + int fd; + uint32_t u32; + uint64_t u64; +} epoll_data_t; + +struct epoll_event { + uint32_t events; + epoll_data_t data; +} +#ifdef __x86_64__ +__attribute__((__packed__)) +#endif +; + +#ifndef __MLIBC_ABI_ONLY + +int epoll_create(int __flags); +int epoll_create1(int __flags); +int epoll_ctl(int __epfd, int __mode, int __fd, struct epoll_event *__ev); +int epoll_wait(int __epfd, struct epoll_event *__events, int __maxevents, int __timeout); +int epoll_pwait(int __epfd, struct epoll_event *__events, int __maxevents, int __timeout, const sigset_t *__sigmask); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_EPOLL_H */ diff --git a/ext2_root/usr/include/sys/eventfd.h b/ext2_root/usr/include/sys/eventfd.h new file mode 100644 index 0000000..74b200d --- /dev/null +++ b/ext2_root/usr/include/sys/eventfd.h @@ -0,0 +1,29 @@ +#ifndef _SYS_EVENTFD_H +#define _SYS_EVENTFD_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +typedef uint64_t eventfd_t; + +#define EFD_SEMAPHORE 1 +#define EFD_CLOEXEC O_CLOEXEC +#define EFD_NONBLOCK O_NONBLOCK + +#ifndef __MLIBC_ABI_ONLY + +int eventfd(unsigned int __initval, int __flags); +int eventfd_read(int __fd, eventfd_t *__value); +int eventfd_write(int __fd, eventfd_t __value); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_EVENTFD_H */ diff --git a/ext2_root/usr/include/sys/fsuid.h b/ext2_root/usr/include/sys/fsuid.h new file mode 100644 index 0000000..0fa0fb3 --- /dev/null +++ b/ext2_root/usr/include/sys/fsuid.h @@ -0,0 +1,22 @@ +#ifndef _SYS_FSUID_H +#define _SYS_FSUID_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __MLIBC_ABI_ONLY + +int setfsuid(uid_t __uid); +int setfsgid(gid_t __gid); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_FSUID_H */ diff --git a/ext2_root/usr/include/sys/inotify.h b/ext2_root/usr/include/sys/inotify.h new file mode 100644 index 0000000..bf9c7c5 --- /dev/null +++ b/ext2_root/usr/include/sys/inotify.h @@ -0,0 +1,71 @@ +#ifndef _SYS_INOTIFY_H +#define _SYS_INOTIFY_H + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define IN_ACCESS 0x1 +#define IN_ATTRIB 0x4 +#define IN_CLOSE_WRITE 0x8 +#define IN_CLOSE_NOWRITE 0x10 +#define IN_CREATE 0x100 +#define IN_DELETE 0x200 +#define IN_DELETE_SELF 0x400 +#define IN_MODIFY 0x2 +#define IN_MOVE_SELF 0x800 +#define IN_MOVED_FROM 0x40 +#define IN_MOVED_TO 0x80 +#define IN_OPEN 0x20 +#define IN_MOVE (IN_MOVED_FROM | IN_MOVED_TO) +#define IN_CLOSE (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE) +#define IN_DONT_FOLLOW 0x2000000 +#define IN_EXCL_UNLINK 0x4000000 +#define IN_MASK_ADD 0x20000000 +#define IN_ONESHOT 0x80000000 +#define IN_ONLYDIR 0x1000000 +#define IN_IGNORED 0x8000 +#define IN_ISDIR 0x40000000 +#define IN_Q_OVERFLOW 0x4000 +#define IN_UNMOUNT 0x2000 + +#define IN_ALL_EVENTS (IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | \ + IN_CLOSE_NOWRITE | IN_OPEN | IN_MOVED_FROM | \ + IN_MOVED_TO | IN_DELETE | IN_CREATE | IN_DELETE_SELF | \ + IN_MOVE_SELF) + +struct inotify_event { + int wd; + unsigned int mask; + unsigned int cookie; + unsigned int len; + +/* + * glibc uses a flexible array member here, but we get a warning and they don't: + * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=117241 + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpedantic" + char name[]; +#pragma GCC diagnostic pop +}; + +#ifndef __MLIBC_ABI_ONLY + +int inotify_init(void); +int inotify_init1(int __flags); +int inotify_add_watch(int __ifd, const char *__path, uint32_t __mask); +int inotify_rm_watch(int __ifd, int __wd); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /*_SYS_INOTIFY_H */ + diff --git a/ext2_root/usr/include/sys/klog.h b/ext2_root/usr/include/sys/klog.h new file mode 100644 index 0000000..f5bd628 --- /dev/null +++ b/ext2_root/usr/include/sys/klog.h @@ -0,0 +1,18 @@ +#ifndef _SYS_KLOG_H +#define _SYS_KLOG_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __MLIBC_ABI_ONLY + +int klogctl(int __type, char *__bufp, int __len); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_KLOG_H */ diff --git a/ext2_root/usr/include/sys/mount.h b/ext2_root/usr/include/sys/mount.h new file mode 100644 index 0000000..8be8857 --- /dev/null +++ b/ext2_root/usr/include/sys/mount.h @@ -0,0 +1,90 @@ +#ifndef _SYS_MOUNT_H +#define _SYS_MOUNT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define MS_RDONLY 1 +#define MS_NOSUID 2 +#define MS_NODEV 4 +#define MS_NOEXEC 8 +#define MS_SYNCHRONOUS 16 +#define MS_REMOUNT 32 +#define MS_MANDLOCK 64 +#define MS_DIRSYNC 128 +#define MS_NOSYMFOLLOW 256 +#define MS_NOATIME 1024 +#define MS_NODIRATIME 2048 +#define MS_BIND 4096 +#define MS_MOVE 8192 +#define MS_REC 16384 +#define MS_SILENT 32768 +#define MS_POSIXACL (1 << 16) +#define MS_UNBINDABLE (1 << 17) +#define MS_PRIVATE (1 << 18) +#define MS_SLAVE (1 << 19) +#define MS_SHARED (1 << 20) +#define MS_RELATIME (1 << 21) +#define MS_KERNMOUNT (1 << 22) +#define MS_I_VERSION (1 << 23) +#define MS_STRICTATIME (1 << 24) +#define MS_LAZYTIME (1 << 25) +#define MS_NOREMOTELOCK (1 << 27) +#define MS_NOSEC (1 << 28) +#define MS_BORN (1 << 29) +#define MS_ACTIVE (1 << 30) +#define MS_NOUSER (1 << 31) + +#define MNT_FORCE 1 +#define MNT_DETACH 2 +#define MNT_EXPIRE 4 +#define UMOUNT_NOFOLLOW 8 + +#undef BLKROSET +#define BLKROSET _IO(0x12, 93) +#undef BLKROGET +#define BLKROGET _IO(0x12, 94) +#undef BLKRRPART +#define BLKRRPART _IO(0x12, 95) +#undef BLKGETSIZE +#define BLKGETSIZE _IO(0x12, 96) +#undef BLKFLSBUF +#define BLKFLSBUF _IO(0x12, 97) +#undef BLKRASET +#define BLKRASET _IO(0x12, 98) +#undef BLKRAGET +#define BLKRAGET _IO(0x12, 99) +#undef BLKFRASET +#define BLKFRASET _IO(0x12, 100) +#undef BLKFRAGET +#define BLKFRAGET _IO(0x12, 101) +#undef BLKSECTSET +#define BLKSECTSET _IO(0x12, 102) +#undef BLKSECTGET +#define BLKSECTGET _IO(0x12, 103) +#undef BLKSSZGET +#define BLKSSZGET _IO(0x12, 104) +#undef BLKBSZGET +#define BLKBSZGET _IOR(0x12, 112, size_t) +#undef BLKBSZSET +#define BLKBSZSET _IOW(0x12, 113, size_t) +#undef BLKGETSIZE64 +#define BLKGETSIZE64 _IOR(0x12, 114, size_t) + +#ifndef __MLIBC_ABI_ONLY + +int mount(const char *__source, const char *__target, + const char *__fstype, unsigned long __flags, const void *__data); +int umount(const char *__target); +int umount2(const char *__target, int __flags); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_MOUNT_H */ diff --git a/ext2_root/usr/include/sys/pidfd.h b/ext2_root/usr/include/sys/pidfd.h new file mode 100644 index 0000000..37f375e --- /dev/null +++ b/ext2_root/usr/include/sys/pidfd.h @@ -0,0 +1,26 @@ +#ifndef _SYS_PIDFD_H +#define _SYS_PIDFD_H + +#include +#include +#include + +#define PIDFD_NONBLOCK O_NONBLOCK + +#ifndef __MLIBC_ABI_ONLY + +#ifdef __cplusplus +extern "C" { +#endif + +int pidfd_open(pid_t __pid, unsigned int __flags); +pid_t pidfd_getpid(int __fd); +int pidfd_send_signal(int __pidfd, int __sig, siginfo_t *__info, unsigned int __flags); + +#ifdef __cplusplus +} +#endif + +#endif /* !__MLIBC_ABI_ONLY */ + +#endif /* _SYS_PIDFD_H */ diff --git a/ext2_root/usr/include/sys/prctl.h b/ext2_root/usr/include/sys/prctl.h new file mode 100644 index 0000000..61e9eb5 --- /dev/null +++ b/ext2_root/usr/include/sys/prctl.h @@ -0,0 +1,128 @@ + +#ifndef _SYS_PRCTL_H +#define _SYS_PRCTL_H + +#include + +#define PR_SET_PDEATHSIG 1 +#define PR_GET_PDEATHSIG 2 +#define PR_GET_DUMPABLE 3 +#define PR_SET_DUMPABLE 4 +#define PR_GET_UNALIGN 5 +#define PR_SET_UNALIGN 6 +#define PR_UNALIGN_NOPRINT 1 +#define PR_UNALIGN_SIGBUS 2 +#define PR_GET_KEEPCAPS 7 +#define PR_SET_KEEPCAPS 8 +#define PR_GET_FPEMU 9 +#define PR_SET_FPEMU 10 +#define PR_FPEMU_NOPRINT 1 +#define PR_FPEMU_SIGFPE 2 +#define PR_GET_FPEXC 11 +#define PR_SET_FPEXC 12 +#define PR_FP_EXC_SW_ENABLE 0x80 +#define PR_FP_EXC_DIV 0x010000 +#define PR_FP_EXC_OVF 0x020000 +#define PR_FP_EXC_UND 0x040000 +#define PR_FP_EXC_RES 0x080000 +#define PR_FP_EXC_INV 0x100000 +#define PR_FP_EXC_DISABLED 0 +#define PR_FP_EXC_NONRECOV 1 +#define PR_FP_EXC_ASYNC 2 +#define PR_FP_EXC_PRECISE 3 +#define PR_GET_TIMING 13 +#define PR_SET_TIMING 14 +#define PR_TIMING_STATISTICAL 0 +#define PR_TIMING_TIMESTAMP 1 +#define PR_SET_NAME 15 +#define PR_GET_NAME 16 +#define PR_GET_ENDIAN 19 +#define PR_SET_ENDIAN 20 +#define PR_ENDIAN_BIG 0 +#define PR_ENDIAN_LITTLE 1 +#define PR_ENDIAN_PPC_LITTLE 2 +#define PR_GET_SECCOMP 21 +#define PR_SET_SECCOMP 22 +#define PR_CAPBSET_READ 23 +#define PR_CAPBSET_DROP 24 +#define PR_GET_TSC 25 +#define PR_SET_TSC 26 +#define PR_TSC_ENABLE 1 +#define PR_TSC_SIGSEGV 2 +#define PR_GET_SECUREBITS 27 +#define PR_SET_SECUREBITS 28 +#define PR_SET_TIMERSLACK 29 +#define PR_GET_TIMERSLACK 30 + +#define PR_TASK_PERF_EVENTS_DISABLE 31 +#define PR_TASK_PERF_EVENTS_ENABLE 32 + +#define PR_MCE_KILL 33 +#define PR_MCE_KILL_CLEAR 0 +#define PR_MCE_KILL_SET 1 +#define PR_MCE_KILL_LATE 0 +#define PR_MCE_KILL_EARLY 1 +#define PR_MCE_KILL_DEFAULT 2 +#define PR_MCE_KILL_GET 34 + +#define PR_SET_MM 35 +#define PR_SET_MM_START_CODE 1 +#define PR_SET_MM_END_CODE 2 +#define PR_SET_MM_START_DATA 3 +#define PR_SET_MM_END_DATA 4 +#define PR_SET_MM_START_STACK 5 +#define PR_SET_MM_START_BRK 6 +#define PR_SET_MM_BRK 7 +#define PR_SET_MM_ARG_START 8 +#define PR_SET_MM_ARG_END 9 +#define PR_SET_MM_ENV_START 10 +#define PR_SET_MM_ENV_END 11 +#define PR_SET_MM_AUXV 12 +#define PR_SET_MM_EXE_FILE 13 +#define PR_SET_MM_MAP 14 +#define PR_SET_MM_MAP_SIZE 15 + +#define PR_SET_PTRACER 0x59616d61 +#define PR_SET_PTRACER_ANY (-1UL) + +#define PR_SET_CHILD_SUBREAPER 36 +#define PR_GET_CHILD_SUBREAPER 37 + +#define PR_SET_NO_NEW_PRIVS 38 +#define PR_GET_NO_NEW_PRIVS 39 + +#define PR_GET_TID_ADDRESS 40 + +#define PR_SET_THP_DISABLE 41 +#define PR_GET_THP_DISABLE 42 + +#define PR_MPX_ENABLE_MANAGEMENT 43 +#define PR_MPX_DISABLE_MANAGEMENT 44 + +#define PR_SET_FP_MODE 45 +#define PR_GET_FP_MODE 46 +#define PR_FP_MODE_FR (1 << 0) +#define PR_FP_MODE_FRE (1 << 1) + +#define PR_CAP_AMBIENT 47 +#define PR_CAP_AMBIENT_IS_SET 1 +#define PR_CAP_AMBIENT_RAISE 2 +#define PR_CAP_AMBIENT_LOWER 3 +#define PR_CAP_AMBIENT_CLEAR_ALL 4 + +#ifndef __MLIBC_ABI_ONLY + +#ifdef __cplusplus +extern "C" { +#endif + +int prctl(int __op, ...); + +#ifdef __cplusplus +} +#endif + +#endif /* !__MLIBC_ABI_ONLY */ + +#endif /* _SYS_PRCTL_H */ + diff --git a/ext2_root/usr/include/sys/ptrace.h b/ext2_root/usr/include/sys/ptrace.h new file mode 100644 index 0000000..915b01d --- /dev/null +++ b/ext2_root/usr/include/sys/ptrace.h @@ -0,0 +1,55 @@ + +#ifndef _SYS_PTRACE_H +#define _SYS_PTRACE_H + +#include +#include + +#define PTRACE_TRACEME 0 +#define PT_TRACE_ME PTRACE_TRACEME + +#define PT_READ_I PTRACE_PEEKTEXT +#define PT_READ_D PTRACE_PEEKDATA +#define PT_READ_U PTRACE_PEEKUSER +#define PT_WRITE_I PTRACE_POKETEXT +#define PT_WRITE_D PTRACE_POKEDATA +#define PT_WRITE_U PTRACE_POKEUSER +#define PT_CONTINUE PTRACE_CONT +#define PT_KILL PTRACE_KILL +#define PT_STEP PTRACE_SINGLESTEP +#define PT_GETREGS PTRACE_GETREGS +#define PT_SETREGS PTRACE_SETREGS +#define PT_GETFPREGS PTRACE_GETFPREGS +#define PT_SETFPREGS PTRACE_SETFPREGS +#define PT_ATTACH PTRACE_ATTACH +#define PT_DETACH PTRACE_DETACH +#define PT_GETFPXREGS PTRACE_GETFPXREGS +#define PT_SETFPXREGS PTRACE_SETFPXREGS +#define PT_SYSCALL PTRACE_SYSCALL +#define PT_SETOPTIONS PTRACE_SETOPTIONS +#define PT_GETEVENTMSG PTRACE_GETEVENTMSG +#define PT_GETSIGINFO PTRACE_GETSIGINFO +#define PT_SETSIGINFO PTRACE_SETSIGINFO + +#ifdef __cplusplus +extern "C" { +#endif + +struct ptrace_peeksiginfo_args { + uint64_t offset; + uint32_t flags; + int32_t nr; +}; + +#ifndef __MLIBC_ABI_ONLY + +long ptrace(int __op, ...); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_PTRACE_H */ + diff --git a/ext2_root/usr/include/sys/quota.h b/ext2_root/usr/include/sys/quota.h new file mode 100644 index 0000000..8f6ea05 --- /dev/null +++ b/ext2_root/usr/include/sys/quota.h @@ -0,0 +1,24 @@ +#ifndef _SYS_QUOTA_H +#define _SYS_QUOTA_H + +#include + +#define SUBCMDMASK 0x00ff +#define SUBCMDSHIFT 8 +#define QCMD(cmd, type) (((cmd) << SUBCMDSHIFT) | ((type) & SUBCMDMASK)) + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __MLIBC_ABI_ONLY + +int quotactl(int __cmd, const char *__special, int __id, caddr_t __addr); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_QUOTA_H */ diff --git a/ext2_root/usr/include/sys/random.h b/ext2_root/usr/include/sys/random.h new file mode 100644 index 0000000..e51e0d1 --- /dev/null +++ b/ext2_root/usr/include/sys/random.h @@ -0,0 +1,24 @@ + +#ifndef _SYS_RANDOM_H +#define _SYS_RANDOM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include +#include + +#ifndef __MLIBC_ABI_ONLY + +ssize_t getrandom(void *__buffer, size_t __max_size, unsigned int __flags); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /*_SYS_RANDOM_H */ + diff --git a/ext2_root/usr/include/sys/reboot.h b/ext2_root/usr/include/sys/reboot.h new file mode 100644 index 0000000..5983882 --- /dev/null +++ b/ext2_root/usr/include/sys/reboot.h @@ -0,0 +1,20 @@ +#ifndef MLIBC_SYS_REBOOT_H +#define MLIBC_SYS_REBOOT_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __MLIBC_ABI_ONLY + +int reboot(int __arg); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* MLIBC_SYS_REBOOT_H */ diff --git a/ext2_root/usr/include/sys/sendfile.h b/ext2_root/usr/include/sys/sendfile.h new file mode 100644 index 0000000..4a0c359 --- /dev/null +++ b/ext2_root/usr/include/sys/sendfile.h @@ -0,0 +1,22 @@ + +#ifndef _SYS_SENDFILE_H_ +#define _SYS_SENDFILE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifndef __MLIBC_ABI_ONLY + +ssize_t sendfile(int __out_fd, int __in_fd, off_t *__offset, size_t __size); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SENDFILE_H_ */ + diff --git a/ext2_root/usr/include/sys/signalfd.h b/ext2_root/usr/include/sys/signalfd.h new file mode 100644 index 0000000..13327c1 --- /dev/null +++ b/ext2_root/usr/include/sys/signalfd.h @@ -0,0 +1,48 @@ +#ifndef _SYS_SIGNALFD_H +#define _SYS_SIGNALFD_H + +/* TODO: Define sigset separately and remove this include. */ +#include +/* musl includes those. Restructure this so we do not need them? */ +#include +#include + +#define SFD_CLOEXEC O_CLOEXEC +#define SFD_NONBLOCK O_NONBLOCK + +#ifdef __cplusplus +extern "C" { +#endif + +struct signalfd_siginfo { + uint32_t ssi_signo; + int32_t ssi_errno; + int32_t ssi_code; + uint32_t ssi_pid; + uint32_t ssi_uid; + int32_t ssi_fd; + uint32_t ssi_tid; + uint32_t ssi_band; + uint32_t ssi_overrun; + uint32_t ssi_trapno; + int32_t ssi_status; + int32_t ssi_int; + uint64_t ssi_ptr; + uint64_t ssi_utime; + uint64_t ssi_stime; + uint64_t ssi_addr; + uint16_t ssi_addr_lsb; + uint8_t pad[128-12*4-4*8-2]; +}; + +#ifndef __MLIBC_ABI_ONLY + +int signalfd(int __fd, const sigset_t *__mask, int __flags); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SIGNALFD_H */ diff --git a/ext2_root/usr/include/sys/statfs.h b/ext2_root/usr/include/sys/statfs.h new file mode 100644 index 0000000..c446307 --- /dev/null +++ b/ext2_root/usr/include/sys/statfs.h @@ -0,0 +1,23 @@ +#ifndef _SYS_STATFS_H +#define _SYS_STATFS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifndef __MLIBC_ABI_ONLY + +int statfs(const char *__path, struct statfs *__buf); +int fstatfs(int __fd, struct statfs *__buf); +int fstatfs64(int __fd, struct statfs64 *__buf); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_STATFS_H */ + diff --git a/ext2_root/usr/include/sys/swap.h b/ext2_root/usr/include/sys/swap.h new file mode 100644 index 0000000..8beb44d --- /dev/null +++ b/ext2_root/usr/include/sys/swap.h @@ -0,0 +1,24 @@ +#ifndef _SYS_SWAP_H +#define _SYS_SWAP_H + +#ifdef __cplusplus +extern "C" { +#endif + +#define SWAP_FLAG_PREFER 0x8000 +#define SWAP_FLAG_PRIO_MASK 0x7fff +#define SWAP_FLAG_PRIO_SHIFT 0 +#define SWAP_FLAG_DISCARD 0x10000 + +#ifndef __MLIBC_ABI_ONLY + +int swapon(const char *__path, int __flags); +int swapoff(const char *__path); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SWAP_H */ diff --git a/ext2_root/usr/include/sys/sysinfo.h b/ext2_root/usr/include/sys/sysinfo.h new file mode 100644 index 0000000..194b94e --- /dev/null +++ b/ext2_root/usr/include/sys/sysinfo.h @@ -0,0 +1,46 @@ +#ifndef _SYS_SYSINFO_H +#define _SYS_SYSINFO_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* TODO: This is from the Linux ABI. Make this an abi-bit. */ + +struct sysinfo { + long uptime; + unsigned long loads[3]; + unsigned long totalram; + unsigned long freeram; + unsigned long sharedram; + unsigned long bufferram; + unsigned long totalswap; + unsigned long freeswap; + unsigned short procs; + unsigned long totalhigh; + unsigned long freehigh; + unsigned int mem_unit; + + /* This is how the kernel header defines it, so suppress the warning. */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpedantic" + char _f[20 - 2 * sizeof(long) - sizeof(int)]; /* Padding to 64 bytes according to my man page */ +#pragma GCC diagnostic pop +}; + +#define SI_LOAD_SHIFT 16 + +#ifndef __MLIBC_ABI_ONLY + +int sysinfo(struct sysinfo *__info); + +int get_nprocs(void); +int get_nprocs_conf(void); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYSINFO_H */ diff --git a/ext2_root/usr/include/sys/sysmacros.h b/ext2_root/usr/include/sys/sysmacros.h new file mode 100644 index 0000000..98b6580 --- /dev/null +++ b/ext2_root/usr/include/sys/sysmacros.h @@ -0,0 +1,35 @@ +#ifndef _SYS_SYSMACROS_H +#define _SYS_SYSMACROS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +__MLIBC_INLINE_DEFINITION unsigned int __mlibc_dev_major( + unsigned long long int __dev) { + return ((__dev >> 8) & 0xfff) | ((unsigned int)(__dev >> 32) & ~0xfff); +} + +__MLIBC_INLINE_DEFINITION unsigned int __mlibc_dev_minor( + unsigned long long int __dev) { + return (__dev & 0xff) | ((unsigned int)(__dev >> 12) & ~0xff); +} + +__MLIBC_INLINE_DEFINITION unsigned long long int __mlibc_dev_makedev( + unsigned int __major, unsigned int __minor) { + return ((__minor & 0xff) | ((__major & 0xfff) << 8) + | (((unsigned long long int)(__minor & ~0xff)) << 12) + | (((unsigned long long int)(__major & ~0xfff)) << 32)); +} + +#define major(dev) __mlibc_dev_major(dev) +#define minor(dev) __mlibc_dev_minor(dev) +#define makedev(major, minor) __mlibc_dev_makedev(major, minor) + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_SYSMACROS_H */ diff --git a/ext2_root/usr/include/sys/timerfd.h b/ext2_root/usr/include/sys/timerfd.h new file mode 100644 index 0000000..5caac5d --- /dev/null +++ b/ext2_root/usr/include/sys/timerfd.h @@ -0,0 +1,32 @@ +#ifndef _SYS_TIMERFD_H +#define _SYS_TIMERFD_H + +/* musl includes those. Refactor and remove them? */ +#include +#include + +#define TFD_NONBLOCK O_NONBLOCK +#define TFD_CLOEXEC O_CLOEXEC + +#define TFD_TIMER_ABSTIME 1 +#define TFD_TIMER_CANCEL_ON_SET (1 << 1) + +#ifdef __cplusplus +extern "C" { +#endif + +struct itimerspec; + +#ifndef __MLIBC_ABI_ONLY + +int timerfd_create(int __clockid, int __flags); +int timerfd_settime(int __fd, int __flags, const struct itimerspec *__value, struct itimerspec *__oldvalue); +int timerfd_gettime(int __fd, struct itimerspec *__value); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_TIMERFD_H */ diff --git a/ext2_root/usr/include/sys/vfs.h b/ext2_root/usr/include/sys/vfs.h new file mode 100644 index 0000000..7e7e60d --- /dev/null +++ b/ext2_root/usr/include/sys/vfs.h @@ -0,0 +1,16 @@ + +#ifndef _SYS_VFS_H +#define _SYS_VFS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#ifdef __cplusplus +} +#endif + +#endif /* _SYS_VFS_H */ + diff --git a/ext2_root/usr/include/sys/vt.h b/ext2_root/usr/include/sys/vt.h new file mode 100644 index 0000000..b0518ed --- /dev/null +++ b/ext2_root/usr/include/sys/vt.h @@ -0,0 +1,6 @@ +#ifndef _SYS_VT_H +#define _SYS_VT_H + +#include + +#endif /* _SYS_VT_H */ diff --git a/ext2_root/usr/include/sys/xattr.h b/ext2_root/usr/include/sys/xattr.h new file mode 100644 index 0000000..1b9486d --- /dev/null +++ b/ext2_root/usr/include/sys/xattr.h @@ -0,0 +1,38 @@ +#ifndef _MLIBC_LINUX_SYS_XATTR_H +#define _MLIBC_LINUX_SYS_XATTR_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __MLIBC_ABI_ONLY + +int setxattr(const char *__path, const char *__name, const void *__val, size_t __size, + int __flags); +int lsetxattr(const char *__path, const char *__name, const void *__val, size_t __size, + int __flags); +int fsetxattr(int __fd, const char *__name, const void *__val, size_t __size, + int __flags); + +ssize_t getxattr(const char *__path, const char *__name, void *__val, size_t __size); +ssize_t lgetxattr(const char *__path, const char *__name, void *__val, size_t __size); +ssize_t fgetxattr(int __fd, const char *__name, void *__val, size_t __size); + +ssize_t listxattr(const char *__path, char *__list, size_t __size); +ssize_t llistxattr(const char *__path, char *__list, size_t __size); +ssize_t flistxattr(int __fd, char *__list, size_t __size); + +int removexattr(const char *__path, const char *__name); +int lremovexattr(const char *__path, const char *__name); +int fremovexattr(int __fd, const char *__name); + +#endif /* !__MLIBC_ABI_ONLY */ + +#ifdef __cplusplus +} +#endif + +#endif /* _MLIBC_LINUX_SYS_XATTR_H */ diff --git a/ext2_root/usr/include/values.h b/ext2_root/usr/include/values.h new file mode 100644 index 0000000..75a4345 --- /dev/null +++ b/ext2_root/usr/include/values.h @@ -0,0 +1,39 @@ + +#ifndef _VALUES_H +#define _VALUES_H + +#include +#include + +#define CHARBITS (sizeof(char) * 8) +#define SHORTBITS (sizeof(short) * 8) +#define INTBITS (sizeof(int) * 8) +#define LONGBITS (sizeof(long) * 8) +#define PTRBITS (sizeof(char *) * 8) +#define DOUBLEBITS (sizeof(double) * 8) +#define FLOATBITS (sizeof(float) * 8) + +#define MINSHORT SHRT_MIN +#define MININT INT_MIN +#define MINLONG LONG_MIN + +#define MAXSHORT SHRT_MAX +#define MAXINT INT_MAX +#define MAXLONG LONG_MAX + +#define HIBITS MINSHORT +#define HIBITL MINLONG + +#define MAXDOUBLE DBL_MAX +#define MAXFLOAT FLT_MAX +#define MINDOUBLE DBL_MIN +#define MINFLOAT FLT_MIN +#define DMINEXP DBL_MIN_EXP +#define FMINEXP FLT_MIN_EXP +#define DMAXEXP DBL_MAX_EXP +#define FMAXEXP FLT_MAX_EXP + +#define BITSPERBYTE CHAR_BIT + +#endif /* _VALUES_H */ + diff --git a/user/include/mlibc/sysdeps/kirkos/meson.build b/user/include/mlibc/sysdeps/kirkos/meson.build index 758ef97..e4095c3 100644 --- a/user/include/mlibc/sysdeps/kirkos/meson.build +++ b/user/include/mlibc/sysdeps/kirkos/meson.build @@ -1,6 +1,6 @@ sysdep_supported_options = { 'posix': true, - 'linux': false, + 'linux': true, 'glibc': true, 'bsd': true, } @@ -54,6 +54,8 @@ if not no_headers 'include/abi-bits/mqueue.h', 'include/abi-bits/utmp-defines.h', 'include/abi-bits/utmpx.h', + 'include/abi-bits/statx.h', + 'include/abi-bits/ioctls.h', subdir: 'abi-bits', follow_symlinks: true )