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

Emulates AT_SYMLINK_NOFOLLOW instead of sometimes implementing it #1588

Merged
merged 3 commits into from
Jul 22, 2023

Conversation

codefromthecrypt
Copy link
Contributor

futimes AT_SYMLINK_NOFOLLOW isn't universally supported. Before, we attempted to support it, but it was a bit hairy. It is better to take the hit of opening the file in the case we need to not follow symlinks than deal with something not very portable by default.

Adrian Cole added 2 commits July 21, 2023 14:19
futimes `AT_SYMLINK_NOFOLLOW` isn't universally supported. Before, we
attempted to support it, but it was a bit hairy. It is better to take
the hit of opening the file in the case we need to *not* follow symlinks
than deal with something not very portable by default.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
Signed-off-by: Adrian Cole <adrian@tetrate.io>
@codefromthecrypt codefromthecrypt marked this pull request as ready for review July 21, 2023 06:48
@@ -1456,7 +1456,16 @@ func pathFilestatSetTimesFn(_ context.Context, mod api.Module, params []uint64)
}

symlinkFollow := flags&wasip1.LOOKUP_SYMLINK_FOLLOW != 0
Copy link
Contributor Author

Choose a reason for hiding this comment

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

the flag is the opposite of the POSIX one in wasip1, presumably to avoid accidentally setting it by default.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
)

//go:noescape
//go:linkname utimensat syscall.utimensat
func utimensat(dirfd int, path string, times *[2]syscall.Timespec, flags int) error

func utimens(path string, times *[2]syscall.Timespec, symlinkFollow bool) error {
func utimens(path string, times *[2]syscall.Timespec) error {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

a later PR will switch this to os.Chtimes which is basically the same logic (once we remove the special OMIT and NOW constants)

@codefromthecrypt codefromthecrypt merged commit fb6147c into main Jul 22, 2023
@codefromthecrypt codefromthecrypt deleted the emulate-dont-follow branch July 22, 2023 00:03
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