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

runtime: add runtime.fcntl link directives #4481

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

leongross
Copy link
Contributor

Building u-root commands with tinygo (see u-root/u-root#2979) returns linking errors for the system runtime function runtime.fcntl. This PR intends to fix this issue. Affected u-root cmdlets:

  • localboot
  • netbootxyz
  • newsshd
  • systemboot

Signed-off-by: leongross <leon.gross@9elements.com>
Signed-off-by: leongross <leon.gross@9elements.com>
//go:linkname syscall_fcntl runtime/runtime.fcntl
func syscall_fcntl(fd, cmd, arg int32) (ret int32, errno int32) {
// https://cs.opensource.google/go/go/+/master:src/runtime/os_linux.go;l=452?q=runtime.fcntl&ss=go%2Fgo
r, _, err := Syscall6(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg), 0, 0, 0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you trying to do a direct system call in syscall_libc.go? Syscall6 and the like are only supported on Windows and Linux, not on many other systems.

What about calling the libc function fcntl instead?

Comment on lines +145 to +147
func fcntl(fd, cmd, arg int32) (ret int32, errno int32){
return 0, 0
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bad idea. It should not just ignore the call and return without an error.
Is this intended to call syscall_fcntl perhaps?

And then, any reason not to call the libc function instead (like with syscall_Getpagesize for example).

@@ -212,6 +212,13 @@ func Truncate(path string, length int64) (err error) {
return
}

//go:linkname syscall_fcntl runtime/runtime.fcntl
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you meant runtime.fcntl?

Suggested change
//go:linkname syscall_fcntl runtime/runtime.fcntl
//go:linkname syscall_fcntl runtime.fcntl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants