summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--pkg/p9/buffer.go4
-rw-r--r--pkg/p9/p9.go12
2 files changed, 10 insertions, 6 deletions
diff --git a/pkg/p9/buffer.go b/pkg/p9/buffer.go
index 9575ddf12..b7bb14ef9 100644
--- a/pkg/p9/buffer.go
+++ b/pkg/p9/buffer.go
@@ -144,7 +144,7 @@ func (b *buffer) ReadGID() GID {
// ReadPermissions reads a file mode value and applies the mask for permissions.
func (b *buffer) ReadPermissions() FileMode {
- return b.ReadFileMode() & PermissionsMask
+ return b.ReadFileMode() & permissionsMask
}
// ReadFileMode reads a file mode value.
@@ -230,7 +230,7 @@ func (b *buffer) WriteGID(gid GID) {
// WritePermissions applies a permissions mask and writes the FileMode.
func (b *buffer) WritePermissions(perm FileMode) {
- b.WriteFileMode(perm & PermissionsMask)
+ b.WriteFileMode(perm & permissionsMask)
}
// WriteFileMode writes a FileMode.
diff --git a/pkg/p9/p9.go b/pkg/p9/p9.go
index be644e7bf..9e8b7d467 100644
--- a/pkg/p9/p9.go
+++ b/pkg/p9/p9.go
@@ -130,8 +130,12 @@ const (
// Exec is a mode bit indicating exec permission.
Exec FileMode = 01
- // PermissionsMask is the mask to apply to FileModes for permissions.
- PermissionsMask FileMode = 0777
+ // AllPermissions is a mask with rwx bits set for user, group and others.
+ AllPermissions FileMode = 0777
+
+ // permissionsMask is the mask to apply to FileModes for permissions. It
+ // includes rwx bits for user, group and others, and sticky bit (01000).
+ permissionsMask FileMode = 01777
)
// QIDType is the most significant byte of the FileMode word, to be used as the
@@ -157,7 +161,7 @@ func (m FileMode) FileType() FileMode {
// Permissions returns just the permission bits of the mode.
func (m FileMode) Permissions() FileMode {
- return m & PermissionsMask
+ return m & permissionsMask
}
// Writable returns the mode with write bits added.
@@ -987,7 +991,7 @@ func (s *SetAttr) Encode(b *buffer) {
// Apply applies this to the given Attr.
func (a *Attr) Apply(mask SetAttrMask, attr SetAttr) {
if mask.Permissions {
- a.Mode = a.Mode&^PermissionsMask | (attr.Permissions & PermissionsMask)
+ a.Mode = a.Mode&^permissionsMask | (attr.Permissions & permissionsMask)
}
if mask.UID {
a.UID = attr.UID