summaryrefslogtreecommitdiffhomepage
path: root/pkg/sentry/fs/fsutil
diff options
context:
space:
mode:
authorNicolas Lacasse <nlacasse@google.com>2019-04-05 15:48:26 -0700
committerShentubot <shentubot@google.com>2019-04-05 15:49:39 -0700
commitee7e6d33b2a017a53bebfdc55d182f53474d4d7d (patch)
tree91c302c8844f62f9c168e571231ecf4cb5e3fbb7 /pkg/sentry/fs/fsutil
parentf44f2f73b068658ddf632586e2178e372fcd1cbd (diff)
Use string type for extended attribute values, instead of []byte.
Strings are a better fit for this usage because they are immutable in Go, and can contain arbitrary bytes. It also allows us to avoid casting bytes to string (and the associated allocation) in the hot path when checking for overlay whiteouts. PiperOrigin-RevId: 242208856 Change-Id: I7699ae6302492eca71787dd0b72e0a5a217a3db2
Diffstat (limited to 'pkg/sentry/fs/fsutil')
-rw-r--r--pkg/sentry/fs/fsutil/inode.go16
1 files changed, 8 insertions, 8 deletions
diff --git a/pkg/sentry/fs/fsutil/inode.go b/pkg/sentry/fs/fsutil/inode.go
index c1ad45e52..2673d73d7 100644
--- a/pkg/sentry/fs/fsutil/inode.go
+++ b/pkg/sentry/fs/fsutil/inode.go
@@ -197,25 +197,25 @@ func (i *InodeSimpleAttributes) NotifyStatusChange(ctx context.Context) {
type InodeSimpleExtendedAttributes struct {
// mu protects xattrs.
mu sync.RWMutex `state:"nosave"`
- xattrs map[string][]byte
+ xattrs map[string]string
}
// Getxattr implements fs.InodeOperations.Getxattr.
-func (i *InodeSimpleExtendedAttributes) Getxattr(_ *fs.Inode, name string) ([]byte, error) {
+func (i *InodeSimpleExtendedAttributes) Getxattr(_ *fs.Inode, name string) (string, error) {
i.mu.RLock()
value, ok := i.xattrs[name]
i.mu.RUnlock()
if !ok {
- return nil, syserror.ENOATTR
+ return "", syserror.ENOATTR
}
return value, nil
}
// Setxattr implements fs.InodeOperations.Setxattr.
-func (i *InodeSimpleExtendedAttributes) Setxattr(_ *fs.Inode, name string, value []byte) error {
+func (i *InodeSimpleExtendedAttributes) Setxattr(_ *fs.Inode, name, value string) error {
i.mu.Lock()
if i.xattrs == nil {
- i.xattrs = make(map[string][]byte)
+ i.xattrs = make(map[string]string)
}
i.xattrs[name] = value
i.mu.Unlock()
@@ -424,12 +424,12 @@ func (InodeNotSymlink) Getlink(context.Context, *fs.Inode) (*fs.Dirent, error) {
type InodeNoExtendedAttributes struct{}
// Getxattr implements fs.InodeOperations.Getxattr.
-func (InodeNoExtendedAttributes) Getxattr(*fs.Inode, string) ([]byte, error) {
- return nil, syserror.EOPNOTSUPP
+func (InodeNoExtendedAttributes) Getxattr(*fs.Inode, string) (string, error) {
+ return "", syserror.EOPNOTSUPP
}
// Setxattr implements fs.InodeOperations.Setxattr.
-func (InodeNoExtendedAttributes) Setxattr(*fs.Inode, string, []byte) error {
+func (InodeNoExtendedAttributes) Setxattr(*fs.Inode, string, string) error {
return syserror.EOPNOTSUPP
}