Changeset View
Changeset View
Standalone View
Standalone View
head/sys/kern/uipc_shm.c
Show First 20 Lines • Show All 591 Lines • ▼ Show 20 Lines | shm_alloc(struct ucred *ucred, mode_t mode) | ||||
shmfd = malloc(sizeof(*shmfd), M_SHMFD, M_WAITOK | M_ZERO); | shmfd = malloc(sizeof(*shmfd), M_SHMFD, M_WAITOK | M_ZERO); | ||||
shmfd->shm_size = 0; | shmfd->shm_size = 0; | ||||
shmfd->shm_uid = ucred->cr_uid; | shmfd->shm_uid = ucred->cr_uid; | ||||
shmfd->shm_gid = ucred->cr_gid; | shmfd->shm_gid = ucred->cr_gid; | ||||
shmfd->shm_mode = mode; | shmfd->shm_mode = mode; | ||||
shmfd->shm_object = vm_pager_allocate(OBJT_SWAP, NULL, | shmfd->shm_object = vm_pager_allocate(OBJT_SWAP, NULL, | ||||
shmfd->shm_size, VM_PROT_DEFAULT, 0, ucred); | shmfd->shm_size, VM_PROT_DEFAULT, 0, ucred); | ||||
KASSERT(shmfd->shm_object != NULL, ("shm_create: vm_pager_allocate")); | KASSERT(shmfd->shm_object != NULL, ("shm_create: vm_pager_allocate")); | ||||
shmfd->shm_object->pg_color = 0; | |||||
VM_OBJECT_WLOCK(shmfd->shm_object); | |||||
vm_object_clear_flag(shmfd->shm_object, OBJ_ONEMAPPING); | |||||
vm_object_set_flag(shmfd->shm_object, OBJ_COLORED | OBJ_NOSPLIT); | |||||
VM_OBJECT_WUNLOCK(shmfd->shm_object); | |||||
vfs_timestamp(&shmfd->shm_birthtime); | vfs_timestamp(&shmfd->shm_birthtime); | ||||
shmfd->shm_atime = shmfd->shm_mtime = shmfd->shm_ctime = | shmfd->shm_atime = shmfd->shm_mtime = shmfd->shm_ctime = | ||||
shmfd->shm_birthtime; | shmfd->shm_birthtime; | ||||
shmfd->shm_ino = alloc_unr64(&shm_ino_unr); | shmfd->shm_ino = alloc_unr64(&shm_ino_unr); | ||||
refcount_init(&shmfd->shm_refs, 1); | refcount_init(&shmfd->shm_refs, 1); | ||||
mtx_init(&shmfd->shm_mtx, "shmrl", NULL, MTX_DEF); | mtx_init(&shmfd->shm_mtx, "shmrl", NULL, MTX_DEF); | ||||
rangelock_init(&shmfd->shm_rl); | rangelock_init(&shmfd->shm_rl); | ||||
#ifdef MAC | #ifdef MAC | ||||
▲ Show 20 Lines • Show All 900 Lines • Show Last 20 Lines |