New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for solaris FEN #196
Conversation
This is a basic implementation of fsnotify for Solaris FEN. It at least passes all integration tests.
fen.go
Outdated
var finfo C.struct_file_info | ||
finfo.mode = C.uint(stat.Mode()) | ||
|
||
var mode C.int = C.FILE_MODIFIED | C.FILE_ATTRIB | C.FILE_NOFOLLOW |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should omit type C.int from declaration of var mode; it will be inferred from the right-hand side
fen.go
Outdated
} | ||
} | ||
|
||
func (w *Watcher) Remove(path string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported method Watcher.Remove should have comment or be unexported
fen.go
Outdated
// Add starts watching the named file or directory (non-recursively). | ||
func (w *Watcher) Add(name string) error { | ||
return nil | ||
func (w *Watcher) Add(path string) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
exported method Watcher.Add should have comment or be unexported
fen.go
Outdated
@@ -231,7 +231,7 @@ func (w *Watcher) associateFile(path string, stat os.FileInfo) error { | |||
var finfo C.struct_file_info | |||
finfo.mode = C.uint(stat.Mode()) | |||
|
|||
var mode C.int = C.FILE_MODIFIED | C.FILE_ATTRIB | C.FILE_NOFOLLOW | |||
mode := C.FILE_MODIFIED | C.FILE_ATTRIB | C.FILE_NOFOLLOW |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well type inference doesn't seem to work as houndci-bot expected. Now I need to cast the usage of mode. Not sure I like that better. Will have a closer look later.
While the `var mode C.int = ...` code isn't the nicest, at least it was working. Type inference alone didn't work. Hopefully houndci will accept this solution with the explicit cast.
@gfrey We don't currently have a good way to test Solaris, either with a CI service or locally from a different OS (I use Vagrant Gopher for Linux/BSD). Any suggestions? |
@nathany I used VirtualBox with an OpenIndiana hipster install. I'll try and add support for solaris to your Vagrant Gopher, just give me a few days. |
@gfrey Thanks both for this pull request and your work on Vagrant Gopher to test it.
(unfortunately no race detector on Solaris) I'm still hoping @4ad and/or @amitkris provide a review, but I will also take a closer look in the coming days. |
What can we do to get this PR accepted and merged into the master branch? This is blocking getting https://github.com/spf13/hugo and https://github.com/prometheus/alertmanager (via https://github.com/stuartnelson3/guac) running on Solaris. I confirmed that this branch merged into master works on SmartOS inside Hugo (running |
@4ad @amitkris @nathany This would be really good for Hugo to get in. @fazalmajid has a valid point about the this cannot break it worse than it already is and the breakage is limited to Solaris. I have quickly browsed through the code and cannot find any obvious mistakes. |
We in DTC golang meetup reviewed the code, not all it. But we have few questions |
I'm not the author, but Solaris requires use of cgo, in general, since libc is the provider of system interfaces. The only other comment I would add is that this should be using golang.org/x/sys/unix instead of syscall. Per the official Go documentation, use of syscall outside of the Go standard runtime has been deprecated since 1.4:
As far as I can tell, this should work on commercial releases of Solaris, although I haven't tried it myself. It appears to be using functionality shared between Solaris and OpenSolaris-based derivatives such as Illumos/SmartOS. |
I don't care about fsnotify, so you'll have to find someone else to review this, but I will point out that using cgo here is an unnecessary mistake. This should all be done using golang.org/x/sys/unix (probably after you update it). |
Forgive any mistakes here, I'm very new to Go. For this kind of code there seems to be a good justification for using the C pass through interfaces. Probably lots of things don't have native Go interfaces yet. Using "syscall" is another matter. It's explicitly deprecated. I see two places where syscall is used explicitly in the code. 1) It's used to access the enumeration of errno values. When I visit x/sys/unix, it says that the official place to get errno values from is syscall.Errno. (Check the top of https://godoc.org/golang.org/x/sys/unix) So that seems legitimate. 2) The other place it's used is to access the C structure for stat_t. The code starts by using os.FileInfo, then goes through Sys() to get the stat_t. It does this because the FileInfo doesn't include atime or ctime members. (access time / create time). Only mtime (modification time) is available through FileInfo according to the docs. So I don't see any way the code could be changed to avoid the existing uses of syscall. In theory you could argue that atime and ctime should be added FileInfo, but that seems like a change that should take into account the availability of those interfaces on other platforms. I'm not sure how widely they're supported on all the Go platforms. It doesn't seem appropriate to ask the submitter to take that on at this point. So with that in mind, I don't see any issues with the use of cgo or syscall. I also ran the fsnotify package test on x86 Oracle Solaris (latest internal build) with the bundled Go 1.5, and it passed. I also ran it on the same Solaris build on SPARC with the latest sparc compiler from https://github.com/4ad/go/tree/sparc64.go1.8 and it passed. I'm not that familiar with file events in Solaris, but if additional code review is what's holding this up, I can find an Oracle Solaris engineer who is familiar with file events to check over the logic. They won't be familiar with Go, but they could vouch for the usage of Solaris interfaces. |
@dago Are you still into OpenCSW? Can their build farm help to solve the CI "problem" in this issue? |
Hi @gfrey! I work at Joyent. We maintain SmartOS, and we need fsnotify support. Thank you for doing this work! I took a look at your pull request and made some changes. I added more robust support for cancellation to fix a race condition exhibited by the TestWatcherClose test, and I altered the interpretation of FEN events to more accurately implement fsnotify's expected behavior, as well as other small improvements. I intend to submit a new pull request for this work. Given that my request would still substantially contain your code, how would you like to be credited? I could add you to the To everyone else on this thread - I would be happy to provide additional resources for testing fsnotify on SmartOS. Please let me know! |
@isaacdavis I'm fine with being mentioned in the AUTHORS file. Nice seeing this getting some traction again! |
@maxmeyer Sure. I have briefly reviewed the comments in this PR, is there something specific I should test? |
@dago What about setting about an automatic build on the opencsw build farm for this project? |
@maxmeyer That would be doable, we already have a number of projects in a buildbot setup which is triggered by hooks, most notable curl which has full CI integration in GitHub with different builders (click on the green checkmarks for CI build details). However, I need to update some stuff to recent Go compilers and make it compile manually first. Please PM me for details. |
@isaacdavis can you help @dago with details to make it build automatically for csw? |
@maxmeyer - Unfortunately, I'm unfamiliar with csw, and my scope of knowledge is centered on illumos/SmartOS rather than Oracle Solaris. With that said, I had no issues building fsnotify on SmartOS, so hopefully the csw build should be equally straightforward. @dago - if you run into any issues please let me know and I will try to help. Note that I now have a new pull request open (#263) with an updated version of this code that fixes some issues. You may want to have a look! |
Closed in favour of #263. |
See #371 |
Fixes #12
I've signed the CLA.
What does this pull request do?
This is a basic implementation of fsnotify for Solaris FEN. It at least passes all integration tests.
Where should the reviewer start?
I used the following two resource to get a basic understanding how this should work:
How should this be manually tested?
The available integration tests are enabled for solaris now and succeed.