mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-07-11 07:19:20 +00:00
Refactor filesystem & stl code
This commit is contained in:
@ -20,174 +20,178 @@
|
||||
|
||||
#include <types.h>
|
||||
|
||||
#define ARCH_SET_GS 0x1001
|
||||
#define ARCH_SET_FS 0x1002
|
||||
#define ARCH_GET_FS 0x1003
|
||||
#define ARCH_GET_GS 0x1004
|
||||
#define linux_SEEK_SET 0
|
||||
#define linux_SEEK_CUR 1
|
||||
#define linux_SEEK_END 2
|
||||
|
||||
#define ARCH_GET_CPUID 0x1011
|
||||
#define ARCH_SET_CPUID 0x1012
|
||||
#define linux_ARCH_SET_GS 0x1001
|
||||
#define linux_ARCH_SET_FS 0x1002
|
||||
#define linux_ARCH_GET_FS 0x1003
|
||||
#define linux_ARCH_GET_GS 0x1004
|
||||
|
||||
#define ARCH_GET_XCOMP_SUPP 0x1021
|
||||
#define ARCH_GET_XCOMP_PERM 0x1022
|
||||
#define ARCH_REQ_XCOMP_PERM 0x1023
|
||||
#define ARCH_GET_XCOMP_GUEST_PERM 0x1024
|
||||
#define ARCH_REQ_XCOMP_GUEST_PERM 0x1025
|
||||
#define linux_ARCH_GET_CPUID 0x1011
|
||||
#define linux_ARCH_SET_CPUID 0x1012
|
||||
|
||||
#define ARCH_XCOMP_TILECFG 17
|
||||
#define ARCH_XCOMP_TILEDATA 18
|
||||
#define linux_ARCH_GET_XCOMP_SUPP 0x1021
|
||||
#define linux_ARCH_GET_XCOMP_PERM 0x1022
|
||||
#define linux_ARCH_REQ_XCOMP_PERM 0x1023
|
||||
#define linux_ARCH_GET_XCOMP_GUEST_PERM 0x1024
|
||||
#define linux_ARCH_REQ_XCOMP_GUEST_PERM 0x1025
|
||||
|
||||
#define ARCH_MAP_VDSO_X32 0x2001
|
||||
#define ARCH_MAP_VDSO_32 0x2002
|
||||
#define ARCH_MAP_VDSO_64 0x2003
|
||||
#define linux_ARCH_XCOMP_TILECFG 17
|
||||
#define linux_ARCH_XCOMP_TILEDATA 18
|
||||
|
||||
#define ARCH_GET_UNTAG_MASK 0x4001
|
||||
#define ARCH_ENABLE_TAGGED_ADDR 0x4002
|
||||
#define ARCH_GET_MAX_TAG_BITS 0x4003
|
||||
#define ARCH_FORCE_TAGGED_SVA 0x4004
|
||||
#define linux_ARCH_MAP_VDSO_X32 0x2001
|
||||
#define linux_ARCH_MAP_VDSO_32 0x2002
|
||||
#define linux_ARCH_MAP_VDSO_64 0x2003
|
||||
|
||||
#define PROT_NONE 0
|
||||
#define PROT_READ 1
|
||||
#define PROT_WRITE 2
|
||||
#define PROT_EXEC 4
|
||||
#define PROT_GROWSDOWN 0x01000000
|
||||
#define PROT_GROWSUP 0x02000000
|
||||
#define linux_ARCH_GET_UNTAG_MASK 0x4001
|
||||
#define linux_ARCH_ENABLE_TAGGED_ADDR 0x4002
|
||||
#define linux_ARCH_GET_MAX_TAG_BITS 0x4003
|
||||
#define linux_ARCH_FORCE_TAGGED_SVA 0x4004
|
||||
|
||||
#define MAP_TYPE 0x0f
|
||||
#define linux_PROT_NONE 0
|
||||
#define linux_PROT_READ 1
|
||||
#define linux_PROT_WRITE 2
|
||||
#define linux_PROT_EXEC 4
|
||||
#define linux_PROT_GROWSDOWN 0x01000000
|
||||
#define linux_PROT_GROWSUP 0x02000000
|
||||
|
||||
#define MAP_FILE 0
|
||||
#define MAP_SHARED 0x01
|
||||
#define MAP_PRIVATE 0x02
|
||||
#define MAP_SHARED_VALIDATE 0x03
|
||||
#define MAP_FIXED 0x10
|
||||
#define MAP_ANONYMOUS 0x20
|
||||
#define MAP_NORESERVE 0x4000
|
||||
#define MAP_GROWSDOWN 0x0100
|
||||
#define MAP_DENYWRITE 0x0800
|
||||
#define MAP_EXECUTABLE 0x1000
|
||||
#define MAP_LOCKED 0x2000
|
||||
#define MAP_POPULATE 0x8000
|
||||
#define MAP_NONBLOCK 0x10000
|
||||
#define MAP_STACK 0x20000
|
||||
#define MAP_HUGETLB 0x40000
|
||||
#define MAP_SYNC 0x80000
|
||||
#define MAP_FIXED_NOREPLACE 0x100000
|
||||
#define linux_MAP_TYPE 0x0f
|
||||
|
||||
#define CLOCK_REALTIME 0
|
||||
#define CLOCK_MONOTONIC 1
|
||||
#define CLOCK_PROCESS_CPUTIME_ID 2
|
||||
#define CLOCK_THREAD_CPUTIME_ID 3
|
||||
#define CLOCK_MONOTONIC_RAW 4
|
||||
#define CLOCK_REALTIME_COARSE 5
|
||||
#define CLOCK_MONOTONIC_COARSE 6
|
||||
#define CLOCK_BOOTTIME 7
|
||||
#define CLOCK_REALTIME_ALARM 8
|
||||
#define CLOCK_BOOTTIME_ALARM 9
|
||||
#define CLOCK_SGI_CYCLE 10
|
||||
#define CLOCK_TAI 11
|
||||
#define linux_MAP_FILE 0
|
||||
#define linux_MAP_SHARED 0x01
|
||||
#define linux_MAP_PRIVATE 0x02
|
||||
#define linux_MAP_SHARED_VALIDATE 0x03
|
||||
#define linux_MAP_FIXED 0x10
|
||||
#define linux_MAP_ANONYMOUS 0x20
|
||||
#define linux_MAP_NORESERVE 0x4000
|
||||
#define linux_MAP_GROWSDOWN 0x0100
|
||||
#define linux_MAP_DENYWRITE 0x0800
|
||||
#define linux_MAP_EXECUTABLE 0x1000
|
||||
#define linux_MAP_LOCKED 0x2000
|
||||
#define linux_MAP_POPULATE 0x8000
|
||||
#define linux_MAP_NONBLOCK 0x10000
|
||||
#define linux_MAP_STACK 0x20000
|
||||
#define linux_MAP_HUGETLB 0x40000
|
||||
#define linux_MAP_SYNC 0x80000
|
||||
#define linux_MAP_FIXED_NOREPLACE 0x100000
|
||||
|
||||
#define GRND_NONBLOCK 0x1
|
||||
#define GRND_RANDOM 0x2
|
||||
#define GRND_INSECURE 0x4
|
||||
#define linux_CLOCK_REALTIME 0
|
||||
#define linux_CLOCK_MONOTONIC 1
|
||||
#define linux_CLOCK_PROCESS_CPUTIME_ID 2
|
||||
#define linux_CLOCK_THREAD_CPUTIME_ID 3
|
||||
#define linux_CLOCK_MONOTONIC_RAW 4
|
||||
#define linux_CLOCK_REALTIME_COARSE 5
|
||||
#define linux_CLOCK_MONOTONIC_COARSE 6
|
||||
#define linux_CLOCK_BOOTTIME 7
|
||||
#define linux_CLOCK_REALTIME_ALARM 8
|
||||
#define linux_CLOCK_BOOTTIME_ALARM 9
|
||||
#define linux_CLOCK_SGI_CYCLE 10
|
||||
#define linux_CLOCK_TAI 11
|
||||
|
||||
#define RLIMIT_CPU 0
|
||||
#define RLIMIT_FSIZE 1
|
||||
#define RLIMIT_DATA 2
|
||||
#define RLIMIT_STACK 3
|
||||
#define RLIMIT_CORE 4
|
||||
#define RLIMIT_RSS 5
|
||||
#define RLIMIT_NPROC 6
|
||||
#define RLIMIT_NOFILE 7
|
||||
#define RLIMIT_MEMLOCK 8
|
||||
#define RLIMIT_AS 9
|
||||
#define RLIMIT_LOCKS 10
|
||||
#define RLIMIT_SIGPENDING 11
|
||||
#define RLIMIT_MSGQUEUE 12
|
||||
#define RLIMIT_NICE 13
|
||||
#define RLIMIT_RTPRIO 14
|
||||
#define RLIMIT_RTTIME 15
|
||||
#define RLIMIT_NLIMITS 16
|
||||
#define linux_GRND_NONBLOCK 0x1
|
||||
#define linux_GRND_RANDOM 0x2
|
||||
#define linux_GRND_INSECURE 0x4
|
||||
|
||||
#define F_DUPFD 0
|
||||
#define F_GETFD 1
|
||||
#define F_SETFD 2
|
||||
#define F_GETFL 3
|
||||
#define F_SETFL 4
|
||||
#define linux_RLIMIT_CPU 0
|
||||
#define linux_RLIMIT_FSIZE 1
|
||||
#define linux_RLIMIT_DATA 2
|
||||
#define linux_RLIMIT_STACK 3
|
||||
#define linux_RLIMIT_CORE 4
|
||||
#define linux_RLIMIT_RSS 5
|
||||
#define linux_RLIMIT_NPROC 6
|
||||
#define linux_RLIMIT_NOFILE 7
|
||||
#define linux_RLIMIT_MEMLOCK 8
|
||||
#define linux_RLIMIT_AS 9
|
||||
#define linux_RLIMIT_LOCKS 10
|
||||
#define linux_RLIMIT_SIGPENDING 11
|
||||
#define linux_RLIMIT_MSGQUEUE 12
|
||||
#define linux_RLIMIT_NICE 13
|
||||
#define linux_RLIMIT_RTPRIO 14
|
||||
#define linux_RLIMIT_RTTIME 15
|
||||
#define linux_RLIMIT_NLIMITS 16
|
||||
|
||||
#define F_SETOWN 8
|
||||
#define F_GETOWN 9
|
||||
#define F_SETSIG 10
|
||||
#define F_GETSIG 11
|
||||
#define linux_F_DUPFD 0
|
||||
#define linux_F_GETFD 1
|
||||
#define linux_F_SETFD 2
|
||||
#define linux_F_GETFL 3
|
||||
#define linux_F_SETFL 4
|
||||
|
||||
#define linux_F_SETOWN 8
|
||||
#define linux_F_GETOWN 9
|
||||
#define linux_F_SETSIG 10
|
||||
#define linux_F_GETSIG 11
|
||||
|
||||
#if __LONG_MAX == 0x7fffffffL
|
||||
#define F_GETLK 12
|
||||
#define F_SETLK 13
|
||||
#define F_SETLKW 14
|
||||
#define linux_F_GETLK 12
|
||||
#define linux_F_SETLK 13
|
||||
#define linux_F_SETLKW 14
|
||||
#else
|
||||
#define F_GETLK 5
|
||||
#define F_SETLK 6
|
||||
#define F_SETLKW 7
|
||||
#define linux_F_GETLK 5
|
||||
#define linux_F_SETLK 6
|
||||
#define linux_F_SETLKW 7
|
||||
#endif
|
||||
|
||||
#define F_SETOWN_EX 15
|
||||
#define F_GETOWN_EX 16
|
||||
#define F_GETOWNER_UIDS 17
|
||||
#define linux_F_SETOWN_EX 15
|
||||
#define linux_F_GETOWN_EX 16
|
||||
#define linux_F_GETOWNER_UIDS 17
|
||||
|
||||
#define F_OFD_GETLK 36
|
||||
#define F_OFD_SETLK 37
|
||||
#define F_OFD_SETLKW 38
|
||||
#define linux_F_OFD_GETLK 36
|
||||
#define linux_F_OFD_SETLK 37
|
||||
#define linux_F_OFD_SETLKW 38
|
||||
|
||||
#define F_DUPFD_CLOEXEC 1030
|
||||
#define linux_F_DUPFD_CLOEXEC 1030
|
||||
|
||||
#define FD_CLOEXEC 1
|
||||
#define linux_FD_CLOEXEC 1
|
||||
|
||||
#define DT_UNKNOWN 0
|
||||
#define DT_FIFO 1
|
||||
#define DT_CHR 2
|
||||
#define DT_DIR 4
|
||||
#define DT_BLK 6
|
||||
#define DT_REG 8
|
||||
#define DT_LNK 10
|
||||
#define DT_SOCK 12
|
||||
#define DT_WHT 14
|
||||
#define linux_DT_UNKNOWN 0
|
||||
#define linux_DT_FIFO 1
|
||||
#define linux_DT_CHR 2
|
||||
#define linux_DT_DIR 4
|
||||
#define linux_DT_BLK 6
|
||||
#define linux_DT_REG 8
|
||||
#define linux_DT_LNK 10
|
||||
#define linux_DT_SOCK 12
|
||||
#define linux_DT_WHT 14
|
||||
|
||||
#define AT_FDCWD (-100)
|
||||
#define AT_SYMLINK_NOFOLLOW 0x100
|
||||
#define AT_REMOVEDIR 0x200
|
||||
#define AT_SYMLINK_FOLLOW 0x400
|
||||
#define AT_EACCESS 0x200
|
||||
#define AT_NO_AUTOMOUNT 0x800
|
||||
#define AT_EMPTY_PATH 0x1000
|
||||
#define AT_STATX_SYNC_TYPE 0x6000
|
||||
#define AT_STATX_SYNC_AS_STAT 0x0000
|
||||
#define AT_STATX_FORCE_SYNC 0x2000
|
||||
#define AT_STATX_DONT_SYNC 0x4000
|
||||
#define AT_RECURSIVE 0x8000
|
||||
#define linux_AT_FDCWD (-100)
|
||||
#define linux_AT_SYMLINK_NOFOLLOW 0x100
|
||||
#define linux_AT_REMOVEDIR 0x200
|
||||
#define linux_AT_SYMLINK_FOLLOW 0x400
|
||||
#define linux_AT_EACCESS 0x200
|
||||
#define linux_AT_NO_AUTOMOUNT 0x800
|
||||
#define linux_AT_EMPTY_PATH 0x1000
|
||||
#define linux_AT_STATX_SYNC_TYPE 0x6000
|
||||
#define linux_AT_STATX_SYNC_AS_STAT 0x0000
|
||||
#define linux_AT_STATX_FORCE_SYNC 0x2000
|
||||
#define linux_AT_STATX_DONT_SYNC 0x4000
|
||||
#define linux_AT_RECURSIVE 0x8000
|
||||
|
||||
#define LINUX_REBOOT_MAGIC1 0xfee1dead
|
||||
#define LINUX_REBOOT_MAGIC2 0x28121969
|
||||
#define LINUX_REBOOT_MAGIC2A 0x05121996
|
||||
#define LINUX_REBOOT_MAGIC2B 0x16041998
|
||||
#define LINUX_REBOOT_MAGIC2C 0x20112000
|
||||
#define linux_LINUX_REBOOT_MAGIC1 0xfee1dead
|
||||
#define linux_LINUX_REBOOT_MAGIC2 0x28121969
|
||||
#define linux_LINUX_REBOOT_MAGIC2A 0x05121996
|
||||
#define linux_LINUX_REBOOT_MAGIC2B 0x16041998
|
||||
#define linux_LINUX_REBOOT_MAGIC2C 0x20112000
|
||||
|
||||
#define LINUX_REBOOT_CMD_RESTART 0x01234567
|
||||
#define LINUX_REBOOT_CMD_HALT 0xCDEF0123
|
||||
#define LINUX_REBOOT_CMD_CAD_ON 0x89ABCDEF
|
||||
#define LINUX_REBOOT_CMD_CAD_OFF 0x00000000
|
||||
#define LINUX_REBOOT_CMD_POWER_OFF 0x4321FEDC
|
||||
#define LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
|
||||
#define LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
|
||||
#define LINUX_REBOOT_CMD_KEXEC 0x45584543
|
||||
#define linux_LINUX_REBOOT_CMD_RESTART 0x01234567
|
||||
#define linux_LINUX_REBOOT_CMD_HALT 0xCDEF0123
|
||||
#define linux_LINUX_REBOOT_CMD_CAD_ON 0x89ABCDEF
|
||||
#define linux_LINUX_REBOOT_CMD_CAD_OFF 0x00000000
|
||||
#define linux_LINUX_REBOOT_CMD_POWER_OFF 0x4321FEDC
|
||||
#define linux_LINUX_REBOOT_CMD_RESTART2 0xA1B2C3D4
|
||||
#define linux_LINUX_REBOOT_CMD_SW_SUSPEND 0xD000FCE2
|
||||
#define linux_LINUX_REBOOT_CMD_KEXEC 0x45584543
|
||||
|
||||
#define SA_IMMUTABLE 0x00800000
|
||||
#define linux_SA_IMMUTABLE 0x00800000
|
||||
|
||||
#define ITIMER_REAL 0
|
||||
#define ITIMER_VIRTUAL 1
|
||||
#define ITIMER_PROF 2
|
||||
#define linux_ITIMER_REAL 0
|
||||
#define linux_ITIMER_VIRTUAL 1
|
||||
#define linux_ITIMER_PROF 2
|
||||
|
||||
#define RUSAGE_SELF 0
|
||||
#define RUSAGE_CHILDREN (-1)
|
||||
#define RUSAGE_THREAD 1
|
||||
#define linux_RUSAGE_SELF 0
|
||||
#define linux_RUSAGE_CHILDREN (-1)
|
||||
#define linux_RUSAGE_THREAD 1
|
||||
|
||||
typedef long __kernel_long_t;
|
||||
typedef unsigned long __kernel_ulong_t;
|
||||
@ -249,19 +253,24 @@ struct rusage
|
||||
|
||||
struct linux_dirent
|
||||
{
|
||||
unsigned long d_ino; /* Inode number */
|
||||
unsigned long d_off; /* Offset to next linux_dirent */
|
||||
unsigned short d_reclen; /* Length of this linux_dirent */
|
||||
char d_name[]; /* Filename (null-terminated) */
|
||||
unsigned long d_ino;
|
||||
unsigned long d_off;
|
||||
unsigned short d_reclen;
|
||||
char d_name[];
|
||||
/**
|
||||
* Getting d_type is not the same as linux_dirent64:
|
||||
* https://github.com/torvalds/linux/blob/bfa8f18691ed2e978e4dd51190569c434f93e268/fs/readdir.c#L296
|
||||
* "man 2 getdents" also is helpful
|
||||
*/
|
||||
};
|
||||
|
||||
struct linux_dirent64
|
||||
{
|
||||
ino64_t d_ino; /* 64-bit inode number */
|
||||
off64_t d_off; /* 64-bit offset to next structure */
|
||||
unsigned short d_reclen; /* Size of this dirent */
|
||||
unsigned char d_type; /* File type */
|
||||
char d_name[]; /* Filename (null-terminated) */
|
||||
uint64_t d_ino;
|
||||
int64_t d_off;
|
||||
unsigned short d_reclen;
|
||||
unsigned char d_type;
|
||||
char d_name[];
|
||||
};
|
||||
|
||||
struct linux_kstat
|
||||
|
Reference in New Issue
Block a user