Skip to content

Commit 62a3703

Browse files
ayushr2gvisor-bot
authored andcommitted
[vfs] Fix rename implementation in OrderedChildren.
Fixes #3027 as there is just 1 writable user using OrderedChildren's rename, unlink and rmdir (kernfs.syntheticDirectory) but it doesn't support the sticky bit yet. Fuse which is the other writable user implements its own Inode operations. PiperOrigin-RevId: 354386522
1 parent bc40393 commit 62a3703

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pkg/sentry/fsimpl/kernfs/inode_impl_util.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,8 @@ type OrderedChildrenOptions struct {
371371
// OrderedChildren may modify the tracked children. This applies to
372372
// operations related to rename, unlink and rmdir. If an OrderedChildren is
373373
// not writable, these operations all fail with EPERM.
374+
//
375+
// Note that writable users must implement the sticky bit (I_SVTX).
374376
Writable bool
375377
}
376378

@@ -556,7 +558,6 @@ func (o *OrderedChildren) Unlink(ctx context.Context, name string, child Inode)
556558
return err
557559
}
558560

559-
// TODO(gvisor.dev/issue/3027): Check sticky bit before removing.
560561
o.removeLocked(name)
561562
return nil
562563
}
@@ -603,8 +604,8 @@ func (o *OrderedChildren) Rename(ctx context.Context, oldname, newname string, c
603604
if err := o.checkExistingLocked(oldname, child); err != nil {
604605
return err
605606
}
607+
o.removeLocked(oldname)
606608

607-
// TODO(gvisor.dev/issue/3027): Check sticky bit before removing.
608609
dst.replaceChildLocked(ctx, newname, child)
609610
return nil
610611
}

0 commit comments

Comments
 (0)