2006-01-31 Lluis Sanchez Gual <lluis@novell.com>
[mono.git] / support / unistd.c
index f12513baf989b9d7b03071e4dc21e8f38c5ea2c2..740afe79e5841654d539cb68ebe9918910c1e477 100644 (file)
@@ -4,7 +4,7 @@
  * Authors:
  *   Jonathan Pryor (jonpryor@vt.edu)
  *
- * Copyright (C) 2004 Jonathan Pryor
+ * Copyright (C) 2004-2005 Jonathan Pryor
  */
 
 #ifndef _GNU_SOURCE
@@ -27,11 +27,7 @@ G_BEGIN_DECLS
 mph_off_t
 Mono_Posix_Syscall_lseek (gint32 fd, mph_off_t offset, gint32 whence)
 {
-       short _whence;
        mph_return_if_off_t_overflow (offset);
-       if (Mono_Posix_FromSeekFlags (whence, &_whence) == -1)
-               return -1;
-       whence = _whence;
 
        return lseek (fd, offset, whence);
 }
@@ -44,7 +40,7 @@ Mono_Posix_Syscall_read (gint32 fd, void *buf, mph_size_t count)
 }
 
 mph_ssize_t
-Mono_Posix_Syscall_write (gint32 fd, const void *buf, mph_size_t count)
+Mono_Posix_Syscall_write (gint32 fd, void *buf, mph_size_t count)
 {
        mph_return_if_size_t_overflow (count);
        return write (fd, buf, (size_t) count);
@@ -60,7 +56,7 @@ Mono_Posix_Syscall_pread (gint32 fd, void *buf, mph_size_t count, mph_off_t offs
 }
 
 mph_ssize_t
-Mono_Posix_Syscall_pwrite (gint32 fd, const void *buf, mph_size_t count, mph_off_t offset)
+Mono_Posix_Syscall_pwrite (gint32 fd, void *buf, mph_size_t count, mph_off_t offset)
 {
        mph_return_if_size_t_overflow (count);
        mph_return_if_off_t_overflow (offset);
@@ -86,7 +82,7 @@ Mono_Posix_Syscall_pipe (gint32 *reading, gint32 *writing)
        return r;
 }
 
-char*
+void*
 Mono_Posix_Syscall_getcwd (char *buf, mph_size_t size)
 {
        mph_return_val_if_size_t_overflow (size, NULL);
@@ -94,34 +90,37 @@ Mono_Posix_Syscall_getcwd (char *buf, mph_size_t size)
 }
 
 gint64
-Mono_Posix_Syscall_fpathconf (int filedes, int name)
+Mono_Posix_Syscall_fpathconf (int filedes, int name, int defaultError)
 {
-       if (Mono_Posix_FromPathConf (name, &name) == -1)
+       errno = defaultError;
+       if (Mono_Posix_FromPathconfName (name, &name) == -1)
                return -1;
        return fpathconf (filedes, name);
 }
 
 gint64
-Mono_Posix_Syscall_pathconf (char *path, int name)
+Mono_Posix_Syscall_pathconf (const char *path, int name, int defaultError)
 {
-       if (Mono_Posix_FromPathConf (name, &name) == -1)
+       errno = defaultError;
+       if (Mono_Posix_FromPathconfName (name, &name) == -1)
                return -1;
        return pathconf (path, name);
 }
 
 gint64
-Mono_Posix_Syscall_sysconf (int name)
+Mono_Posix_Syscall_sysconf (int name, int defaultError)
 {
-       if (Mono_Posix_FromSysConf (name, &name) == -1)
+       errno = defaultError;
+       if (Mono_Posix_FromSysconfName (name, &name) == -1)
                return -1;
        return sysconf (name);
 }
 
-gint64
+mph_size_t
 Mono_Posix_Syscall_confstr (int name, char *buf, mph_size_t len)
 {
        mph_return_if_size_t_overflow (len);
-       if (Mono_Posix_FromConfStr (name, &name) == -1)
+       if (Mono_Posix_FromConfstrName (name, &name) == -1)
                return -1;
        return confstr (name, buf, (size_t) len);
 }
@@ -187,19 +186,23 @@ Mono_Posix_Syscall_sethostid (gint64 hostid)
 }
 #endif /* def HAVE_SETHOSTID */
 
+#ifdef HAVE_GETDOMAINNAME
 gint32
 Mono_Posix_Syscall_getdomainname (char *name, mph_size_t len)
 {
        mph_return_if_size_t_overflow (len);
        return getdomainname (name, (size_t) len);
 }
+#endif /* def HAVE_GETDOMAINNAME */
 
+#ifdef HAVE_SETDOMAINNAME
 gint32
 Mono_Posix_Syscall_setdomainname (const char *name, mph_size_t len)
 {
        mph_return_if_size_t_overflow (len);
        return setdomainname (name, (size_t) len);
 }
+#endif /* def HAVE_SETDOMAINNAME */
 
 gint32
 Mono_Posix_Syscall_truncate (const char *path, mph_off_t length)
@@ -219,7 +222,7 @@ gint32
 Mono_Posix_Syscall_lockf (int fd, int cmd, mph_off_t len)
 {
        mph_return_if_off_t_overflow (len);
-       if (Mono_Posix_FromLockFlags (cmd, &cmd) == -1)
+       if (Mono_Posix_FromLockfCommand (cmd, &cmd) == -1)
                return -1;
        return lockf (fd, cmd, (off_t) len);
 }
@@ -232,6 +235,39 @@ Mono_Posix_Syscall_swab (void *from, void *to, mph_ssize_t n)
        swab (from, to, (ssize_t) n);
 }
 
+int
+Mono_Posix_Syscall_encrypt (void* block, int edflag)
+{
+       errno = 0;
+       encrypt (block, edflag);
+       return errno == 0 ? 0 : -1;
+}
+
+int
+Mono_Posix_Syscall_setusershell (void)
+{
+       errno = 0;
+       setusershell ();
+       return errno == 0 ? 0 : -1;
+}
+
+int
+Mono_Posix_Syscall_endusershell (void)
+{
+       errno = 0;
+       endusershell ();
+       return errno == 0 ? 0 : -1;
+}
+
+int
+Mono_Posix_Syscall_sync (void)
+{
+       errno = 0;
+       sync ();
+       return errno == 0 ? 0 : -1;
+}
+
+
 G_END_DECLS
 
 /*