Skip to content

x/sys/unix: Linux: utimensat syscall takes a NULL path, wrapper can't #49699

@unbrice

Description

@unbrice

What version of Go are you using (go version)?

x/sys package v0.0.0-20211117180635-dee7805ff2e1

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
The version of Golang we use at Google (I believe this is not public information, please correct me if I'm wrong and I'll share go env)

What did you do?

I opened the documentation of sys/unix and also read its source code.

What did you expect to see?

I expected to be able to do the equivalent to the futimens glibc function.
This could have been its own function. Alternatively the wrapper of utimensat could have given empty strings the special meaning that NULL pointers have for the syscall.

(On Linux, in the glibc, futimens is implemented on top of utimensat by passing a NULL pointer as path. This is described in the NOTES section of the manpage.)

I also expected to see Futimes implemented in a way that did not go through /proc

What did you see instead?

  • The wrapper of utimensat, named UtimesNanoAt, takes a string for the path and does not have a special case to pass NULL when the string is empty.
  • The wrapper of Utimes goes to /proc instead of taking advantage of a NULL path
  • There is no equivalent for futimens

Please let me know if you'd like me to contribute a fix. Unless someone suggest another approach, I offer to send a PR that leaves UtimesNanoAt unchanged and adds FUtimesNano.

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions