* 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. */
| 1650 | * sequence counter to determine whether the operation was successful. |
| 1651 | */ |
| 1652 | bool |
| 1653 | filecaps_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 | |
| 1672 | static u_long * |
| 1673 | filecaps_copy_prep(const struct filecaps *src) |
no test coverage detected