Changeset c1f68b0 in mainline for kernel/generic/src/cap/cap.c
- Timestamp:
- 2017-10-28T11:40:41Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- eca820c
- Parents:
- 15d9fe6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/cap/cap.c
r15d9fe6 rc1f68b0 148 148 void caps_task_init(task_t *task) 149 149 { 150 mutex_initialize(&task->cap_info->lock, MUTEX_ PASSIVE);150 mutex_initialize(&task->cap_info->lock, MUTEX_RECURSIVE); 151 151 152 152 for (kobject_type_t t = 0; t < KOBJECT_TYPE_MAX; t++) … … 238 238 if (cap->state == CAP_STATE_PUBLISHED && cap->kobject->ops->reclaim && 239 239 cap->kobject->ops->reclaim(cap->kobject)) { 240 kobject_t *kobj = cap_unpublish _locked(cap->task, cap->handle,240 kobject_t *kobj = cap_unpublish(cap->task, cap->handle, 241 241 cap->kobject->type); 242 242 kobject_put(kobj); … … 318 318 } 319 319 320 /** @copydoc cap_unpublish() 321 * 322 * Can only be called internally by the capability subsytem or from a 323 * caps_apply_to_kobject_type() callback. 324 */ 325 kobject_t * 326 cap_unpublish_locked(task_t *task, cap_handle_t handle, kobject_type_t type) 320 /** Unpublish published capability 321 * 322 * The kernel object is moved out of the capability. In other words, the 323 * capability's reference to the objects is handed over to the kernel object 324 * pointer returned by this function. Once unpublished, the capability does not 325 * refer to any kernel object anymore. 326 * 327 * @param task Task in which to unpublish the capability. 328 * @param handle Capability handle. 329 * @param type Kernel object type of the object associated with the 330 * capability. 331 */ 332 kobject_t *cap_unpublish(task_t *task, cap_handle_t handle, kobject_type_t type) 327 333 { 328 334 kobject_t *kobj = NULL; 329 335 336 mutex_lock(&task->cap_info->lock); 330 337 cap_t *cap = cap_get(task, handle, CAP_STATE_PUBLISHED); 331 338 if (cap) { … … 338 345 } 339 346 } 347 mutex_unlock(&task->cap_info->lock); 340 348 341 349 return kobj; 342 350 } 343 351 344 /** Unpublish published capability 345 * 346 * The kernel object is moved out of the capability. In other words, the 347 * capability's reference to the objects is handed over to the kernel object 348 * pointer returned by this function. Once unpublished, the capability does not 349 * refer to any kernel object anymore. 350 * 351 * @param task Task in which to unpublish the capability. 352 /** Free allocated capability 353 * 354 * @param task Task in which to free the capability. 352 355 * @param handle Capability handle. 353 * @param type Kernel object type of the object associated with the 354 * capability. 355 */ 356 kobject_t *cap_unpublish(task_t *task, cap_handle_t handle, kobject_type_t type) 357 { 358 359 mutex_lock(&task->cap_info->lock); 360 kobject_t *kobj = cap_unpublish_locked(task, handle, type); 361 mutex_unlock(&task->cap_info->lock); 362 363 return kobj; 364 } 365 366 /** @copydoc cap_free() 367 * 368 * Can only be called internally by the capability subsytem or from a 369 * caps_apply_to_kobject_type() callback. 370 */ 371 void cap_free_locked(task_t *task, cap_handle_t handle) 356 */ 357 void cap_free(task_t *task, cap_handle_t handle) 372 358 { 373 359 assert(handle >= 0); 374 360 assert(handle < MAX_CAPS); 375 361 362 mutex_lock(&task->cap_info->lock); 376 363 cap_t *cap = cap_get(task, handle, CAP_STATE_ALLOCATED); 377 364 … … 381 368 ra_free(task->cap_info->handles, handle, 1); 382 369 slab_free(cap_slab, cap); 383 }384 385 /** Free allocated capability386 *387 * @param task Task in which to free the capability.388 * @param handle Capability handle.389 */390 void cap_free(task_t *task, cap_handle_t handle)391 {392 mutex_lock(&task->cap_info->lock);393 cap_free_locked(task, handle);394 370 mutex_unlock(&task->cap_info->lock); 395 371 }
Note:
See TracChangeset
for help on using the changeset viewer.