-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
proposal: os: add ReparsePointTag #70735
Comments
This is a Windows specific concept and does not belong in the os package. It could go in a syscall package however. |
It seems hard to put this proposed function in any package other than the os package, because it would have to interrogate the unexported Windows-specific That said I also wonder whether there is some way to handle this general idea outside the os package. |
The unexported struct can be moved to an |
Which would be de input of the syscall function? |
@qmuntal I have not checked it, but what about fs.FileInfo? os.FileInfo is an alias now. EDIT: io/fs imports time which imports syscall, so not possible. |
I don't understand how these work or what they actually do, but surely it comes back to some FD or Windows equivalent which you can pull out of |
I think the point here is that the requested information has already been retrieved from the OS by the time the caller is holding the Lines 46 to 79 in 6705ac6
Note that Edit: Whoops... submitted to early. 🙄 It seems like this could therefore be exported as a new field of the Lines 276 to 285 in 6705ac6
|
That was also my initial thought, but I worry that we will confuse users that legitimately uses But maybe it's fine given that these projects should be using golang.org/x/sys.Win32FileAttributeData instead. |
Is |
It is a standard Windows type: https://learn.microsoft.com/en-us/windows/win32/api/fileapi/ns-fileapi-win32_file_attribute_data. |
Thanks, unfortunately in that case it seems weird to add a field. That said, perhaps for a reparse point only we could have the |
While I acknowledge that is isn't really clear how to get there without breaking backward compatibility now, it seems like this Then one of those interfaces could've been an extra indirection over getting this I'm struggling to think of a way to get there from here without breaking code that relies on the current concrete type. Adding new unexported members to it and then having it implement extra interfaces in terms of those unexported members could potentially work, but it'd be weird to do that to a type that is intended to correspond directly to a Win32 API type. 😖 |
Just spitballing, but what about a new API that returns platform-specific data about any On Windows, that would be the reparsepoint data, e.g. something that could be passed to A quick look suggests that the only other in-tree user is Solaris (#52259) and I have no idea what useful data could be provided in those three cases. |
It will be a breaking change, unfortunately.
If we did so,
Thanks for the context! |
Thanks for the discussion. There are two path forwards right now that doesn't involve breaking changes:
I'm leaning towards option 2. What do you think? |
Proposal Details
Windows applications might need to know the reparse point tag of a given
os.FileInfo
. Although the Windows implementation ofos.FileInfo
knows the reparse point tag, there is no way to get that information using the publicos
API. This means that applications are forced to partially reimplementos.Lstat
by opening the file and callingGetFileInformationByHandleEx
.I propose to add the following helper function to the
os
package:The
ReparsePointTag
implementation could be made moreos
-agnostic by also defining an interface that externalos.FileInfo
implementations could implement to get the reparse point tag. This might be an overkill for now, as reparse points are not a broadly-addopted concept outside NTFS file systems.ReparsePointTag
would only be useful on Windows for now, although it could potentially be implemented on other OSes supporting NTFS drivers.@golang/windows
The text was updated successfully, but these errors were encountered: