Skip to content
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

x/sys/unix: add Solaris Fcntl? #24649

Closed
ppbrown opened this issue Apr 2, 2018 · 4 comments
Closed

x/sys/unix: add Solaris Fcntl? #24649

ppbrown opened this issue Apr 2, 2018 · 4 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. OS-Solaris
Milestone

Comments

@ppbrown
Copy link

ppbrown commented Apr 2, 2018

(I'm trying to follow the contributor guidelines: this is my first submission. I have 20 years of coding experience, and my own github repositories at https://github.com/bolthole )

My relevant environment:
go version go1.10.1 solaris/amd64

Background: 3rd party code I want to use, calls
unix.Syscall(unix.SYS_FCNTL, ...)

Problem is, my platform of Solaris, while being a supported platform.. does not have an implementation of Syscall(). Nor can it have one, because the OS does not have that API.

Seeing as how fcntl() is in the actual POSIX standard, seems like it would be a good idea for Go to actually have an official function call for it. Particularly since practically all the platforms suported in the "unix" collection, actually have OS suport for a native fcntl() call.

I have working code, that I'd like to submit to the repo, for Solaris.
I could potentially submit an attempt at other platforms, as well, but I do not have a testbed for them.

Proof my code works:

$ cat test.go
package main

import (
"golang.org/x/sys/unix"
"fmt"
)

func main() {
var retval int

    fmt.Println("Hi there")
    retval, _ = unix.Fcntl(1,unix.F_SETFD, unix.FD_CLOEXEC)
    fmt.Println("status of fcntl: ", retval)

}

$ go build test.go
$ truss ./test
/1: write(1, " H i t h e r e\n", 9) = 9
/1: fcntl(1, F_SETFD, 0x00000001) = 0
status of fcntl: 0
/1: write(1, " s t a t u s o f f c".., 20) = 20
/1: _exit(0)

@ppbrown
Copy link
Author

ppbrown commented Apr 2, 2018

I guess I should explictly mention that my code change is extremely small; i could easly cutnpaste it here :) but for brevity at the moment, I will say that it only touches two files currently:

unix/asm_solaris_amd64.s
unix/syscall_solaris.go

I could probably trivially add in a true Fnctl() call for the other unixen platforms, by modifying just a single file,

unix/flock.go

which currently only has FcntlFlock()

@bradfitz bradfitz changed the title Proposal for code submit for x/sys/unix/Fcntl x/sys/unix: add Solaris Fcntl? Apr 2, 2018
@gopherbot gopherbot added this to the Unreleased milestone Apr 2, 2018
@bradfitz
Copy link
Contributor

bradfitz commented Apr 2, 2018

If you already have the code, send the code GitHub PR or Gerrit (https://golang.org/doc/contribute.html) and @tklauser, @ianlancetaylor, and I can take a look.

@gopherbot
Copy link

Change https://golang.org/cl/104255 mentions this issue: unix: Add Fcntl()

@tklauser tklauser added OS-Solaris NeedsFix The path to resolution is known, but the work has not been done. labels Apr 3, 2018
@gopherbot
Copy link

Change https://golang.org/cl/104736 mentions this issue: x/sys/unix: add FcntlInt

@golang golang locked and limited conversation to collaborators Apr 4, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. OS-Solaris
Projects
None yet
Development

No branches or pull requests

4 participants