Skip to main content

duplicate

Function duplicate 

Source
pub fn duplicate(ctx: &ServiceContext, cap: Cap) -> Result<Cap, Error>
Expand description

Duplicate a capability you hold, to hand the copy away while keeping the original.

The copy carries the SAME resource, generation and rights - this does not narrow, and there is no rights argument because the kernel’s DeriveCap does not take one. Narrowing is real (CLAUDE.md 7.3) and happens where a capability is minted or granted, not here.

Requires the source to hold GRANT: a capability you may not pass on is also one you may not copy for passing on. Fails if it lacks GRANT, has gone stale, or the table is full - and those three are not distinguished, which is a limitation of the syscall rather than of this wrapper.