You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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)
The text was updated successfully, but these errors were encountered:
I discussed this with @neild already and:
I think it might be possible to convert *os.File → *os.Root by using SyscallConn then calling os.OpenRoot with fmt.Sprintf("/proc/self/fd/%d") on Linux.
Not portable tho.
He pointed out *os.Root → *os.File should be possible by calling (*os.Root).Open(root, ".").
I am not sure if lifetimes should be independent or not.
I guess from a point of implementing in the std this is the easiest, but as a consumer I would sometime want the opposite.
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 neededSyscallConn
to fetch the generation of directories and more architecturally the current codepath is to open everything as a*os.File
and then usestatx
to decide what to do next.The text was updated successfully, but these errors were encountered: