From 0d356c5bbc44297b1a10c56acbead376783074b3 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Fri, 24 Mar 2023 17:40:58 +0200 Subject: [PATCH] LibC: Add stat structure --- libc/include/sys/stat.h | 29 +++++++++++++++++++++++++++++ libc/include/sys/types.h | 18 +++++++++++++----- libc/include/time.h | 13 +++++++++++++ 3 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 libc/include/sys/stat.h create mode 100644 libc/include/time.h diff --git a/libc/include/sys/stat.h b/libc/include/sys/stat.h new file mode 100644 index 000000000..7e92c950e --- /dev/null +++ b/libc/include/sys/stat.h @@ -0,0 +1,29 @@ +#pragma once + +#include +#include + +__BEGIN_DECLS + +#define st_atime st_atim.tv_sec +#define st_ctime st_ctim.tv_sec +#define st_mtime st_mtim.tv_sec + +struct stat +{ + dev_t st_dev; + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + off_t st_size; + timespec st_atim; + timespec st_mtim; + timespec st_ctim; + blksize_t st_blksize; + blkcnt_t st_blocks; +}; + +__END_DECLS \ No newline at end of file diff --git a/libc/include/sys/types.h b/libc/include/sys/types.h index dd1240afa..3375183ea 100644 --- a/libc/include/sys/types.h +++ b/libc/include/sys/types.h @@ -5,10 +5,18 @@ __BEGIN_DECLS -typedef int32_t id_t; -typedef id_t pid_t; -typedef id_t uid_t; -typedef id_t gid_t; -typedef uint16_t mode_t; + +using blkcnt_t = int32_t; +using blksize_t = int32_t; +using dev_t = uint64_t; +using ino_t = uint32_t; +using mode_t = uint16_t; +using nlink_t = uint32_t; +using off_t = int64_t; +using time_t = uint64_t; +using id_t = int32_t; +using pid_t = id_t; +using uid_t = id_t; +using gid_t = id_t; __END_DECLS \ No newline at end of file diff --git a/libc/include/time.h b/libc/include/time.h new file mode 100644 index 000000000..666db0d4e --- /dev/null +++ b/libc/include/time.h @@ -0,0 +1,13 @@ +#pragma once + +#include + +__BEGIN_DECLS + +struct timespec +{ + time_t tv_sec; + long tv_nsec; +}; + +__END_DECLS \ No newline at end of file