Implement setxattr for overlays.

PiperOrigin-RevId: 290186303
This commit is contained in:
Dean Deng
2020-01-16 18:15:02 -08:00
committed by gVisor bot
parent 1e7f0c822b
commit 7a45ae7e67
3 changed files with 13 additions and 6 deletions
+2 -2
View File
@@ -270,9 +270,9 @@ func (i *Inode) GetXattr(ctx context.Context, name string, size uint64) (string,
}
// SetXattr calls i.InodeOperations.SetXattr with i as the Inode.
func (i *Inode) SetXattr(ctx context.Context, name, value string, flags uint32) error {
func (i *Inode) SetXattr(ctx context.Context, d *Dirent, name, value string, flags uint32) error {
if i.overlay != nil {
return overlaySetxattr(ctx, i.overlay, name, value, flags)
return overlaySetxattr(ctx, i.overlay, d, name, value, flags)
}
return i.InodeOperations.SetXattr(ctx, i, name, value, flags)
}
+10 -3
View File
@@ -552,9 +552,16 @@ func overlayGetXattr(ctx context.Context, o *overlayEntry, name string, size uin
return s, err
}
// TODO(b/146028302): Support setxattr for overlayfs.
func overlaySetxattr(ctx context.Context, o *overlayEntry, name, value string, flags uint32) error {
return syserror.EOPNOTSUPP
func overlaySetxattr(ctx context.Context, o *overlayEntry, d *Dirent, name, value string, flags uint32) error {
// Don't allow changes to overlay xattrs through a setxattr syscall.
if strings.HasPrefix(XattrOverlayPrefix, name) {
return syserror.EPERM
}
if err := copyUp(ctx, d); err != nil {
return err
}
return o.upper.SetXattr(ctx, d, name, value, flags)
}
func overlayListXattr(ctx context.Context, o *overlayEntry) (map[string]struct{}, error) {
+1 -1
View File
@@ -142,7 +142,7 @@ func setXattr(t *kernel.Task, d *fs.Dirent, dirPath bool, nameAddr, valueAddr us
return syserror.EOPNOTSUPP
}
return d.Inode.SetXattr(t, name, value, flags)
return d.Inode.SetXattr(t, d, name, value, flags)
}
func copyInXattrName(t *kernel.Task, nameAddr usermem.Addr) (string, error) {