2 * <sys/stat.h> wrapper functions.
5 * Jonathan Pryor (jonpryor@vt.edu)
7 * Copyright (C) 2004-2006 Jonathan Pryor
12 #endif /* ndef _GNU_SOURCE */
14 #include <sys/types.h>
26 Mono_Posix_Syscall_stat (const char *file_name, struct Mono_Posix_Stat *buf)
35 r = stat (file_name, &_buf);
36 if (r != -1 && Mono_Posix_ToStat (&_buf, buf) == -1)
42 Mono_Posix_Syscall_fstat (int filedes, struct Mono_Posix_Stat *buf)
51 r = fstat (filedes, &_buf);
52 if (r != -1 && Mono_Posix_ToStat (&_buf, buf) == -1)
58 Mono_Posix_Syscall_lstat (const char *file_name, struct Mono_Posix_Stat *buf)
67 r = lstat (file_name, &_buf);
68 if (r != -1 && Mono_Posix_ToStat (&_buf, buf) == -1)
75 Mono_Posix_Syscall_fstatat (gint32 dirfd, const char *file_name, struct Mono_Posix_Stat *buf, gint32 flags)
80 if (Mono_Posix_FromAtFlags (flags, &flags) == -1)
87 r = fstatat (dirfd, file_name, &_buf, flags);
88 if (r != -1 && Mono_Posix_ToStat (&_buf, buf) == -1)
95 Mono_Posix_Syscall_mknod (const char *pathname, guint32 mode, mph_dev_t dev)
97 if (Mono_Posix_FromFilePermissions (mode, &mode) == -1)
99 return mknod (pathname, mode, dev);
104 Mono_Posix_Syscall_mknodat (int dirfd, const char *pathname, guint32 mode, mph_dev_t dev)
106 if (Mono_Posix_FromFilePermissions (mode, &mode) == -1)
108 return mknodat (dirfd, pathname, mode, dev);
115 Mono_Posix_Syscall_get_utime_now ()
125 Mono_Posix_Syscall_get_utime_omit ()
134 static inline struct timespec*
135 copy_utimens (struct timespec* to, struct Mono_Posix_Timespec *from)
138 to[0].tv_sec = from[0].tv_sec;
139 to[0].tv_nsec = from[0].tv_nsec;
140 to[1].tv_sec = from[1].tv_sec;
141 to[1].tv_nsec = from[1].tv_nsec;
150 Mono_Posix_Syscall_futimens(int fd, struct Mono_Posix_Timespec *tv)
152 struct timespec _tv[2];
153 struct timespec *ptv;
155 ptv = copy_utimens (_tv, tv);
157 return futimens (fd, ptv);
159 #endif /* def HAVE_FUTIMENS */
161 #ifdef HAVE_UTIMENSAT
163 Mono_Posix_Syscall_utimensat(int dirfd, const char *pathname, struct Mono_Posix_Timespec *tv, int flags)
165 struct timespec _tv[2];
166 struct timespec *ptv;
168 ptv = copy_utimens (_tv, tv);
170 return utimensat (dirfd, pathname, ptv, flags);
172 #endif /* def HAVE_UTIMENSAT */