[Mono-dev] Unix.Native

Greg Young gregoryyoung1 at gmail.com
Tue Jan 13 02:16:23 UTC 2015


btw if anyone runs into this (should be a top google result) and the
constants are not in commands here is how to do it:

Not the prettiest but it should work

#if __MonoCS__ || USE_UNIX_IO
[DllImport("libc")]
static extern int fcntl(int fd, uint command, int arg);
#endif

if (OS.OsFlavor != OsFlavor.MacOS) return;
#if __MonoCS__ || USE_UNIX_IO
long r = 0;
do {
r = fcntl (handle.DangerousGetHandle().ToInt32(), MAC_F_NOCACHE, 1);
} while (UnixMarshal.ShouldRetrySyscall ((int) r));
if (r == -1)
UnixMarshal.ThrowExceptionForLastError ();
#endif

On Tue, Jan 13, 2015 at 3:49 AM, Greg Young <gregoryyoung1 at gmail.com> wrote:
> If we can get a list of all the params that need to be supported and
> the varying mappings I have no problem working on it.
>
> I will look into its build etc as I have never dealt with it internally.
>
> Greg
>
> On Tue, Jan 13, 2015 at 3:48 AM, Rodrigo Kumpera <kumpera at gmail.com> wrote:
>> I agree we would be better with a better error message.
>>
>> Said that, right now Mono.Posix lacks a more dedicated maintainer and it
>> would be lovely if you
>> could bring some love to it. :)
>>
>> On Mon, Jan 12, 2015 at 8:39 PM, Greg Young <gregoryyoung1 at gmail.com> wrote:
>>>
>>> There are a ton to surface ... I just ran into this one :)
>>>
>>> In general I agree with you surfacing is better I was thinking just
>>> letting me call it if it doesn't understand it (or having a better
>>> message) would be useful. I spun for hours thinking what was wrong
>>> with my parameters to the call thinking it for some undocumented
>>> reason was returning EINVAL :)
>>>
>>> On Tue, Jan 13, 2015 at 3:30 AM, Rodrigo Kumpera <kumpera at gmail.com>
>>> wrote:
>>> > That would change the behavior of the function and translate into a more
>>> > fragile API.
>>> >
>>> > The way to go is to surface this option.
>>> >
>>> > On Mon, Jan 12, 2015 at 8:23 PM, Greg Young <gregoryyoung1 at gmail.com>
>>> > wrote:
>>> >>
>>> >> I figured out why after a while of looking. The C code translates the
>>> >> argument
>>> >>
>>> >> int Mono_Posix_FromFcntlCommand (int x, int *r)
>>> >>
>>> >> When its something that is not a known command it returns EINVAL.
>>> >> Might a better option be to try to let it pass through otherwise how
>>> >> could I call for instance a value on a ac?
>>> >>
>>> >> Cheers,
>>> >>
>>> >> Greg
>>> >>
>>> >> On Tue, Jan 13, 2015 at 2:28 AM, Greg Young <gregoryyoung1 at gmail.com>
>>> >> wrote:
>>> >> > I have been trying to set F_NOCACHE via fcntl on a mac to no avail.
>>> >> >
>>> >> >                  r = Syscall.fcntl
>>> >> > (handle.DangerousGetHandle().ToInt32(), (FcntlCommand) MAC_F_NOCACHE,
>>> >> > 1);
>>> >> >                  } while (UnixMarshal.ShouldRetrySyscall ((int) r));
>>> >> >                  if (r == -1)
>>> >> >                      UnixMarshal.ThrowExceptionForLastError ();
>>> >> >
>>> >> > (EINVAL)
>>> >> >
>>> >> > I have tried
>>> >> > 48
>>> >> > 0x400
>>> >> > and 0x40000
>>> >> > for F_NOCACHE though from
>>> >> >
>>> >> >
>>> >> > https://github.com/realthunder/mac-headers/blob/master/usr/include/sys/fcntl.h#L256
>>> >> >
>>> >> > Given FcntlCommandFlags does not expose F_NOCACHE but it still should
>>> >> > be fine to jam the value into the enum
>>> >> >
>>> >> > Has anyone set this before? Chances of finding this on google are
>>> >> > slightly better than 0 :)
>>> >> >
>>> >> > Cheers,
>>> >> >
>>> >> > Greg
>>> >> > --
>>> >> > Studying for the Turing test
>>> >>
>>> >>
>>> >>
>>> >> --
>>> >> Studying for the Turing test
>>> >> _______________________________________________
>>> >> Mono-devel-list mailing list
>>> >> Mono-devel-list at lists.ximian.com
>>> >> http://lists.ximian.com/mailman/listinfo/mono-devel-list
>>> >
>>> >
>>>
>>>
>>>
>>> --
>>> Studying for the Turing test
>>
>>
>
>
>
> --
> Studying for the Turing test



-- 
Studying for the Turing test


More information about the Mono-devel-list mailing list