X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=support%2Fsys-stat.c;h=d6abce4a1facdfafdad71bd2f6022d217bfc8db0;hb=ef7a4c06206976de7ef2e974267407347ddb75a4;hp=54d53086801464ef70e413d869a08febd325e57a;hpb=f3b1d7e5eba21eca5b6a2f857f3405ab2182015a;p=mono.git diff --git a/support/sys-stat.c b/support/sys-stat.c index 54d53086801..d6abce4a1fa 100644 --- a/support/sys-stat.c +++ b/support/sys-stat.c @@ -13,15 +13,93 @@ #include #include +#ifdef HAVE_UNISTD_H #include +#endif #include #include +#include "mph.h" /* Don't remove or move after map.h! Works around issues with Android SDK unified headers */ #include "map.h" -#include "mph.h" G_BEGIN_DECLS +int +Mono_Posix_FromStat (struct Mono_Posix_Stat *from, void *_to) +{ + struct stat *to = _to; + memset (to, 0, sizeof(*to)); + + to->st_dev = from->st_dev; + to->st_ino = from->st_ino; + + unsigned int to_st_mode; + if (Mono_Posix_FromFilePermissions (from->st_mode, &to_st_mode) != 0) { + return -1; + } + + to->st_mode = to_st_mode; + to->st_nlink = from->st_nlink; + to->st_uid = from->st_uid; + to->st_gid = from->st_gid; + to->st_rdev = from->st_rdev; + to->st_size = from->st_size; +#ifndef HOST_WIN32 + to->st_blksize = from->st_blksize; + to->st_blocks = from->st_blocks; +#endif + to->st_atime = from->st_atime_; + to->st_mtime = from->st_mtime_; + to->st_ctime = from->st_ctime_; +#ifdef HAVE_STRUCT_STAT_ST_ATIM + to->st_atim.tv_nsec = from->st_atime_nsec; +#endif +#ifdef HAVE_STRUCT_STAT_ST_MTIM + to->st_mtim.tv_nsec = from->st_mtime_nsec; +#endif +#ifdef HAVE_STRUCT_STAT_ST_CTIM + to->st_ctim.tv_nsec = from->st_ctime_nsec; +#endif + + return 0; +} + +int +Mono_Posix_ToStat (void *_from, struct Mono_Posix_Stat *to) +{ + struct stat *from = _from; + memset (to, 0, sizeof(*to)); + + to->st_dev = from->st_dev; + to->st_ino = from->st_ino; + if (Mono_Posix_ToFilePermissions (from->st_mode, &to->st_mode) != 0) { + return -1; + } + to->st_nlink = from->st_nlink; + to->st_uid = from->st_uid; + to->st_gid = from->st_gid; + to->st_rdev = from->st_rdev; + to->st_size = from->st_size; +#ifndef HOST_WIN32 + to->st_blksize = from->st_blksize; + to->st_blocks = from->st_blocks; +#endif + to->st_atime_ = from->st_atime; + to->st_mtime_ = from->st_mtime; + to->st_ctime_ = from->st_ctime; +#ifdef HAVE_STRUCT_STAT_ST_ATIM + to->st_atime_nsec = from->st_atim.tv_nsec; +#endif +#ifdef HAVE_STRUCT_STAT_ST_MTIM + to->st_mtime_nsec = from->st_mtim.tv_nsec; +#endif +#ifdef HAVE_STRUCT_STAT_ST_CTIM + to->st_ctime_nsec = from->st_ctim.tv_nsec; +#endif + + return 0; +} + gint32 Mono_Posix_Syscall_stat (const char *file_name, struct Mono_Posix_Stat *buf) { @@ -54,6 +132,7 @@ Mono_Posix_Syscall_fstat (int filedes, struct Mono_Posix_Stat *buf) return r; } +#ifndef HOST_WIN32 gint32 Mono_Posix_Syscall_lstat (const char *file_name, struct Mono_Posix_Stat *buf) { @@ -69,6 +148,7 @@ Mono_Posix_Syscall_lstat (const char *file_name, struct Mono_Posix_Stat *buf) r = -1; return r; } +#endif #ifdef HAVE_FSTATAT gint32 @@ -91,6 +171,7 @@ Mono_Posix_Syscall_fstatat (gint32 dirfd, const char *file_name, struct Mono_Pos } #endif +#ifndef HOST_WIN32 gint32 Mono_Posix_Syscall_mknod (const char *pathname, guint32 mode, mph_dev_t dev) { @@ -98,6 +179,7 @@ Mono_Posix_Syscall_mknod (const char *pathname, guint32 mode, mph_dev_t dev) return -1; return mknod (pathname, mode, dev); } +#endif #ifdef HAVE_MKNODAT gint32 @@ -131,6 +213,7 @@ Mono_Posix_Syscall_get_utime_omit () #endif } +#if defined(HAVE_FUTIMENS) || defined(HAVE_UTIMENSAT) static inline struct timespec* copy_utimens (struct timespec* to, struct Mono_Posix_Timespec *from) { @@ -144,6 +227,7 @@ copy_utimens (struct timespec* to, struct Mono_Posix_Timespec *from) return NULL; } +#endif #ifdef HAVE_FUTIMENS gint32