-
Notifications
You must be signed in to change notification settings - Fork 117
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
squashfs: set Mode bits correctly in FileInfo #199
Conversation
I have gone through some very not fun times dealing with when this should have the dir, etc. mode bits set and when not. Are you sure that this is consistently handled this way in go? i.e. when I use the usual built-in |
Yes I've been there too :-)
The If you look at the help for type FileMode uint32
A FileMode represents a file's mode and permission bits. The bits have the
same definition on all systems, so that information about files can be moved
from one system to another portably. Not all bits apply to all systems.
The only required bit is ModeDir for directories. And if you look at the actual definition of the bits you'll see that they are defined like this for all OSes. // The defined file mode bits are the most significant bits of the FileMode.
// The nine least-significant bits are the standard Unix rwxrwxrwx permissions.
// The values of these bits should be considered part of the public API and
// may be used in wire protocols or disk representations: they must not be
// changed, although new bits might be added.
const (
// The single letters are the abbreviations
// used by the String method's formatting.
ModeDir FileMode = 1 << (32 - 1 - iota) // d: is a directory
ModeAppend // a: append-only
ModeExclusive // l: exclusive use
ModeTemporary // T: temporary file; Plan 9 only
ModeSymlink // L: symbolic link
ModeDevice // D: device file
ModeNamedPipe // p: named pipe (FIFO)
ModeSocket // S: Unix domain socket
ModeSetuid // u: setuid
ModeSetgid // g: setgid
ModeCharDevice // c: Unix character device, when ModeDevice is set
ModeSticky // t: sticky
ModeIrregular // ?: non-regular file; nothing else is known about this file
// Mask for the type bits. For regular files, none will be set.
ModeType = ModeDir | ModeSymlink | ModeNamedPipe | ModeSocket | ModeDevice | ModeCharDevice | ModeIrregular
ModePerm FileMode = 0777 // Unix permission bits
) So I feel confident in saying that yes, it will always use exactly these bits whatever OS you are running on. Perhaps the code I wrote to implement this should zero out everything except the 9 unix permissions bits so there aren't any Linux bits left in the mode so we've entirely Go-ified the mode. Currently it only zeroes out the |
Any downside to doing this? It sounds right to me, but 🤷♂️
Yeah, I implemented a read-write |
I think making the FileMode 100% Go friendly is the right thing to do. If there are other bits in there we can extract to Go standard bits then that can be future work. I've updated the PR
:-) |
No description provided.