You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to implement System.IO.FileSystem.Watcher on FreeBSD #14716
I need to look again, but I believe the kqueue system works very similarly to the inotify system; if this is the case, we could potentially re-use the Linux implementation for FreeBSD. I'll dig in and find out more
It looks like the kqueue system requires opening a handle per file whereas Linux requires per directory. The Linux implementation won't work here so there are a couple options:
Make a FreeBSD implementation using kqueues and error out if (read as when) the process hits the maximum handle limit
Have the FreeBSD implementation have an external dependency on other software (an inotify port, other 3rd party FSW implementations, etc)
Throw PlatformNotSupported for the FSW and kick the can down the road a bit
If we want a robust implementation, I'd vote for looking into option 2 since my initial investigation showed that there are a few third-party libraries (runtime and compile time) that help with this problem...it would require customers install packages to use the FSW, however, but we already have precedence for that (OpenSSL for example).
@janhenke I think the kqueue implementation would be the best bet; it would be functionally similar to the FileSystemWatcher.Linux implementation but with FreeBSD nuances; it feels like the best option here unless FreeBSD has some special APIs (like OSX), but I don't know enough about FreeBSD to know that :)
--- a/.cirrus.yml+++ b/.cirrus.yml@@ -1,5 +1,5 @@
freebsd_instance:
- image: freebsd-11-2-release-amd64+ image: freebsd-12-0-release-amd64
freebsd_build_task:
@@ -10,4 +10,4 @@ freebsd_build_task:
build_script:
- ./src/Native/build-native.sh # this is redundant; just for testing native assets build beforehand
- - ./build.sh+ - LD_PRELOAD=/usr/lib/libpthread.so ./build.sh
and it gives a different error about missing openssl (although there is no change in the package install step in .cirrus.yml):
expand..
Welcome to .NET Core!
---------------------
GitHub: https://github.com/dotnet/core
Docs: https://aka.ms/dotnet-docs
HTTPS: https://aka.ms/aspnet-core-https
Telemetry statement: https://aka.ms/dotnet-cli-telemetry
System.TypeInitializationException: The type initializer for'Crypto' threw an exception. ---> System.DllNotFoundException: Unable to load shared library 'System.Security.Cryptography.Native.OpenSsl' or one of its dependencies. In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: Shared object "libSystem.Security.Cryptography.Native.OpenSsl" not found, required by "dotnet"
at Interop.Crypto.GetMaxMdSize()
at Interop.Crypto..cctor()
--- End of inner exception stack trace ---
at Interop.Crypto.EvpSha256()
at Internal.Cryptography.HashProviderDispenser.CreateHashProvider(String hashAlgorithmId)
at System.Security.Cryptography.SHA256.Implementation..ctor()
at System.Security.Cryptography.SHA256.Create()
at Microsoft.DotNet.Cli.Telemetry.Sha256Hasher.Hash(String text)
at Microsoft.DotNet.Cli.Telemetry.Sha256Hasher.HashWithNormalizedCasing(String text)
at Microsoft.DotNet.Cli.Utils.ApplicationInsightsEntryFormat.<>c__DisplayClass10_0.<WithAppliedToPropertiesValue>b__1(KeyValuePair`2 p)at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
I think minimal implementation would be good. Having same behavior as Mono is also good as we are heading to convergence in general between corefx and Mono.
As far as the build: I need to update build instructions.
While back when I tested it, I could not build corefx with 3.0 even of supported platforms. That may have changed. As 3.0 looms closer I was unable to find enough time to keep everything up to date.
Has there been no new “official” SDK build since then
Seems like this is the case; FreeBSD was disabled in official SDK build matrix on January 8 due to some problems: dotnet/installer#248.
I made a slight progress by applying dotnet/corefx#36766. The next errors are related to missing (preview5) runtime packages, ILAsm, CoreCLR and friends:
error NU1102: Unable to find package runtime.freebsd-x64.Microsoft.NETCore.ILAsm with version (>= 3.0.0-preview5-27608-73)
..
error NU1102: Unable to find package runtime.freebsd-x64.Microsoft.NETCore.Runtime.CoreCLR with version (>= 3.0.0-preview5-27608-73)
To get unblocked, I think there are at least two possibilities:
This is mostly because @rootwyrm made me realized how easy it is. So we get some functionality now and we can improve if somebody bumps to issues.
There is now wave of new effort to stabilize around 3.x and get source-build working for freebsd. I'll probably post update on main freebsd issue as it would be great to get help from anybody who has any time left. Even if that is to follow steps and provide feedback.
Ha, I will gladly take the blame here, and also deliver the very important caveats.
The reason kqueue should remain preferred as a long term goal is that it's several orders of magnitude faster. libinotify is just a shim and may not be maintained. There's also the caveat of still missing O_SYMLINK. So IN_ATTRIB, IN_MODIFY, IN_MOVE_SELF, and IN_DELETE_SELF don't work. If you all would consider these important, I can see about making noises about finally accepting the kernel patches that fix this.
Activity
stephentoub commentedon Jun 15, 2015
Hopefully some OS-provided solution will work well, but worst case you could also consider a polling-based solution, e.g. https://github.com/dotnet/corefxlab/tree/master/src/System.IO.FileSystem.Watcher.Polling
cc: @KrzysztofCwalina
jonmill commentedon Oct 6, 2015
I need to look again, but I believe the kqueue system works very similarly to the inotify system; if this is the case, we could potentially re-use the Linux implementation for FreeBSD. I'll dig in and find out more
jonmill commentedon Oct 7, 2015
It looks like the kqueue system requires opening a handle per file whereas Linux requires per directory. The Linux implementation won't work here so there are a couple options:
If we want a robust implementation, I'd vote for looking into option 2 since my initial investigation showed that there are a few third-party libraries (runtime and compile time) that help with this problem...it would require customers install packages to use the FSW, however, but we already have precedence for that (OpenSSL for example).
Thoughts?
saper commentedon Oct 8, 2015
kevent/kqueueis the best way and it's pretty easy in my opinion. So I'd go for option dotnet/corefx#1.jonmill commentedon Feb 10, 2016
We have this throwing PlatformNotSupported right now but since FreeBSD work is mainly being done by the community, adding the Up-For-Grabs label
janhenke commentedon Feb 10, 2016
Fair enough. I would still like to see the FreeBSD port completed. Is there any strong opnion about the three possibilities you mentioned above?
jonmill commentedon Feb 10, 2016
@janhenke I think the kqueue implementation would be the best bet; it would be functionally similar to the FileSystemWatcher.Linux implementation but with FreeBSD nuances; it feels like the best option here unless FreeBSD has some special APIs (like OSX), but I don't know enough about FreeBSD to know that :)
janhenke commentedon Feb 11, 2016
I would then grab this one and try to come up with a kqueue based implementation.
krytarowski commentedon Feb 14, 2016
http://dmitrymatveev.co.uk/gsoc11 inotify emulation for BSD
krytarowski commentedon Feb 15, 2016
@janhenke can you please try to reuse
libinotifywith CoreFX on FreeBSD? It'skevent(2)/kqueue(2) based and MIT licensed.janhenke commentedon Feb 15, 2016
@krytarowski I'll look at it.
janhenke commentedon Apr 19, 2016
Sorry, I have to give this one back. My private life does not leave enough time for seriously getting into this.
krytarowski commentedon Apr 19, 2016
I should be there soon with NetBSD
29 remaining items
am11 commentedon Apr 8, 2019
Would it make sense to tackle this old issue pragmatically for now? For example, port of
KeventWatcherimplementation from mono over to CoreFX, where the following options are available at https://github.com/mono/mono/blob/master/mcs/class/System/System.IO/, followed by CoreFX style adaptations.To be able to build CoreFX recent master on FreeBSD, I tweaked some scripts and versions in CoreFX to ultimately use FreeBSD v3.x preview listed at https://github.com/dotnet/core-sdk/blob/master/README.md. However, CoreFX is currently using v2.2 of the SDK, and due to some API differences, I could not make much progress. Is there a patch available that we can apply on top of CoreFX master to build with SDK v3.x (any OS)?
wolfspider commentedon Apr 8, 2019
@am11 If you move the 2.2 SDK folder into v3 does it not find it or is it not building? What happens when you try to build it?
am11 commentedon Apr 9, 2019
@wolfspider, with minimal patch: dotnet/corefx@master...am11:freebsd-ci, it downloads the SDK for FreeBSD, but subsequently fails while executing
FindBestConfigurationsMSBuild task:excerpt from: https://cirrus-ci.com/task/5635235873030144
expand..
This was tested on FreeBSD 11.2. If we switch to FreeBSD 12.0 in CirrusCI YAML, we need to apply @wfurt's
LD_PRELOADworkaround from https://github.com/dotnet/corefx/issues/1626#issuecomment-459842620. The reason why we still need to apply this workaround is because3.0.100-preview-009812is the last release for FreeBSD (from Jan).expand..
and it gives a different error about missing openssl (although there is no change in the package install step in
.cirrus.yml):expand..
wfurt commentedon Apr 9, 2019
I think minimal implementation would be good. Having same behavior as Mono is also good as we are heading to convergence in general between corefx and Mono.
As far as the build: I need to update build instructions.
While back when I tested it, I could not build corefx with 3.0 even of supported platforms. That may have changed. As 3.0 looms closer I was unable to find enough time to keep everything up to date.
josteink commentedon Apr 10, 2019
I did submit a fix for this. Has there been no new “official” SDK build since then, or was the fix insufficient?
am11 commentedon Apr 10, 2019
Seems like this is the case; FreeBSD was disabled in official SDK build matrix on January 8 due to some problems: dotnet/installer#248.
I made a slight progress by applying dotnet/corefx#36766. The next errors are related to missing (preview5) runtime packages, ILAsm, CoreCLR and friends:
To get unblocked, I think there are at least two possibilities:
wfurt commentedon Apr 10, 2019
This goes all the way to microsoft/azure-pipelines-agent#1906
We need the agent to run the builds and without it it hard to push on infrastructure.
danmoseley commentedon Apr 30, 2019
We can keep tracking this but it's not aligned to work on the 3.0 schedule
josteink commentedon Nov 9, 2019
So we finally went with inotify instead of kqueue, just 4-5 years after I suggested so, because nobody wanted to implement the kqueue-version.
Oh well. Better late than never. 😄
Thanks @wfurt ! Good job!
wfurt commentedon Nov 9, 2019
This is mostly because @rootwyrm made me realized how easy it is. So we get some functionality now and we can improve if somebody bumps to issues.
There is now wave of new effort to stabilize around 3.x and get source-build working for freebsd. I'll probably post update on main freebsd issue as it would be great to get help from anybody who has any time left. Even if that is to follow steps and provide feedback.
rootwyrm commentedon Nov 10, 2019
Ha, I will gladly take the blame here, and also deliver the very important caveats.
The reason
kqueueshould remain preferred as a long term goal is that it's several orders of magnitude faster.libinotifyis just a shim and may not be maintained. There's also the caveat of still missing O_SYMLINK. SoIN_ATTRIB, IN_MODIFY, IN_MOVE_SELF,andIN_DELETE_SELFdon't work. If you all would consider these important, I can see about making noises about finally accepting the kernel patches that fix this.