Changeset View
Changeset View
Standalone View
Standalone View
head/sys/kern/kern_descrip.c
Show First 20 Lines • Show All 1,486 Lines • ▼ Show 20 Lines | |||||
* Copy filecaps structure allocating memory for ioctls array if needed. | * Copy filecaps structure allocating memory for ioctls array if needed. | ||||
* | * | ||||
* The last parameter indicates whether the fdtable is locked. If it is not and | * 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. | * 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 | * Note that if the table was not locked, the caller has to check the relevant | ||||
* sequence counter to determine whether the operation was successful. | * sequence counter to determine whether the operation was successful. | ||||
*/ | */ | ||||
int | bool | ||||
filecaps_copy(const struct filecaps *src, struct filecaps *dst, bool locked) | filecaps_copy(const struct filecaps *src, struct filecaps *dst, bool locked) | ||||
{ | { | ||||
size_t size; | size_t size; | ||||
if (src->fc_ioctls != NULL && !locked) | |||||
return (false); | |||||
*dst = *src; | *dst = *src; | ||||
if (src->fc_ioctls == NULL) | if (src->fc_ioctls == NULL) | ||||
return (0); | return (true); | ||||
if (!locked) | |||||
return (1); | |||||
KASSERT(src->fc_nioctls > 0, | KASSERT(src->fc_nioctls > 0, | ||||
("fc_ioctls != NULL, but fc_nioctls=%hd", src->fc_nioctls)); | ("fc_ioctls != NULL, but fc_nioctls=%hd", src->fc_nioctls)); | ||||
size = sizeof(src->fc_ioctls[0]) * src->fc_nioctls; | size = sizeof(src->fc_ioctls[0]) * src->fc_nioctls; | ||||
dst->fc_ioctls = malloc(size, M_FILECAPS, M_WAITOK); | dst->fc_ioctls = malloc(size, M_FILECAPS, M_WAITOK); | ||||
bcopy(src->fc_ioctls, dst->fc_ioctls, size); | bcopy(src->fc_ioctls, dst->fc_ioctls, size); | ||||
return (0); | return (true); | ||||
} | } | ||||
static u_long * | static u_long * | ||||
filecaps_copy_prep(const struct filecaps *src) | filecaps_copy_prep(const struct filecaps *src) | ||||
{ | { | ||||
u_long *ioctls; | u_long *ioctls; | ||||
size_t size; | size_t size; | ||||
▲ Show 20 Lines • Show All 2,736 Lines • Show Last 20 Lines |