Commit Graph
282 Commits
Author SHA1 Message Date
Jonas 'Sortie' Termansen 325982b65f Remove Mono_Posix_Syscall_utimes_bad
Welcome to the world of tomorrow! It's been almost a decade since this was
made obsolete in 2005. Nothing uses this function any longer. Additionally
it is completely broken as utimes takes a pointer to an array with two
timevals, but the code passes only a pointer to a single timeval.

This change is released under the MIT/X11 license.
2014-06-26 10:52:53 -04:00
Jonas 'Sortie' Termansen 82364ccaaa Use SIGPROF only if it is available
The SIGPROF signal is an XSI option and obsolescent in XSI. POSIX systems
are not required to have it.

This change is released under the MIT/X11 license.
2014-06-26 10:09:08 -04:00
Jonas 'Sortie' Termansen c765c61f57 Only include the <sys/param.h> header if available
The <sys/param.h> header is non-standard and usually not required if it isn't
available.

This change is released under the MIT/X11 license.
2014-06-26 09:57:42 -04:00
Jonas 'Sortie' Termansen 6479266304 Use <poll.h> to get poll rather than <sys/poll.h>
POSIX specifies <poll.h> as the standard header that declares the poll
function. Many systems provide <sys/poll.h> to be compatible with historical
practice. Prefer the <poll.h> header over <sys/poll.h> if it is available.

This change is released under the MIT/X11 license.
2014-06-26 09:57:34 -04:00
Zoltan Varga 6a197bad93 Fix a warning. 2014-06-22 21:38:24 +02:00
Alex Rønne Petersen ec0304a599 Remove unnecessary MPH_INTERNAL applied to a function definition.
This should be applied to prototypes, and it already is for
this function (in mph.h).
2014-06-10 03:15:16 +02:00
Alex Rønne Petersen b45527f44b Add missing prototypes to supportw.c. 2014-06-07 18:03:31 +02:00
Alex Rønne Petersen f35c6a0b07 Comment an unused function in minizip. 2014-06-07 18:03:19 +02:00
Alex Rønne Petersen 93e7f8691c Fix z_alloc () signature.
Yes, really. zlib really uses a 32-bit int here...
2014-06-07 18:02:29 +02:00
Alex Rønne Petersen 58ebad8f72 Add missing prototypes to Mono.Posix C sources. 2014-06-07 18:02:14 +02:00
Seth Jackson c38e27bc7b L_cuserid was removed from OpenBSD.
This change released under the MIT license with permission from the original
author Christian Weisgerber.
2014-05-26 17:21:27 -04:00
Jonathan Pryor d2b5279484 [Mono.Posix] Support OS X ENOATTR
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=19991

The original Mono.Unix.Native.Errno design used the Linux <errno.h>
constants and values...largely because it was easy.

As it turns out, this is also incomplete. The getxattr(2) defines
ENOATTR as a possible error code. On Linux, ENOATTR is an alias for
ENODATA [0]. On OS X, ENOATTR is _not_ an alias. Furthermore, since
ENOATTR is not a Linux errno value (it's an alias!),
Mono_Posix_ToErrno() couldn't check for the native ENOATTR value, so a
Syscall.GetLastError() call after a failing Syscall.getxattr() would
fail with a System.ArgumentOutOfRangeException:

	$ csharp -r:Mono.Posix.dll
	Mono C# Shell, type "help;" for help

	Enter statements below.
	csharp> using Mono.Unix.Native;
	csharp> byte[] value;
	csharp> Syscall.getxattr(".", "test", out value);
	-1
	csharp> Syscall.GetLastError();
	System.ArgumentOutOfRangeException: Current platform doesn't support this value.
	Parameter name: value
	93
		at Mono.Unix.Native.NativeConvert.ThrowArgumentException (System.Object value) [0x00000] in <filename unknown>:0
		at Mono.Unix.Native.NativeConvert.ToErrno (Int32 value) [0x00000] in <filename unknown>:0
		at Mono.Unix.Native.Stdlib.GetLastError () [0x00000] in <filename unknown>:0

The fix is to add an Errno.ENOATTR field [1].

The complication is one of what enum value to use: at present, the
Errno values are based on the Linux values. In the case of ENOATTR
(and others), there is no Linux value. Meanwhile, there is the
possibility of additional Linux error values; how do we future proof
ourselves?

This isn't a perfect solution, but it should punt the problem down the
road a bit: Errno is an `int` enum, and thus has large range. To
support the OS X values, we add 1000 to the OS X error value.

	/* OS X: <errno.h> */
	#define ENOATTR		93		/* Attribute not found */

	// C# Errno enum:
	public enum Errno : int {
		// ...
		ENOATTR = 1093,
	}

This gives us 0..1000 for POSIX+Linux error codes, 1000..2000 for OS X
specific error codes, and as new platforms require additional support
they can all start at multiples of 1000.

Hopefully no single *nix platform will add more than 1000 error codes...

[0]: http://linux.die.net/man/2/getxattr
[1]: Related part of the fix: add all the OTHER <errno.h> values that
     OS X includes but weren't included in the Errno enum.
2014-05-23 13:45:10 -04:00
Seth Jackson 256ec5591a Don't define _XOPEN_SOURCE on OpenBSD. With _XOPEN_SOURCE defined mincore() is not visible.
This change is licensed under the MIT license.
2014-05-23 00:06:44 -04:00
Joao Matos eefbe2d246 Fixed incomplete decompression bug in System.IO.Compression.DeflateStream.
Call zlib's inflate() even if no data was read from the stream, there might still be some data left to process.

Originally reported by Eric Roller, as Xamarin bugzilla #17183.
https://bugzilla.xamarin.com/show_bug.cgi?id=17183

Reviewed by Rodrigo Kumpera.
2014-02-13 16:52:55 -05:00
Alex Rønne Petersen 05f4546a96 Add a .gitignore file to support/minizip/ to ignore *.la *.lo files. 2013-10-27 01:15:45 +02:00
Aaron Bockover d075623275 bxc#13642: MacNetworkChange: implement using managed code
The previous version used SCNetworkReachability
in C inside libMonoPosixHelper. This was less
than ideal and made it more problematic for
supporting iOS as it doesn't actually link
MPH in.

Rewrite using P/Invokes directly into the
SCNetworkReachability APIs for Mac OS X and
iOS.

Fixes https://bugzilla.xamarin.com/show_bug.cgi?id=13642
for iOS and Mac OS X.
2013-10-10 12:35:47 -04:00
Steffen Kieß 9b824c31c8 Fix Syscall.readlink() for non-ascii targets
Syscall.readlink() currently returns an integer indicating the number of
bytes in the link. As buf contains chars, this value is useless if the
target contains non-ascii characters.

This commit creates a new overload which uses a byte array instead of a
StringBuilder and rewrites the old overload to return the number of chars
instead.

Fixes #11778 and #9611
2013-07-28 11:11:38 +02:00
Alex Rønne Petersen 78db50f208 Revert the use of mono_binary_search () in support/supportw.c.
This code can't depend on mono/utils and doesn't need the 'fixed'
implementation of bsearch () anyway since keys are never null.
2013-07-26 20:16:24 +02:00
Alex Rønne Petersen bd54b2b72d Add a mono_binary_search () function.
This is a replacement for bsearch () because some platforms
have bogus asserts in their implementations.
2013-07-26 16:24:50 +02:00
Zoltan Varga 5535c13577 Pass some defines in config.h instead of on the command line. 2013-06-01 09:14:29 +02:00
Zoltan Varga dbbb5ff89b Revert "Pass more defines in config.h instead of on the command line. Pass libgc defines to libgc only."
This reverts commit cff0ecb816.

Revert this as boehm-gc.c depends on the libgc defines.
2013-05-30 18:11:47 +02:00
Zoltan Varga cff0ecb816 Pass more defines in config.h instead of on the command line. Pass libgc defines to libgc only. 2013-05-30 10:59:05 +02:00
Aaron Bockover d4630d000b mac-reachability.c: update for C89isms
In response to Rodrigo's comments on PR 629.
2013-05-02 11:03:27 -04:00
Aaron Bockover 1ddafd7997 mac-reachability.c: enable for TARGET_IOS 2013-05-01 18:10:06 -04:00
Aaron Bockover ed5d39b1d7 NetworkChange: Support Mac OS X (bcx#12038)
Refactor System.Net.NetworkingInformation in order
to support multiple "providers"; previously only
Linux was ever supported for this API.

This patch provides basic support for Mac OS X
via the SystemConfiguration framework's
SCNetworkReachability API.

bxc#12038
2013-05-01 17:49:44 -04:00
Steffen Kieß f7b355721a Fix a crash in Mono.Posix.Syscall.getpwuid_r () on some systems when a uid is not found. Fixes #11770. 2013-04-18 20:35:30 +02:00
Zoltan Varga e70d60d39d Fix the build. 2013-03-28 06:24:09 +01:00
Jonathan Pryor 7a30dcccb9 Fix build break.
5329fab3 requires <sys/uio.h>, which wasn't being included.
2013-03-27 23:29:50 -04:00
Steffen Kieß 28e16142fa Add nanosecond resolution times to struct Stat 2013-03-27 13:45:50 +01:00
Steffen Kieß 5329fab38b Add various methods and flags to Syscall
* Add OpenFlags.O_CLOEXEC and OpenFlags.O_PATH

    * Add AtFlags for AT_* values

    * Add fdopendir, mkdtemp, futimens

    * Add readv, writev, preadv, pwritev

    * Add *at methods: openat, renameat, fchmodat, fstatat, utimensat,
      mkdirat, mknodat, mkfifoat, faccessat, fchownat, linkat, readlinkat,
      symlinkat, unlinkat

    * Add constants AT_FDCWD, UTIME_NOW, UTIME_OMIT
2013-03-26 21:26:09 +01:00
Steffen Kieß 6ceccd8cd2 Set errno to 0 before calling readdir in Syscall.readdir().
This will allow the caller to distinguish between errors and end-of-directory.
2013-03-26 19:53:00 +01:00
Marek Habersack c802ea53a3 Added CreateNLSocket stub for non-linux platforms 2013-03-20 01:38:07 +01:00
Rodrigo Kumpera 32fbc3ab7e Fix the build. 2012-10-24 13:39:42 -04:00
Mirco Bauer 58f443c5d2 Disable -Werror=format-security on GCC as the input is already validated by the caller
Jonathan Pryor (jonpryor) commented on f49164b:

The message parameter is validated in managed code:
https://github.com/mono/mono/blob/master/mcs/class/Mono.Posix/Mono.Unix.Native/Syscall.cs#L3200
https://github.com/mono/mono/blob/master/mcs/class/Mono.Posix/Mono.Unix/UnixMarshal.cs#L366

This change means that '%m' isn't useful in format strings to Syscall.syslog(),
as it'll be escaped instead of "passed through" unchanged.
2012-10-24 16:28:09 +02:00
Zoltan Varga c1ed4a5570 Use AM_CPPFLAGS instead of INCLUDES in Makefile.am files, as the later is no longer supported, see http://lists.gnu.org/archive/html/automake/2012-08/msg00087.html. 2012-10-03 10:26:37 +02:00
Rob Wilkens 0fb2958a66 For Bug 2014: map FcntlCommand to local system command for fcntl_lock
In support/fcntl.c - every time fcntl() was called, it would first map the
cmd from mono's version of it to the system header file version of it.
The only time this wasn't happening was in Mono_Posix_Syscall_fcntl_lock()
and now it does it there too.  This seems to resolve Bug 2014 on both
64-bit linux and on Mac OS X (64-bit).
2012-06-25 20:17:24 -04:00
KISHIMOTO, Makoto 9e9e2c86c8 any BSD's sendfile has 6 arguments 2012-06-16 11:04:33 +09:00
KISHIMOTO, Makoto 7c38dc9817 mincore(2) isnot X/Ooen standard 2012-06-16 06:15:46 +09:00
Zoltan Varga 174de374ff Fix implicit function declarations on osx. 2012-06-01 13:42:04 +02:00
Miguel de Icaza 43fac74fa3 Silence compiler warnings for methods that are P/Invoked: provide prototypes 2012-03-19 15:35:35 -04:00
Miguel de Icaza 99209c62ee (write_serial): fix the variable holding the return value of write(2) which is a ssize_t, not a size_t. This fixed a problem where we would not exit the loop, as negative values would never be set, fix from GitHub.com's konrad-kruczynski 2012-03-19 11:31:55 -04:00
Miguel de Icaza 7b07672528 Revert the change to syslog message formatting, as JonP's code already does escaping in managed code, see: https://github.com/mono/mono/commit/f49164bf7658855390b2c19574b170f8728a99ff#commitcomment-1044747 2012-03-05 16:43:44 -05:00
Jonathan Pryor 163f9061e1 [MonoPosixHelper] Allow MmapFlags.MAP_ANON use on OS X.
Fixes: https://bugzilla.xamarin.com/show_bug.cgi?id=3419

The problem is that OS X defines MAP_ANON but not MAP_ANONYMOUS, AND
MAP_ANON and MAP_ANONYMOUS have the same value. Furthermore,
create-native-map doesn't have any special support for constants with
the same value, so it emits the validation independently.

The result is that the following fails on OS X:

	$ csharp -r:Mono.Posix.dll
	csharp> int r;
	csharp> using Mono.Unix.Native;
	csharp> NativeConvert.TryFromMmapFlags(MmapFlags.MAP_ANONYMOUS, out r);
	false
	csharp> r;

The (hackish) fix is to provide MAP_ANONYMOUS on OS X, thus allowing
the existing validation logic to work as expected.
2012-02-27 17:41:37 -05:00
Alan McGovern b5a0b8e0a8 [minizip] Ensure we don't ever accidentally change calling convention
Make sure we always #define ZCALLBACK to empty so we don't change
the calling convention on windows by including a header which defines
'CALLBACK'. This will keep things as cdecl as required by the c#
pinvokes.
2011-08-17 13:23:05 +01:00
Miguel de Icaza 16a40cb7b3 Fix invocation to syslog 2011-07-25 19:13:41 -04:00
Konrad M. Kruczynski 718b24e6ae Added exception in case of using nonstandard baud rate on POSIX boxes, which is not supported by termios. OutOfRange rather than NotSupported exception due to interface compatibility. 2011-05-01 14:20:54 +02:00
Jeffrey Stedfast 48ca47413f Don't forget to link with libiconv 2011-04-20 09:53:32 -04:00
Gonzalo Paniagua Javier eef46f9edf [nl] Move a bunch of #if's out of the way. 2011-03-29 14:24:23 -04:00
Gonzalo Paniagua Javier b3360089d5 (c) lines. 2011-03-28 18:14:47 -04:00
Gonzalo Paniagua Javier 75d42f19f9 [NetworkInformation] Support network IP/status events
Add support for the events in NetworkChanged (linux-only).
2011-03-27 18:50:35 -04:00