MCPcopy Create free account
hub / github.com/F-Stack/f-stack / filecaps_copy

Function filecaps_copy

freebsd/kern/kern_descrip.c:1652–1670  ·  view source on GitHub ↗

* Copy filecaps structure allocating memory for ioctls array if needed. * * The last parameter indicates whether the fdtable is locked. If it is not and * ioctls are encountered, copying fails and the caller must lock the table. * * Note that if the table was not locked, the caller has to check the relevant * sequence counter to determine whether the operation was successful. */

Source from the content-addressed store, hash-verified

1650 * sequence counter to determine whether the operation was successful.
1651 */
1652bool
1653filecaps_copy(const struct filecaps *src, struct filecaps *dst, bool locked)
1654{
1655 size_t size;
1656
1657 if (src->fc_ioctls != NULL && !locked)
1658 return (false);
1659 memcpy(dst, src, sizeof(*src));
1660 if (src->fc_ioctls == NULL)
1661 return (true);
1662
1663 KASSERT(src->fc_nioctls > 0,
1664 ("fc_ioctls != NULL, but fc_nioctls=%hd", src->fc_nioctls));
1665
1666 size = sizeof(src->fc_ioctls[0]) * src->fc_nioctls;
1667 dst->fc_ioctls = malloc(size, M_FILECAPS, M_WAITOK);
1668 memcpy(dst->fc_ioctls, src->fc_ioctls, size);
1669 return (true);
1670}
1671
1672static u_long *
1673filecaps_copy_prep(const struct filecaps *src)

Callers 6

fdcopyFunction · 0.85
fdcopy_remappedFunction · 0.85
fget_cap_lockedFunction · 0.85
fget_capFunction · 0.85
fgetvp_lookup_smrFunction · 0.85
unp_internalizeFunction · 0.85

Calls 2

mallocFunction · 0.85
memcpyFunction · 0.50

Tested by

no test coverage detected