Proposal Details
I have code which opens both files and directories as files to perform various actions such as fetching and comparing generations (I need to upstream to linux once I write tests) or other metadata with SyscallConn.
Trying to use #67002 to make it less conservative with some TOCTOU edge cases prove challenging since *os.Root does not provide needed SyscallConn to fetch the generation of directories and more architecturally the current codepath is to open everything as a *os.File and then use statx to decide what to do next.
package os
// AsRoot open the File as a Root if it is a directory otherwise it errors.
// The Root is returned with a new lifetime such that each need to be closed independently.
func (*File) AsRoot() (*Root, error)
// AsFile opens the Root as a File.
// The File is returned with a new lifetime such that each need to be closed independently.
func (*Root) AsFile() (*File, error)
Proposal Details
I have code which opens both files and directories as files to perform various actions such as fetching and comparing generations (I need to upstream to linux once I write tests) or other metadata with
SyscallConn.Trying to use #67002 to make it less conservative with some TOCTOU edge cases prove challenging since
*os.Rootdoes not provide neededSyscallConnto fetch the generation of directories and more architecturally the current codepath is to open everything as a*os.Fileand then usestatxto decide what to do next.