*/
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
+#endif /* ndef HAVE_SYS_TIME_H */
#ifdef HAVE_SYS_POLL_H
#include <sys/poll.h>
#endif /* ndef HAVE_SYS_POLL_H */
#ifdef HAVE_SYS_MMAN_H
#include <sys/mman.h>
#endif /* ndef HAVE_SYS_MMAN_H */
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif /* ndef HAVE_UNISTD_H */
#include <fcntl.h>
#include <signal.h>
#ifdef HAVE_POLL_H
#ifdef HAVE_SYSLOG_H
#include <syslog.h>
#endif /* ndef HAVE_SYSLOG_H */
+#ifdef HAVE_DIRENT_H
#include <dirent.h>
+#endif /* ndef HAVE_DIRENT_H */
+#ifdef HAVE_UTIME_H
#include <utime.h>
+#endif /* ndef HAVE_UTIME_H */
+#include <time.h>
#include "mph.h"
#include "map.h"
? CNM_MAXINT64 \
: (g_assert_not_reached (), 0))
-#ifdef DEBUG
-#define _cnm_dump_(to_t,from) \
- printf ("# %s -> %s: min=%llx; max=%llx; value=%llx; lt=%i; l0=%i; gt=%i; e=%i\n", \
+#ifdef _CNM_DUMP
+#define _cnm_dump(to_t,from) \
+ printf ("# %s -> %s: uns=%i; min=%llx; max=%llx; value=%llx; lt=%i; l0=%i; gt=%i; e=%i\n", \
#from, #to_t, \
- (gint64) (_cnm_integral_type_min(to_t)), \
+ (int) _cnm_integral_type_is_unsigned (to_t), \
+ (gint64) (_cnm_integral_type_min (to_t)), \
(gint64) (_cnm_integral_type_max (to_t)), \
(gint64) (from), \
- (_cnm_integral_type_min (to_t) <= from), \
+ (((gint64) _cnm_integral_type_min (to_t)) <= (gint64) from), \
(from < 0), \
- /* (_cnm_integral_type_max (to_t) >= from) */ \
- (from <= _cnm_integral_type_max (to_t)), \
- ((_cnm_integral_type_min(to_t) >= from) && \
- ((from < 0) ? 1 : (from <= _cnm_integral_type_max(to_t)))) \
+ (((guint64) from) <= (guint64) _cnm_integral_type_max (to_t)), \
+ !((int) _cnm_integral_type_is_unsigned (to_t) \
+ ? ((0 <= from) && \
+ ((guint64) from <= (guint64) _cnm_integral_type_max (to_t))) \
+ : ((gint64) _cnm_integral_type_min(to_t) <= (gint64) from && \
+ (guint64) from <= (guint64) _cnm_integral_type_max (to_t))) \
)
-#else
-#define _cnm_dump_(to_t, from) do {} while (0)
-#endif
+#else /* ndef _CNM_DUMP */
+#define _cnm_dump(to_t, from) do {} while (0)
+#endif /* def _CNM_DUMP */
+#ifdef DEBUG
#define _cnm_return_val_if_overflow(to_t,from,val) G_STMT_START { \
- if (!(_cnm_integral_type_min(to_t) <= from && \
- ((from < 0) || (from <= _cnm_integral_type_max(to_t))))) { \
- _cnm_dump_(to_t, from); \
+ int uns = _cnm_integral_type_is_unsigned (to_t); \
+ gint64 min = (gint64) _cnm_integral_type_min (to_t); \
+ guint64 max = (guint64) _cnm_integral_type_max (to_t); \
+ gint64 sf = (gint64) from; \
+ guint64 uf = (guint64) from; \
+ if (!(uns ? ((0 <= from) && (uf <= max)) \
+ : (min <= sf && (from < 0 || uf <= max)))) { \
+ _cnm_dump(to_t, from); \
errno = EOVERFLOW; \
return (val); \
} \
} G_STMT_END
+#else /* !def DEBUG */
+/* don't do any overflow checking */
+#define _cnm_return_val_if_overflow(to_t,from,val) G_STMT_START { \
+ } G_STMT_END
+#endif /* def DEBUG */
int Mono_Posix_FromAccessModes (int x, int *r)
{
return 0;
}
+int Mono_Posix_FromEpollEvents (unsigned int x, unsigned int *r)
+{
+ *r = 0;
+ if ((x & Mono_Posix_EpollEvents_EPOLLERR) == Mono_Posix_EpollEvents_EPOLLERR)
+#ifdef EPOLLERR
+ *r |= EPOLLERR;
+#else /* def EPOLLERR */
+ {errno = EINVAL; return -1;}
+#endif /* ndef EPOLLERR */
+ if ((x & Mono_Posix_EpollEvents_EPOLLET) == Mono_Posix_EpollEvents_EPOLLET)
+#ifdef EPOLLET
+ *r |= EPOLLET;
+#else /* def EPOLLET */
+ {errno = EINVAL; return -1;}
+#endif /* ndef EPOLLET */
+ if ((x & Mono_Posix_EpollEvents_EPOLLHUP) == Mono_Posix_EpollEvents_EPOLLHUP)
+#ifdef EPOLLHUP
+ *r |= EPOLLHUP;
+#else /* def EPOLLHUP */
+ {errno = EINVAL; return -1;}
+#endif /* ndef EPOLLHUP */
+ if ((x & Mono_Posix_EpollEvents_EPOLLIN) == Mono_Posix_EpollEvents_EPOLLIN)
+#ifdef EPOLLIN
+ *r |= EPOLLIN;
+#else /* def EPOLLIN */
+ {errno = EINVAL; return -1;}
+#endif /* ndef EPOLLIN */
+ if ((x & Mono_Posix_EpollEvents_EPOLLMSG) == Mono_Posix_EpollEvents_EPOLLMSG)
+#ifdef EPOLLMSG
+ *r |= EPOLLMSG;
+#else /* def EPOLLMSG */
+ {errno = EINVAL; return -1;}
+#endif /* ndef EPOLLMSG */
+ if ((x & Mono_Posix_EpollEvents_EPOLLONESHOT) == Mono_Posix_EpollEvents_EPOLLONESHOT)
+#ifdef EPOLLONESHOT
+ *r |= EPOLLONESHOT;
+#else /* def EPOLLONESHOT */
+ {errno = EINVAL; return -1;}
+#endif /* ndef EPOLLONESHOT */
+ if ((x & Mono_Posix_EpollEvents_EPOLLOUT) == Mono_Posix_EpollEvents_EPOLLOUT)
+#ifdef EPOLLOUT
+ *r |= EPOLLOUT;
+#else /* def EPOLLOUT */
+ {errno = EINVAL; return -1;}
+#endif /* ndef EPOLLOUT */
+ if ((x & Mono_Posix_EpollEvents_EPOLLPRI) == Mono_Posix_EpollEvents_EPOLLPRI)
+#ifdef EPOLLPRI
+ *r |= EPOLLPRI;
+#else /* def EPOLLPRI */
+ {errno = EINVAL; return -1;}
+#endif /* ndef EPOLLPRI */
+ if ((x & Mono_Posix_EpollEvents_EPOLLRDBAND) == Mono_Posix_EpollEvents_EPOLLRDBAND)
+#ifdef EPOLLRDBAND
+ *r |= EPOLLRDBAND;
+#else /* def EPOLLRDBAND */
+ {errno = EINVAL; return -1;}
+#endif /* ndef EPOLLRDBAND */
+ if ((x & Mono_Posix_EpollEvents_EPOLLRDHUP) == Mono_Posix_EpollEvents_EPOLLRDHUP)
+#ifdef EPOLLRDHUP
+ *r |= EPOLLRDHUP;
+#else /* def EPOLLRDHUP */
+ {errno = EINVAL; return -1;}
+#endif /* ndef EPOLLRDHUP */
+ if ((x & Mono_Posix_EpollEvents_EPOLLRDNORM) == Mono_Posix_EpollEvents_EPOLLRDNORM)
+#ifdef EPOLLRDNORM
+ *r |= EPOLLRDNORM;
+#else /* def EPOLLRDNORM */
+ {errno = EINVAL; return -1;}
+#endif /* ndef EPOLLRDNORM */
+ if ((x & Mono_Posix_EpollEvents_EPOLLWRBAND) == Mono_Posix_EpollEvents_EPOLLWRBAND)
+#ifdef EPOLLWRBAND
+ *r |= EPOLLWRBAND;
+#else /* def EPOLLWRBAND */
+ {errno = EINVAL; return -1;}
+#endif /* ndef EPOLLWRBAND */
+ if ((x & Mono_Posix_EpollEvents_EPOLLWRNORM) == Mono_Posix_EpollEvents_EPOLLWRNORM)
+#ifdef EPOLLWRNORM
+ *r |= EPOLLWRNORM;
+#else /* def EPOLLWRNORM */
+ {errno = EINVAL; return -1;}
+#endif /* ndef EPOLLWRNORM */
+ if (x == 0)
+ return 0;
+ return 0;
+}
+
+int Mono_Posix_ToEpollEvents (unsigned int x, unsigned int *r)
+{
+ *r = 0;
+ if (x == 0)
+ return 0;
+#ifdef EPOLLERR
+ if ((x & EPOLLERR) == EPOLLERR)
+ *r |= Mono_Posix_EpollEvents_EPOLLERR;
+#endif /* ndef EPOLLERR */
+#ifdef EPOLLET
+ if ((x & EPOLLET) == EPOLLET)
+ *r |= Mono_Posix_EpollEvents_EPOLLET;
+#endif /* ndef EPOLLET */
+#ifdef EPOLLHUP
+ if ((x & EPOLLHUP) == EPOLLHUP)
+ *r |= Mono_Posix_EpollEvents_EPOLLHUP;
+#endif /* ndef EPOLLHUP */
+#ifdef EPOLLIN
+ if ((x & EPOLLIN) == EPOLLIN)
+ *r |= Mono_Posix_EpollEvents_EPOLLIN;
+#endif /* ndef EPOLLIN */
+#ifdef EPOLLMSG
+ if ((x & EPOLLMSG) == EPOLLMSG)
+ *r |= Mono_Posix_EpollEvents_EPOLLMSG;
+#endif /* ndef EPOLLMSG */
+#ifdef EPOLLONESHOT
+ if ((x & EPOLLONESHOT) == EPOLLONESHOT)
+ *r |= Mono_Posix_EpollEvents_EPOLLONESHOT;
+#endif /* ndef EPOLLONESHOT */
+#ifdef EPOLLOUT
+ if ((x & EPOLLOUT) == EPOLLOUT)
+ *r |= Mono_Posix_EpollEvents_EPOLLOUT;
+#endif /* ndef EPOLLOUT */
+#ifdef EPOLLPRI
+ if ((x & EPOLLPRI) == EPOLLPRI)
+ *r |= Mono_Posix_EpollEvents_EPOLLPRI;
+#endif /* ndef EPOLLPRI */
+#ifdef EPOLLRDBAND
+ if ((x & EPOLLRDBAND) == EPOLLRDBAND)
+ *r |= Mono_Posix_EpollEvents_EPOLLRDBAND;
+#endif /* ndef EPOLLRDBAND */
+#ifdef EPOLLRDHUP
+ if ((x & EPOLLRDHUP) == EPOLLRDHUP)
+ *r |= Mono_Posix_EpollEvents_EPOLLRDHUP;
+#endif /* ndef EPOLLRDHUP */
+#ifdef EPOLLRDNORM
+ if ((x & EPOLLRDNORM) == EPOLLRDNORM)
+ *r |= Mono_Posix_EpollEvents_EPOLLRDNORM;
+#endif /* ndef EPOLLRDNORM */
+#ifdef EPOLLWRBAND
+ if ((x & EPOLLWRBAND) == EPOLLWRBAND)
+ *r |= Mono_Posix_EpollEvents_EPOLLWRBAND;
+#endif /* ndef EPOLLWRBAND */
+#ifdef EPOLLWRNORM
+ if ((x & EPOLLWRNORM) == EPOLLWRNORM)
+ *r |= Mono_Posix_EpollEvents_EPOLLWRNORM;
+#endif /* ndef EPOLLWRNORM */
+ return 0;
+}
+
+int Mono_Posix_FromEpollFlags (int x, int *r)
+{
+ *r = 0;
+ if ((x & Mono_Posix_EpollFlags_EPOLL_CLOEXEC) == Mono_Posix_EpollFlags_EPOLL_CLOEXEC)
+#ifdef EPOLL_CLOEXEC
+ *r |= EPOLL_CLOEXEC;
+#else /* def EPOLL_CLOEXEC */
+ {errno = EINVAL; return -1;}
+#endif /* ndef EPOLL_CLOEXEC */
+ if ((x & Mono_Posix_EpollFlags_EPOLL_NONBLOCK) == Mono_Posix_EpollFlags_EPOLL_NONBLOCK)
+#ifdef EPOLL_NONBLOCK
+ *r |= EPOLL_NONBLOCK;
+#else /* def EPOLL_NONBLOCK */
+ {errno = EINVAL; return -1;}
+#endif /* ndef EPOLL_NONBLOCK */
+ if (x == 0)
+ return 0;
+ return 0;
+}
+
+int Mono_Posix_ToEpollFlags (int x, int *r)
+{
+ *r = 0;
+ if (x == 0)
+ return 0;
+#ifdef EPOLL_CLOEXEC
+ if ((x & EPOLL_CLOEXEC) == EPOLL_CLOEXEC)
+ *r |= Mono_Posix_EpollFlags_EPOLL_CLOEXEC;
+#endif /* ndef EPOLL_CLOEXEC */
+#ifdef EPOLL_NONBLOCK
+ if ((x & EPOLL_NONBLOCK) == EPOLL_NONBLOCK)
+ *r |= Mono_Posix_EpollFlags_EPOLL_NONBLOCK;
+#endif /* ndef EPOLL_NONBLOCK */
+ return 0;
+}
+
int Mono_Posix_FromErrno (int x, int *r)
{
*r = 0;
#else /* def DEFFILEMODE */
{/* Ignoring Mono_Posix_FilePermissions_DEFFILEMODE, as it is constructed from other values */}
#endif /* ndef DEFFILEMODE */
- if (x == Mono_Posix_FilePermissions_S_IFBLK)
+ if ((x & Mono_Posix_FilePermissions_S_IFMT) == Mono_Posix_FilePermissions_S_IFBLK)
#ifdef S_IFBLK
- {*r = S_IFBLK; return 0;}
+ *r |= S_IFBLK;
#else /* def S_IFBLK */
{errno = EINVAL; return -1;}
#endif /* ndef S_IFBLK */
- if (x == Mono_Posix_FilePermissions_S_IFCHR)
+ if ((x & Mono_Posix_FilePermissions_S_IFMT) == Mono_Posix_FilePermissions_S_IFCHR)
#ifdef S_IFCHR
- {*r = S_IFCHR; return 0;}
+ *r |= S_IFCHR;
#else /* def S_IFCHR */
{errno = EINVAL; return -1;}
#endif /* ndef S_IFCHR */
- if (x == Mono_Posix_FilePermissions_S_IFDIR)
+ if ((x & Mono_Posix_FilePermissions_S_IFMT) == Mono_Posix_FilePermissions_S_IFDIR)
#ifdef S_IFDIR
- {*r = S_IFDIR; return 0;}
+ *r |= S_IFDIR;
#else /* def S_IFDIR */
{errno = EINVAL; return -1;}
#endif /* ndef S_IFDIR */
- if (x == Mono_Posix_FilePermissions_S_IFIFO)
+ if ((x & Mono_Posix_FilePermissions_S_IFMT) == Mono_Posix_FilePermissions_S_IFIFO)
#ifdef S_IFIFO
- {*r = S_IFIFO; return 0;}
+ *r |= S_IFIFO;
#else /* def S_IFIFO */
{errno = EINVAL; return -1;}
#endif /* ndef S_IFIFO */
- if (x == Mono_Posix_FilePermissions_S_IFLNK)
+ if ((x & Mono_Posix_FilePermissions_S_IFMT) == Mono_Posix_FilePermissions_S_IFLNK)
#ifdef S_IFLNK
- {*r = S_IFLNK; return 0;}
+ *r |= S_IFLNK;
#else /* def S_IFLNK */
{errno = EINVAL; return -1;}
#endif /* ndef S_IFLNK */
- if (x == Mono_Posix_FilePermissions_S_IFMT)
+ if ((x & Mono_Posix_FilePermissions_S_IFMT) == Mono_Posix_FilePermissions_S_IFMT)
#ifdef S_IFMT
- {*r = S_IFMT; return 0;}
+ *r |= S_IFMT;
#else /* def S_IFMT */
- {errno = EINVAL; return -1;}
+ {/* Ignoring Mono_Posix_FilePermissions_S_IFMT, as it is constructed from other values */}
#endif /* ndef S_IFMT */
- if (x == Mono_Posix_FilePermissions_S_IFREG)
+ if ((x & Mono_Posix_FilePermissions_S_IFMT) == Mono_Posix_FilePermissions_S_IFREG)
#ifdef S_IFREG
- {*r = S_IFREG; return 0;}
+ *r |= S_IFREG;
#else /* def S_IFREG */
{errno = EINVAL; return -1;}
#endif /* ndef S_IFREG */
- if (x == Mono_Posix_FilePermissions_S_IFSOCK)
+ if ((x & Mono_Posix_FilePermissions_S_IFMT) == Mono_Posix_FilePermissions_S_IFSOCK)
#ifdef S_IFSOCK
- {*r = S_IFSOCK; return 0;}
+ *r |= S_IFSOCK;
#else /* def S_IFSOCK */
{errno = EINVAL; return -1;}
#endif /* ndef S_IFSOCK */
*r |= Mono_Posix_FilePermissions_DEFFILEMODE;
#endif /* ndef DEFFILEMODE */
#ifdef S_IFBLK
- if (x == S_IFBLK)
- {*r = Mono_Posix_FilePermissions_S_IFBLK; return 0;}
+ if ((x & S_IFMT) == S_IFBLK)
+ *r |= Mono_Posix_FilePermissions_S_IFBLK;
#endif /* ndef S_IFBLK */
#ifdef S_IFCHR
- if (x == S_IFCHR)
- {*r = Mono_Posix_FilePermissions_S_IFCHR; return 0;}
+ if ((x & S_IFMT) == S_IFCHR)
+ *r |= Mono_Posix_FilePermissions_S_IFCHR;
#endif /* ndef S_IFCHR */
#ifdef S_IFDIR
- if (x == S_IFDIR)
- {*r = Mono_Posix_FilePermissions_S_IFDIR; return 0;}
+ if ((x & S_IFMT) == S_IFDIR)
+ *r |= Mono_Posix_FilePermissions_S_IFDIR;
#endif /* ndef S_IFDIR */
#ifdef S_IFIFO
- if (x == S_IFIFO)
- {*r = Mono_Posix_FilePermissions_S_IFIFO; return 0;}
+ if ((x & S_IFMT) == S_IFIFO)
+ *r |= Mono_Posix_FilePermissions_S_IFIFO;
#endif /* ndef S_IFIFO */
#ifdef S_IFLNK
- if (x == S_IFLNK)
- {*r = Mono_Posix_FilePermissions_S_IFLNK; return 0;}
+ if ((x & S_IFMT) == S_IFLNK)
+ *r |= Mono_Posix_FilePermissions_S_IFLNK;
#endif /* ndef S_IFLNK */
#ifdef S_IFMT
- if (x == S_IFMT)
- {*r = Mono_Posix_FilePermissions_S_IFMT; return 0;}
+ if ((x & S_IFMT) == S_IFMT)
+ *r |= Mono_Posix_FilePermissions_S_IFMT;
#endif /* ndef S_IFMT */
#ifdef S_IFREG
- if (x == S_IFREG)
- {*r = Mono_Posix_FilePermissions_S_IFREG; return 0;}
+ if ((x & S_IFMT) == S_IFREG)
+ *r |= Mono_Posix_FilePermissions_S_IFREG;
#endif /* ndef S_IFREG */
#ifdef S_IFSOCK
- if (x == S_IFSOCK)
- {*r = Mono_Posix_FilePermissions_S_IFSOCK; return 0;}
+ if ((x & S_IFMT) == S_IFSOCK)
+ *r |= Mono_Posix_FilePermissions_S_IFSOCK;
#endif /* ndef S_IFSOCK */
#ifdef S_IRGRP
if ((x & S_IRGRP) == S_IRGRP)
return 0;
}
+#ifdef HAVE_STRUCT_FLOCK
+int
+Mono_Posix_FromFlock (struct Mono_Posix_Flock *from, struct flock *to)
+{
+ _cnm_return_val_if_overflow (off_t, from->l_start, -1);
+ _cnm_return_val_if_overflow (off_t, from->l_len, -1);
+ _cnm_return_val_if_overflow (pid_t, from->l_pid, -1);
+
+ memset (to, 0, sizeof(*to));
+
+ if (Mono_Posix_FromLockType (from->l_type, &to->l_type) != 0) {
+ return -1;
+ }
+ if (Mono_Posix_FromSeekFlags (from->l_whence, &to->l_whence) != 0) {
+ return -1;
+ }
+ to->l_start = from->l_start;
+ to->l_len = from->l_len;
+ to->l_pid = from->l_pid;
+
+ return 0;
+}
+#endif /* ndef HAVE_STRUCT_FLOCK */
+
+
+#ifdef HAVE_STRUCT_FLOCK
+int
+Mono_Posix_ToFlock (struct flock *from, struct Mono_Posix_Flock *to)
+{
+ _cnm_return_val_if_overflow (gint64, from->l_start, -1);
+ _cnm_return_val_if_overflow (gint64, from->l_len, -1);
+ _cnm_return_val_if_overflow (int, from->l_pid, -1);
+
+ memset (to, 0, sizeof(*to));
+
+ if (Mono_Posix_ToLockType (from->l_type, &to->l_type) != 0) {
+ return -1;
+ }
+ if (Mono_Posix_ToSeekFlags (from->l_whence, &to->l_whence) != 0) {
+ return -1;
+ }
+ to->l_start = from->l_start;
+ to->l_len = from->l_len;
+ to->l_pid = from->l_pid;
+
+ return 0;
+}
+#endif /* ndef HAVE_STRUCT_FLOCK */
+
+
int Mono_Posix_FromLockType (short x, short *r)
{
*r = 0;
#else /* def ST_APPEND */
{errno = EINVAL; return -1;}
#endif /* ndef ST_APPEND */
+ if ((x & Mono_Posix_MountFlags_ST_BIND) == Mono_Posix_MountFlags_ST_BIND)
+#ifdef ST_BIND
+ *r |= ST_BIND;
+#else /* def ST_BIND */
+ {errno = EINVAL; return -1;}
+#endif /* ndef ST_BIND */
if ((x & Mono_Posix_MountFlags_ST_IMMUTABLE) == Mono_Posix_MountFlags_ST_IMMUTABLE)
#ifdef ST_IMMUTABLE
*r |= ST_IMMUTABLE;
#else /* def ST_NODIRATIME */
{errno = EINVAL; return -1;}
#endif /* ndef ST_NODIRATIME */
+ if ((x & Mono_Posix_MountFlags_ST_NOEXEC) == Mono_Posix_MountFlags_ST_NOEXEC)
+#ifdef ST_NOEXEC
+ *r |= ST_NOEXEC;
+#else /* def ST_NOEXEC */
+ {errno = EINVAL; return -1;}
+#endif /* ndef ST_NOEXEC */
if ((x & Mono_Posix_MountFlags_ST_NOSUID) == Mono_Posix_MountFlags_ST_NOSUID)
#ifdef ST_NOSUID
*r |= ST_NOSUID;
#else /* def ST_RDONLY */
{errno = EINVAL; return -1;}
#endif /* ndef ST_RDONLY */
+ if ((x & Mono_Posix_MountFlags_ST_REMOUNT) == Mono_Posix_MountFlags_ST_REMOUNT)
+#ifdef ST_REMOUNT
+ *r |= ST_REMOUNT;
+#else /* def ST_REMOUNT */
+ {errno = EINVAL; return -1;}
+#endif /* ndef ST_REMOUNT */
if ((x & Mono_Posix_MountFlags_ST_SYNCHRONOUS) == Mono_Posix_MountFlags_ST_SYNCHRONOUS)
#ifdef ST_SYNCHRONOUS
*r |= ST_SYNCHRONOUS;
if ((x & ST_APPEND) == ST_APPEND)
*r |= Mono_Posix_MountFlags_ST_APPEND;
#endif /* ndef ST_APPEND */
+#ifdef ST_BIND
+ if ((x & ST_BIND) == ST_BIND)
+ *r |= Mono_Posix_MountFlags_ST_BIND;
+#endif /* ndef ST_BIND */
#ifdef ST_IMMUTABLE
if ((x & ST_IMMUTABLE) == ST_IMMUTABLE)
*r |= Mono_Posix_MountFlags_ST_IMMUTABLE;
if ((x & ST_NODIRATIME) == ST_NODIRATIME)
*r |= Mono_Posix_MountFlags_ST_NODIRATIME;
#endif /* ndef ST_NODIRATIME */
+#ifdef ST_NOEXEC
+ if ((x & ST_NOEXEC) == ST_NOEXEC)
+ *r |= Mono_Posix_MountFlags_ST_NOEXEC;
+#endif /* ndef ST_NOEXEC */
#ifdef ST_NOSUID
if ((x & ST_NOSUID) == ST_NOSUID)
*r |= Mono_Posix_MountFlags_ST_NOSUID;
if ((x & ST_RDONLY) == ST_RDONLY)
*r |= Mono_Posix_MountFlags_ST_RDONLY;
#endif /* ndef ST_RDONLY */
+#ifdef ST_REMOUNT
+ if ((x & ST_REMOUNT) == ST_REMOUNT)
+ *r |= Mono_Posix_MountFlags_ST_REMOUNT;
+#endif /* ndef ST_REMOUNT */
#ifdef ST_SYNCHRONOUS
if ((x & ST_SYNCHRONOUS) == ST_SYNCHRONOUS)
*r |= Mono_Posix_MountFlags_ST_SYNCHRONOUS;
return 0;
}
+#ifdef HAVE_STRUCT_TIMESPEC
+int
+Mono_Posix_FromTimespec (struct Mono_Posix_Timespec *from, struct timespec *to)
+{
+ _cnm_return_val_if_overflow (time_t, from->tv_sec, -1);
+ _cnm_return_val_if_overflow (gint64, from->tv_nsec, -1);
+
+ memset (to, 0, sizeof(*to));
+
+ to->tv_sec = from->tv_sec;
+ to->tv_nsec = from->tv_nsec;
+
+ return 0;
+}
+#endif /* ndef HAVE_STRUCT_TIMESPEC */
+
+
+#ifdef HAVE_STRUCT_TIMESPEC
+int
+Mono_Posix_ToTimespec (struct timespec *from, struct Mono_Posix_Timespec *to)
+{
+ _cnm_return_val_if_overflow (gint64, from->tv_sec, -1);
+ _cnm_return_val_if_overflow (gint64, from->tv_nsec, -1);
+
+ memset (to, 0, sizeof(*to));
+
+ to->tv_sec = from->tv_sec;
+ to->tv_nsec = from->tv_nsec;
+
+ return 0;
+}
+#endif /* ndef HAVE_STRUCT_TIMESPEC */
+
+
#ifdef HAVE_STRUCT_TIMEVAL
int
Mono_Posix_FromTimeval (struct Mono_Posix_Timeval *from, struct timeval *to)
#endif /* ndef HAVE_STRUCT_TIMEZONE */
+#ifdef HAVE_STRUCT_UTIMBUF
+int
+Mono_Posix_FromUtimbuf (struct Mono_Posix_Utimbuf *from, struct utimbuf *to)
+{
+ _cnm_return_val_if_overflow (time_t, from->actime, -1);
+ _cnm_return_val_if_overflow (time_t, from->modtime, -1);
+
+ memset (to, 0, sizeof(*to));
+
+ to->actime = from->actime;
+ to->modtime = from->modtime;
+
+ return 0;
+}
+#endif /* ndef HAVE_STRUCT_UTIMBUF */
+
+
+#ifdef HAVE_STRUCT_UTIMBUF
+int
+Mono_Posix_ToUtimbuf (struct utimbuf *from, struct Mono_Posix_Utimbuf *to)
+{
+ _cnm_return_val_if_overflow (gint64, from->actime, -1);
+ _cnm_return_val_if_overflow (gint64, from->modtime, -1);
+
+ memset (to, 0, sizeof(*to));
+
+ to->actime = from->actime;
+ to->modtime = from->modtime;
+
+ return 0;
+}
+#endif /* ndef HAVE_STRUCT_UTIMBUF */
+
+
int Mono_Posix_FromWaitOptions (int x, int *r)
{
*r = 0;