diff options
author | gVisor bot <gvisor-bot@google.com> | 2021-02-17 23:45:20 +0000 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2021-02-17 23:45:20 +0000 |
commit | 45be62df210badd412752214925e0de28887ed54 (patch) | |
tree | 3ac83e6200ea1ffb2178e63fe075a543649b3244 /pkg/sentry/fs/inode_overlay.go | |
parent | 741e62541882e96e46adeafcda43205e67f81443 (diff) | |
parent | 4bc7daf91a0d9102fa477b199964e7db45066da1 (diff) |
Merge release-20210208.0-63-g4bc7daf91 (automated)
Diffstat (limited to 'pkg/sentry/fs/inode_overlay.go')
-rw-r--r-- | pkg/sentry/fs/inode_overlay.go | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/pkg/sentry/fs/inode_overlay.go b/pkg/sentry/fs/inode_overlay.go index b16ab08ba..e97afc626 100644 --- a/pkg/sentry/fs/inode_overlay.go +++ b/pkg/sentry/fs/inode_overlay.go @@ -333,6 +333,19 @@ func overlayRemove(ctx context.Context, o *overlayEntry, parent *Dirent, child * } child.Inode.overlay.copyMu.RLock() defer child.Inode.overlay.copyMu.RUnlock() + if child.Inode.StableAttr.Type == Directory { + // RemoveDirectory requires that the directory is empty. + ser := &CollectEntriesSerializer{} + dirCtx := &DirCtx{ + Serializer: ser, + } + if _, err := overlayIterateDirLocked(ctx, child.Inode.overlay, child, dirCtx, 0); err != nil { + return err + } + if ser.Written() != 0 { + return syserror.ENOTEMPTY + } + } if child.Inode.overlay.upper != nil { if child.Inode.StableAttr.Type == Directory { if err := o.upper.InodeOperations.RemoveDirectory(ctx, o.upper, child.name); err != nil { |