Re: [Mono-dev] Unix.Native
Are there any instructions on building/testing the area (linux)? I don't mind jumping in it a bit On Tue, Jan 13, 2015 at 6:28 AM, Miguel de Icaza wrote: > Hey, > > Good observation, so passing a -1 is enough. > > That said, perhaps we do need to expose a number of overloads with various > possible data types of other sizes. > > On Mon, Jan 12, 2015 at 11:23 PM, Greg Young > wrote: >> >> I would guess it to be the same for others like F_RDAHEAD >> >> I don't think the long is too horrible as its only defined as 0/non-zero >> >> On Tue, Jan 13, 2015 at 6:15 AM, Miguel de Icaza >> wrote: >> > I added support for this on master. >> > >> > That said, there is an issue that I think will bite us. >> > >> > Currently the fcntl P/Invoke declaration uses a "long" as a general >> > purpose >> > way of passing flags to fcntl, and I suspect the parameter to F_NOCACHE >> > should be an int. >> > >> > Thoughts? >> > >> > Miguel >> > >> > On Mon, Jan 12, 2015 at 7:28 PM, Greg Young >> > 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 0x4 >> >> 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 >> >> ___ >> >> Mono-devel-list mailing list >> >> Mono-devel-list@lists.ximian.com >> >> http://lists.ximian.com/mailman/listinfo/mono-devel-list >> > >> > >> >> >> >> -- >> Studying for the Turing test > > -- Studying for the Turing test ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
[Mono-dev] Managed/Unmanaged code debugging
Hi, Can anyone suggest me how i can debug unmanned/managed code together using mono develop ? I have used mono-soft-debugger & successfully debug managed code locally & remotely. *Techi* ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Unix.Native
Hey, Good observation, so passing a -1 is enough. That said, perhaps we do need to expose a number of overloads with various possible data types of other sizes. On Mon, Jan 12, 2015 at 11:23 PM, Greg Young wrote: > I would guess it to be the same for others like F_RDAHEAD > > I don't think the long is too horrible as its only defined as 0/non-zero > > On Tue, Jan 13, 2015 at 6:15 AM, Miguel de Icaza > wrote: > > I added support for this on master. > > > > That said, there is an issue that I think will bite us. > > > > Currently the fcntl P/Invoke declaration uses a "long" as a general > purpose > > way of passing flags to fcntl, and I suspect the parameter to F_NOCACHE > > should be an int. > > > > Thoughts? > > > > Miguel > > > > On Mon, Jan 12, 2015 at 7:28 PM, Greg Young > 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 0x4 > >> 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 > >> ___ > >> Mono-devel-list mailing list > >> Mono-devel-list@lists.ximian.com > >> http://lists.ximian.com/mailman/listinfo/mono-devel-list > > > > > > > > -- > Studying for the Turing test > ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Unix.Native
I would guess it to be the same for others like F_RDAHEAD I don't think the long is too horrible as its only defined as 0/non-zero On Tue, Jan 13, 2015 at 6:15 AM, Miguel de Icaza wrote: > I added support for this on master. > > That said, there is an issue that I think will bite us. > > Currently the fcntl P/Invoke declaration uses a "long" as a general purpose > way of passing flags to fcntl, and I suspect the parameter to F_NOCACHE > should be an int. > > Thoughts? > > Miguel > > On Mon, Jan 12, 2015 at 7:28 PM, Greg Young 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 0x4 >> 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 >> ___ >> Mono-devel-list mailing list >> Mono-devel-list@lists.ximian.com >> http://lists.ximian.com/mailman/listinfo/mono-devel-list > > -- Studying for the Turing test ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Unix.Native
I added support for this on master. That said, there is an issue that I think will bite us. Currently the fcntl P/Invoke declaration uses a "long" as a general purpose way of passing flags to fcntl, and I suspect the parameter to F_NOCACHE should be an int. Thoughts? Miguel On Mon, Jan 12, 2015 at 7:28 PM, Greg Young 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 0x4 > 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 > ___ > Mono-devel-list mailing list > Mono-devel-list@lists.ximian.com > http://lists.ximian.com/mailman/listinfo/mono-devel-list > ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Unix.Native
Rodrigo, What do you think as a pattern (there are quite a few places like this) if it were to do something like: [Conditional("DEBUG")] private void VerifyCommandEnum(T enum) { if(!Enum.IsDefined(typeof(T), command)) throw new Exception(string.Format("The value passed '{0}' for {1} is not a defined value and will fail at runtime.", enum, typeof(T).ToString()); } This will be slower but will give a reasonably sane error in debug at least. I can send over a PR with a few of them covered but wanted to run it by here before I spent the time on it. Greg On Tue, Jan 13, 2015 at 4:16 AM, Greg Young wrote: > 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 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 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 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 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 > 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 >> 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 0x4 >> > 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@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 -- Studying for the Turing test ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Unix.Native
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 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 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 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 >>> 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 >>> > 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 >>> >> 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 0x4 >>> >> > 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@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 ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Unix.Native
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 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 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 >> 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 >> > 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 >> >> 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 0x4 >> >> > 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@lists.ximian.com >> >> http://lists.ximian.com/mailman/listinfo/mono-devel-list >> > >> > >> >> >> >> -- >> Studying for the Turing test > > -- Studying for the Turing test ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Unix.Native
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 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 > 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 > 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 > >> 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 0x4 > >> > 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@lists.ximian.com > >> http://lists.ximian.com/mailman/listinfo/mono-devel-list > > > > > > > > -- > Studying for the Turing test > ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Unix.Native
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 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 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 >> 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 0x4 >> > 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@lists.ximian.com >> http://lists.ximian.com/mailman/listinfo/mono-devel-list > > -- Studying for the Turing test ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Unix.Native
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 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 > 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 0x4 > > 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@lists.ximian.com > http://lists.ximian.com/mailman/listinfo/mono-devel-list > ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] Unix.Native
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 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 0x4 > 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@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
[Mono-dev] Unix.Native
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 0x4 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 ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] SafeFileHandle
Here is the code as well in case you see something obvious. I could probably make it smaller but this is pretty simple. The message happens asynchronously well after the code is run (as you can see from the outputs). Causing a gc seems to make it happen sooner which made me think finalizer [Test] public void shitbird_test() { var filename = GetFilePathFor(Guid.NewGuid().ToString()); using(var stream = new shitstream(filename)) { Console.WriteLine(stream.Position); } Console.WriteLine("done"); } public class shitstream : Stream { private SafeFileHandle _handle; public shitstream(string filename) { var han = Syscall.open(filename, OpenFlags.O_CREAT | OpenFlags.O_RDONLY, FilePermissions.S_IRWXU); var _handle = new SafeFileHandle((IntPtr) han, true); if(_handle.IsInvalid) throw new Exception("Invalid handle"); } public override void Flush() {} public override long Seek(long offset, SeekOrigin origin){return 0;} public override void SetLength(long value){} public override int Read(byte[] buffer, int offset, int count) {return 0;} public override void Write(byte[] buffer, int offset, int count) {} public override bool CanRead { get { return true; } } public override bool CanSeek { get { return true;} } public override bool CanWrite { get { return true; } } public override long Length { get { return 0;} } public override long Position { get { return 0;} set {} } protected override void Dispose(bool disposing) { if(_handle == null) return; _handle.Close(); _handle = null; GC.SuppressFinalize (this); } } On Tue, Jan 13, 2015 at 12:46 AM, Zoltan Varga wrote: > Hi, > > Yes, please file a report. > > Zoltan > > On Mon, Jan 12, 2015 at 5:42 PM, Greg Young wrote: >> >> I have one I can file. I figured it was something on my side though. >> >> Could it be the FileHandle closing itself later for a second time? Are >> there other scenarios aside from close this can happen on? >> >> In general SafeFileHandle is pretty painful to use since none of the >> definitions support it. >> >> Want me to create an issue? >> >> Greg >> >> On Tue, Jan 13, 2015 at 12:32 AM, Zoltan Varga wrote: >> > Hi, >> > >> > This is a bug, it shouldn't happen. If you have some kind of >> > reproducible >> > test case, please file a bug report with it. >> > >> > Zoltan >> > >> > On Mon, Jan 12, 2015 at 5:28 PM, Greg Young >> > wrote: >> >> >> >> _wapi_handle_unref_full: Attempting to unref unused handle 0x8a >> >> >> >> I seem to be getting this message from the runtime not sure what could >> >> be causing it. From some googling this appears to happen when you >> >> close a file handle multiple times. >> >> >> >> The only place close is called is : >> >> >> >> protected override void Dispose(bool disposing) >> >> { >> >> if(_handle == null) return; >> >> Flush(); >> >> _handle.Close(); >> >> _handle = null; >> >> >> >> >> >> Not sure how it could be called multiple times. I don't get any issues >> >> on the CLR. >> >> >> >> Any ideas? >> >> >> >> Greg >> >> >> >> -- >> >> Studying for the Turing test >> >> ___ >> >> Mono-devel-list mailing list >> >> Mono-devel-list@lists.ximian.com >> >> http://lists.ximian.com/mailman/listinfo/mono-devel-list >> > >> > >> >> >> >> -- >> Studying for the Turing test > > -- Studying for the Turing test ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] SafeFileHandle
Hi, Yes, please file a report. Zoltan On Mon, Jan 12, 2015 at 5:42 PM, Greg Young wrote: > I have one I can file. I figured it was something on my side though. > > Could it be the FileHandle closing itself later for a second time? Are > there other scenarios aside from close this can happen on? > > In general SafeFileHandle is pretty painful to use since none of the > definitions support it. > > Want me to create an issue? > > Greg > > On Tue, Jan 13, 2015 at 12:32 AM, Zoltan Varga wrote: > > Hi, > > > > This is a bug, it shouldn't happen. If you have some kind of > reproducible > > test case, please file a bug report with it. > > > > Zoltan > > > > On Mon, Jan 12, 2015 at 5:28 PM, Greg Young > wrote: > >> > >> _wapi_handle_unref_full: Attempting to unref unused handle 0x8a > >> > >> I seem to be getting this message from the runtime not sure what could > >> be causing it. From some googling this appears to happen when you > >> close a file handle multiple times. > >> > >> The only place close is called is : > >> > >> protected override void Dispose(bool disposing) > >> { > >> if(_handle == null) return; > >> Flush(); > >> _handle.Close(); > >> _handle = null; > >> > >> > >> Not sure how it could be called multiple times. I don't get any issues > >> on the CLR. > >> > >> Any ideas? > >> > >> Greg > >> > >> -- > >> Studying for the Turing test > >> ___ > >> Mono-devel-list mailing list > >> Mono-devel-list@lists.ximian.com > >> http://lists.ximian.com/mailman/listinfo/mono-devel-list > > > > > > > > -- > Studying for the Turing test > ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] SafeFileHandle
I have one I can file. I figured it was something on my side though. Could it be the FileHandle closing itself later for a second time? Are there other scenarios aside from close this can happen on? In general SafeFileHandle is pretty painful to use since none of the definitions support it. Want me to create an issue? Greg On Tue, Jan 13, 2015 at 12:32 AM, Zoltan Varga wrote: > Hi, > > This is a bug, it shouldn't happen. If you have some kind of reproducible > test case, please file a bug report with it. > > Zoltan > > On Mon, Jan 12, 2015 at 5:28 PM, Greg Young wrote: >> >> _wapi_handle_unref_full: Attempting to unref unused handle 0x8a >> >> I seem to be getting this message from the runtime not sure what could >> be causing it. From some googling this appears to happen when you >> close a file handle multiple times. >> >> The only place close is called is : >> >> protected override void Dispose(bool disposing) >> { >> if(_handle == null) return; >> Flush(); >> _handle.Close(); >> _handle = null; >> >> >> Not sure how it could be called multiple times. I don't get any issues >> on the CLR. >> >> Any ideas? >> >> Greg >> >> -- >> Studying for the Turing test >> ___ >> Mono-devel-list mailing list >> Mono-devel-list@lists.ximian.com >> http://lists.ximian.com/mailman/listinfo/mono-devel-list > > -- Studying for the Turing test ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
Re: [Mono-dev] SafeFileHandle
Hi, This is a bug, it shouldn't happen. If you have some kind of reproducible test case, please file a bug report with it. Zoltan On Mon, Jan 12, 2015 at 5:28 PM, Greg Young wrote: > _wapi_handle_unref_full: Attempting to unref unused handle 0x8a > > I seem to be getting this message from the runtime not sure what could > be causing it. From some googling this appears to happen when you > close a file handle multiple times. > > The only place close is called is : > > protected override void Dispose(bool disposing) > { > if(_handle == null) return; > Flush(); > _handle.Close(); > _handle = null; > > > Not sure how it could be called multiple times. I don't get any issues > on the CLR. > > Any ideas? > > Greg > > -- > Studying for the Turing test > ___ > Mono-devel-list mailing list > Mono-devel-list@lists.ximian.com > http://lists.ximian.com/mailman/listinfo/mono-devel-list > ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list
[Mono-dev] SafeFileHandle
_wapi_handle_unref_full: Attempting to unref unused handle 0x8a I seem to be getting this message from the runtime not sure what could be causing it. From some googling this appears to happen when you close a file handle multiple times. The only place close is called is : protected override void Dispose(bool disposing) { if(_handle == null) return; Flush(); _handle.Close(); _handle = null; Not sure how it could be called multiple times. I don't get any issues on the CLR. Any ideas? Greg -- Studying for the Turing test ___ Mono-devel-list mailing list Mono-devel-list@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-devel-list