[Mono-list] Mono.Posix

Jonathan Pryor jonpryor at vt.edu
Wed Feb 2 14:24:08 EST 2011


On Feb 2, 2011, at 5:54 AM, Steve Lessard wrote:
> ...
> This tool basically checks a file's permissions to see if the file is executable by any or all of user, group, other.
> Windows is supposed to have a Posix compliant layer. Does Mono.Posix assembly work on Windows's Posix layer? 

Mono.Posix.dll only partially works on Windows:

  - Mono.Unix.Convert works (requires INTL.DLL)
  - Mono.Unix.Native.Stdlib works (uses MSVCRT.DLL)
  - Mono.Unix.StdioFileStream works (uses Mono.Unix.Native.Stdlib)

Beyond that, forgetaboutit.  Everything else depends on calls into MonoPosixHelper.dll which aren't compiled on Windows (e.g. Syscall.setxattr), or are calls into libc directly (which is remapped to MSVCRT.DLL under Mono, but those functions won't exist).

For example, Syscall.access() P/Invokes "libc".  If you use Mono.Posix.dll under .NET, this will fail (no such library).  Under Mono, it should get remapped to MSVCRT.DLL, but MSVCRT.DLL doesn't have an "access" export (it instead has "_access"), so the attempt to find the method will fail.

Furthermore, using Syscall.access() to check the executable bit doesn't make lots of sense on Windows.  Even when it did have a POSIX layer, very little software actually used it, so the important bit is NTFS ACLs, which access() likely won't know about.

 - Jon



More information about the Mono-list mailing list