* support/Makefile.am: Add utime.c and sys-time.c to the build.
authorJonathan Pryor <jpryor@novell.com>
Fri, 12 Nov 2004 15:07:39 +0000 (15:07 -0000)
committerJonathan Pryor <jpryor@novell.com>
Fri, 12 Nov 2004 15:07:39 +0000 (15:07 -0000)
  * support/sys-time.c: Added; export gettimeofday(2), settimeofday(2), utimes(2).
  * support/sys-stat.c: Export mknod(2).
  * support/utime.c: Added; export utime(2).

svn path=/trunk/mono/; revision=36053

support/Makefile.am
support/sys-stat.c
support/sys-time.c [new file with mode: 0644]
support/utime.c [new file with mode: 0644]

index 0b6cc241ac2709cd3f575aa120cebce65963a1b4..8b36de371d3280ae164aa56d912abcd594d12f24 100644 (file)
@@ -24,9 +24,11 @@ MPH_SOURCE = \
        sys-mount.c \
        sys-sendfile.c \
        sys-stat.c \
+       sys-time.c \
        sys-wait.c \
        time.c \
-       unistd.c
+       unistd.c \
+       utime.c
 
 if HAVE_ZLIB
 libMonoPosixHelper_la_SOURCES = \
index 3ff4888316ed68b9e3bb7568a78c392c75f9ef5e..49405e51e1d5c2861fa21607aa798bb3109a089b 100644 (file)
@@ -111,6 +111,14 @@ Mono_Posix_Syscall_lstat (const char *file_name, struct Mono_Posix_Syscall_Stat
        return r;
 }
 
+gint32
+Mono_Posix_Syscall_mknod (const char *pathname, guint32 mode, mph_dev_t dev)
+{
+       if (Mono_Posix_FromFilePermissions (mode, &mode) == -1)
+               return -1;
+       return mknod (pathname, mode, dev);
+}
+
 G_END_DECLS
 
 /*
diff --git a/support/sys-time.c b/support/sys-time.c
new file mode 100644 (file)
index 0000000..0b41489
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * <sys/stat.h> wrapper functions.
+ *
+ * Authors:
+ *   Jonathan Pryor (jonpryor@vt.edu)
+ *
+ * Copyright (C) 2004 Jonathan Pryor
+ */
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <string.h>
+
+#include "map.h"
+#include "mph.h"
+
+G_BEGIN_DECLS
+
+struct Mono_Posix_Syscall_Timeval {
+       /* time_t */      mph_time_t  tv_sec;   /* seconds */
+       /* suseconds_t */ gint64      tv_usec;  /* microseconds */
+};
+
+struct Mono_Posix_Syscall_Timezone {
+       int tz_minuteswest;  /* minutes W of Greenwich */
+       int tz_dsttime;      /* ignored */
+};
+
+gint32
+Mono_Posix_Syscall_gettimeofday (
+       struct Mono_Posix_Syscall_Timeval *tv,
+       struct Mono_Posix_Syscall_Timezone *tz)
+{
+       struct timeval _tv;
+       struct timezone _tz;
+       int r;
+
+       r = gettimeofday (&_tv, &_tz);
+
+       if (r == 0) {
+               if (tv) {
+                       tv->tv_sec  = _tv.tv_sec;
+                       tv->tv_usec = _tv.tv_usec;
+               }
+               if (tz) {
+                       tz->tz_minuteswest = _tz.tz_minuteswest;
+                       tz->tz_dsttime     = 0;
+               }
+       }
+
+       return r;
+}
+
+gint32
+Mono_Posix_Syscall_settimeofday (
+       const struct Mono_Posix_Syscall_Timeval *tv,
+       const struct Mono_Posix_Syscall_Timezone *tz)
+{
+       struct timeval _tv   = {0};
+       struct timeval *ptv  = NULL;
+       struct timezone _tz  = {0};
+       struct timezone *ptz = NULL;
+       int r;
+
+       if (tv) {
+               _tv.tv_sec  = tv->tv_sec;
+               _tv.tv_usec = tv->tv_usec;
+               ptv = &_tv;
+       }
+       if (tz) {
+               _tz.tz_minuteswest = tz->tz_minuteswest;
+               _tz.tz_dsttime = 0;
+               ptz = &_tz;
+       }
+
+       r = settimeofday (ptv, ptz);
+
+       return r;
+}
+
+gint32
+Mono_Posix_Syscall_utimes (const char *filename,
+       struct Mono_Posix_Syscall_Timeval *tv)
+{
+       struct timeval _tv;
+       struct timeval *ptv = NULL;
+
+       if (tv) {
+               _tv.tv_sec  = tv->tv_sec;
+               _tv.tv_usec = tv->tv_usec;
+               ptv = &_tv;
+       }
+
+       return utimes (filename, ptv);
+}
+
+G_END_DECLS
+
+/*
+ * vim: noexpandtab
+ */
diff --git a/support/utime.c b/support/utime.c
new file mode 100644 (file)
index 0000000..4e40c68
--- /dev/null
@@ -0,0 +1,41 @@
+/*
+ * <stdio.h> wrapper functions.
+ *
+ * Authors:
+ *   Jonathan Pryor (jonpryor@vt.edu)
+ *
+ * Copyright (C) 2004 Jonathan Pryor
+ */
+
+#include <sys/types.h>
+#include <utime.h>
+
+#include "mph.h"
+
+G_BEGIN_DECLS
+
+struct Mono_Posix_Utimbuf {
+       /* time_t */ mph_time_t actime;   /* access time */
+       /* time_t */ mph_time_t modtime;  /* modification time */
+};
+
+gint32
+Mono_Posix_Syscall_utime (const char *filename, struct Mono_Posix_Utimbuf *buf)
+{
+       struct utimbuf _buf;
+       struct utimbuf *pbuf = NULL;
+
+       if (buf) {
+               _buf.actime  = buf->actime;
+               _buf.modtime = buf->modtime;
+               pbuf = &_buf;
+       }
+
+       return utime (filename, pbuf);
+}
+
+G_END_DECLS
+
+/*
+ * vim: noexpandtab
+ */