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 Fstatat on Linux on more than just GOARCH=arm64 #14216

Closed
dturner-tw opened this issue Feb 3, 2016 · 9 comments
Closed

x/sys/unix: add Fstatat on Linux on more than just GOARCH=arm64 #14216

dturner-tw opened this issue Feb 3, 2016 · 9 comments
Labels
FeatureRequest Issues asking for a new feature that does not need a proposal. FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@dturner-tw
Copy link

x/sys/unix doesn't have the following posix functions:

fstatat()
linkat()
mkfifoat()
readlinkat()
symlinkat()
utimensat()

I propose to add exactly fstat, symlinkat, and linkat because I think those are the only ones I am likely to use.

@ianlancetaylor ianlancetaylor added this to the Unreleased milestone Feb 4, 2016
@ianlancetaylor
Copy link
Member

Go for it.

@dturner-tw
Copy link
Author

Actually, looks like I'm not going to end up getting to this (at least not soon) -- I've been pulled away onto another project. So I'm going to leave this note here and if someone else gets to it before I come back, that's OK with me.

P.S. fdopendir is the *at family version of opendir, but since it's not a syscall, I'm not sure where it should live.

@perillo
Copy link
Contributor

perillo commented Apr 7, 2016

I need the fstatat syscall for a project, at least on Linux. In future I would like to add support for other systems like FreeBSD and Darwin.

@dturner-tw
Copy link
Author

fstatat-3.zip

Before I got pulled back to my main job hacking on Git, I had written the attached patch. At the time, I didn't have permission from Twitter legal to post it, but they have since given me permission. I don't recall what state this was in -- that is, what parts of it worked, what testing was done, etc. Sorry for the poor record-keeping here.

Anyway, it's a starting point. If you need any assignments or signatures in order to use this, I am happy to execute them.

@perillo
Copy link
Contributor

perillo commented Apr 7, 2016

@dturner-tw thanks for the patch.

However I already patched my local clone of x/sys in order to add support for fstatat for linux amd64. This will allow me to test my project and waiting for official support before releasing it.

Just some little differences from your code.

Instead of generating the newfstatat syscall, with the required wrapper function, I declared the syscall as

//sys   Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) = SYS_NEWFSTATAT

Another difference is that I declared Fstatat in syscall_linux_amd64.go, instead of syscall_linux.go, but this a topic that I'm not sure to understand well.

@tklauser
Copy link
Member

Support for linkat, readlinkat and symlinkat was added in golang/sys@9bb9f09 (#14459)

@bradfitz
Copy link
Contributor

Let's make this bug only about fstatat.

Here's the current status as of 50298aa:

unix/syscall_linux_arm64.go://sys       Fstatat(fd int, path string, stat *Stat_t, flags int) (err error)
unix/syscall_linux_arm64.go:    return Fstatat(AT_FDCWD, path, stat, 0)
unix/syscall_linux_arm64.go:    return Fstatat(AT_FDCWD, path, stat, AT_SYMLINK_NOFOLLOW)
unix/zsyscall_linux_arm64.go:func Fstatat(fd int, path string, stat *Stat_t, flags int) (err error) {
unix/zsyscall_linux_arm64.go:   _, _, e1 := Syscall6(SYS_FSTATAT, uintptr(fd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0)
unix/zsysnum_linux_386.go:      SYS_FSTATAT64              = 300
unix/zsysnum_linux_amd64.go:    SYS_NEWFSTATAT             = 262
unix/zsysnum_linux_arm.go:      SYS_FSTATAT64              = 327
unix/zsysnum_linux_arm64.go:    SYS_FSTATAT                = 79
unix/zsysnum_linux_mips.go:     SYS_FSTATAT64              = 4293
unix/zsysnum_linux_mips64.go:   SYS_NEWFSTATAT             = 5252
unix/zsysnum_linux_mips64le.go: SYS_NEWFSTATAT             = 5252
unix/zsysnum_linux_mipsle.go:   SYS_FSTATAT64              = 4293
unix/zsysnum_linux_ppc64.go:    SYS_NEWFSTATAT             = 291
unix/zsysnum_linux_ppc64le.go:  SYS_NEWFSTATAT             = 291
unix/zsysnum_linux_s390x.go:    SYS_NEWFSTATAT             = 293
unix/zsysnum_linux_sparc64.go:  SYS_FSTATAT64              = 289

It exists for arm64, but not the rest. Looks like the syscall has evolved a bit over the years, so this might require manually written wrappers to make the API feel the same everywhere (matching linux/arm64)

@bradfitz bradfitz changed the title x/sys/unix: missing fstatat and some other *at functions x/sys/unix: add Fstatat on Linux on more than just GOARCH=arm64 Jun 27, 2017
@bradfitz bradfitz added FeatureRequest Issues asking for a new feature that does not need a proposal. help wanted NeedsFix The path to resolution is known, but the work has not been done. labels Jun 27, 2017
@gopherbot
Copy link
Contributor

CL https://golang.org/cl/48530 mentions this issue.

gopherbot pushed a commit to golang/sys that referenced this issue Jul 14, 2017
Add the Mkfifoat function on Linux, akin to the existing Mkfifo function
but taking an additional dirfd parameter. See
http://man7.org/linux/man-pages/man3/mkfifo.3.html

Originally requested in golang/go#14216

Also remove the named result parameter for Mkfifo, as they add no
additional use (suggested by Brad Fitzpatrick).

Change-Id: I7b759752abf3e1469d7f883a7f13313e3062aeb4
Reviewed-on: https://go-review.googlesource.com/48530
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
micanzhang pushed a commit to micanzhang/sys that referenced this issue Sep 12, 2017
Add the Mkfifoat function on Linux, akin to the existing Mkfifo function
but taking an additional dirfd parameter. See
http://man7.org/linux/man-pages/man3/mkfifo.3.html

Originally requested in golang/go#14216

Also remove the named result parameter for Mkfifo, as they add no
additional use (suggested by Brad Fitzpatrick).

Change-Id: I7b759752abf3e1469d7f883a7f13313e3062aeb4
Reviewed-on: https://go-review.googlesource.com/48530
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@gopherbot
Copy link
Contributor

Change https://golang.org/cl/79795 mentions this issue: unix: add Fstatat on Linux for all GOOSes

@golang golang locked and limited conversation to collaborators Nov 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FeatureRequest Issues asking for a new feature that does not need a proposal. FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

6 participants