[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel,v2,5/5] plat/linuxu: Add fstat and open host system calls
From: Robert Hrusecky <roberth@xxxxxxxxxxxxx> Add system call number for arm_32 and x86_64 for the fstat system call Implement system call wrapper function for open and fstat Add MAP_PRIVATE constant for use with mmap Signed-off-by: Robert Hrusecky <roberth@xxxxxxxxxxxxx> Signed-off-by: Omar Jamil <omarj2898@xxxxxxxxx> Signed-off-by: Sachin Beldona <sachinbeldona@xxxxxxxxxx> Signed-off-by: Gabriel Mocanu <gabi.mocanu98@xxxxxxxxx> --- plat/linuxu/include/linuxu/mode.h | 8 +++++ plat/linuxu/include/linuxu/stat.h | 39 +++++++++++++++++++++ plat/linuxu/include/linuxu/syscall-arm_32.h | 1 + plat/linuxu/include/linuxu/syscall-x86_64.h | 1 + plat/linuxu/include/linuxu/syscall.h | 20 +++++++++++ 5 files changed, 69 insertions(+) create mode 100644 plat/linuxu/include/linuxu/mode.h create mode 100644 plat/linuxu/include/linuxu/stat.h diff --git a/plat/linuxu/include/linuxu/mode.h b/plat/linuxu/include/linuxu/mode.h new file mode 100644 index 0000000..ac2f40e --- /dev/null +++ b/plat/linuxu/include/linuxu/mode.h @@ -0,0 +1,8 @@ +#ifndef __LINUXU_MODE_H__ +#define __LINUXU_MODE_H__ + +#define K_O_RDONLY 0x0000 + +typedef unsigned k_mode_t; + +#endif /* __LINUXU_MODE_H__ */ diff --git a/plat/linuxu/include/linuxu/stat.h b/plat/linuxu/include/linuxu/stat.h new file mode 100644 index 0000000..d500b0a --- /dev/null +++ b/plat/linuxu/include/linuxu/stat.h @@ -0,0 +1,39 @@ +#ifndef __LINUXU_STAT_H__ +#define __LINUXU_STAT_H__ + +#include <linuxu/time.h> +#include <linuxu/mode.h> + +typedef __u64 k_dev_t; +typedef __u64 k_ino_t; +typedef __u32 k_nlink_t; +typedef unsigned k_uid_t; +typedef unsigned k_gid_t; +typedef unsigned k_id_t; +typedef __off k_off_t; +typedef long k_blksize_t; +typedef __s64 k_blkcnt_t; + + +struct k_stat { + + k_dev_t st_dev; + k_ino_t st_ino; + k_nlink_t st_nlink; + + k_mode_t st_mode; + k_uid_t st_uit; + k_gid_t st_gid; + unsigned int __pad0; + k_dev_t st_rdev; + k_off_t st_size; + k_blksize_t st_blksize; + k_blkcnt_t st_blocks; + + struct k_timespec st_atim; + struct k_timespec st_mtim; + struct k_timespec st_ctim; + +}; + +#endif /* __LINUXU_STAT_H__ */ diff --git a/plat/linuxu/include/linuxu/syscall-arm_32.h b/plat/linuxu/include/linuxu/syscall-arm_32.h index ef9323b..5d1b1e2 100644 --- a/plat/linuxu/include/linuxu/syscall-arm_32.h +++ b/plat/linuxu/include/linuxu/syscall-arm_32.h @@ -46,6 +46,7 @@ #define __SC_MUNMAP 91 #define __SC_EXIT 1 #define __SC_IOCTL 54 +#define __SC_FSTAT 108 #define __SC_RT_SIGPROCMASK 126 #define __SC_ARCH_PRCTL 172 #define __SC_RT_SIGACTION 174 diff --git a/plat/linuxu/include/linuxu/syscall-x86_64.h b/plat/linuxu/include/linuxu/syscall-x86_64.h index 553f0ba..0dd280e 100644 --- a/plat/linuxu/include/linuxu/syscall-x86_64.h +++ b/plat/linuxu/include/linuxu/syscall-x86_64.h @@ -42,6 +42,7 @@ #define __SC_WRITE 1 #define __SC_OPEN 2 #define __SC_CLOSE 3 +#define __SC_FSTAT 5 #define __SC_MMAP 9 #define __SC_MUNMAP 11 #define __SC_RT_SIGACTION 13 diff --git a/plat/linuxu/include/linuxu/syscall.h b/plat/linuxu/include/linuxu/syscall.h index 0dca7c5..1b590b1 100644 --- a/plat/linuxu/include/linuxu/syscall.h +++ b/plat/linuxu/include/linuxu/syscall.h @@ -39,6 +39,7 @@ #include <linuxu/time.h> #include <sys/types.h> #include <linuxu/signal.h> +#include <linuxu/stat.h> #if defined __X86_64__ #include <linuxu/syscall-x86_64.h> @@ -48,6 +49,13 @@ #error "Unsupported architecture" #endif + +static inline int sys_open(const char *pathname, int flags, mode_t mode) +{ + return (int)syscall3(__SC_OPEN, (long)pathname, (long)flags, + (long)mode); +} + static inline ssize_t sys_read(int fd, const char *buf, size_t len) { return (ssize_t) syscall3(__SC_READ, @@ -64,6 +72,17 @@ static inline ssize_t sys_write(int fd, const char *buf, size_t len) (long) (len)); } +static inline ssize_t sys_close(int fd) +{ + return (ssize_t) syscall1(__SC_CLOSE, + (long) (fd)); +} + +static inline int sys_fstat(int fd, struct k_stat *statbuf) +{ + return (int)syscall2(__SC_FSTAT, (long)(fd), (long)(statbuf)); +} + static inline int sys_exit(int status) { return (int) syscall1(__SC_EXIT, @@ -81,6 +100,7 @@ static inline int sys_clock_gettime(k_clockid_t clk_id, struct k_timespec *tp) * Please note that on failure sys_mmap() is returning -errno */ #define MAP_SHARED (0x01) +#define MAP_PRIVATE (0x02) #define MAP_ANONYMOUS (0x20) #define PROT_NONE (0x0) #define PROT_READ (0x1) -- 2.17.1
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |