/*
* Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
*
- * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
+ * @APPLE_LICENSE_HEADER_START@
*
- * This file contains Original Code and/or Modifications of Original Code
- * as defined in and that are subject to the Apple Public Source License
- * Version 2.0 (the 'License'). You may not use this file except in
- * compliance with the License. The rights granted to you under the License
- * may not be used to create, or enable the creation or redistribution of,
- * unlawful or unlicensed copies of an Apple operating system, or to
- * circumvent, violate, or enable the circumvention or violation of, any
- * terms of an Apple operating system software license agreement.
+ * The contents of this file constitute Original Code as defined in and
+ * are subject to the Apple Public Source License Version 1.1 (the
+ * "License"). You may not use this file except in compliance with the
+ * License. Please obtain a copy of the License at
+ * http://www.apple.com/publicsource and read it before using this file.
*
- * Please obtain a copy of the License at
- * http://www.opensource.apple.com/apsl/ and read it before using this file.
- *
- * The Original Code and all software distributed under the License are
- * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * This Original Code and all software distributed under the License are
+ * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
- * Please see the License for the specific language governing rights and
- * limitations under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
+ * License for the specific language governing rights and limitations
+ * under the License.
*
- * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
+ * @APPLE_LICENSE_HEADER_END@
*/
/*
* Copyright (c) 1990, 1996-1998 Apple Computer, Inc.
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/sysproto.h>
+#include <sys/proc_info.h>
#include <bsm/audit_kernel.h>
#define f_data f_fglob->fg_data
#define PSHMNAMLEN 31 /* maximum name segment length we bother with */
+
struct pshminfo {
unsigned int pshm_flags;
unsigned int pshm_usecount;
{
psx_shm_subsys_lck_grp_attr = lck_grp_attr_alloc_init();
- lck_grp_attr_setstat(psx_shm_subsys_lck_grp_attr);
psx_shm_subsys_lck_grp = lck_grp_alloc_init("posix shared memory", psx_shm_subsys_lck_grp_attr);
psx_shm_subsys_lck_attr = lck_attr_alloc_init();
- /* lck_attr_setdebug(psx_shm_subsys_lck_attr); */
lck_mtx_init(& psx_shm_subsys_mutex, psx_shm_subsys_lck_grp, psx_shm_subsys_lck_attr);
}
pinfo->pshm_mode = cmode;
pinfo->pshm_uid = kauth_cred_getuid(kauth_cred_get());
pinfo->pshm_gid = kauth_cred_get()->cr_gid;
+ bcopy(pnbuf, &pinfo->pshm_name[0], PSHMNAMLEN);
+ pinfo->pshm_name[PSHMNAMLEN]=0;
} else {
/* already exists */
if( pinfo->pshm_flags & PSHM_INDELETE) {
fp->f_type = DTYPE_PSXSHM;
fp->f_ops = &pshmops;
fp->f_data = (caddr_t)pnode;
- *fdflags(p, indx) &= ~UF_RESERVED;
+ procfdtbl_releasefd(p, indx, NULL);
fp_drop(p, indx, fp, 1);
proc_fdunlock(p);
struct pshminfo * pinfo;
struct pshmnode * pnode ;
kern_return_t kret;
- vm_offset_t user_addr;
+ mach_vm_offset_t user_addr;
mem_entry_name_port_t mem_object;
- vm_size_t size;
+ mach_vm_size_t size;
if (fp->f_type != DTYPE_PSXSHM) {
return(EINVAL);
PSHM_SUBSYS_UNLOCK();
size = round_page_64(length);
- kret = vm_allocate(current_map(), &user_addr, size, VM_FLAGS_ANYWHERE);
+ kret = mach_vm_allocate(current_map(), &user_addr, size, VM_FLAGS_ANYWHERE);
if (kret != KERN_SUCCESS)
goto out;
- kret = mach_make_memory_entry (current_map(), &size,
+ kret = mach_make_memory_entry_64 (current_map(), &size,
user_addr, VM_PROT_DEFAULT, &mem_object, 0);
if (kret != KERN_SUCCESS)
goto out;
- vm_deallocate(current_map(), user_addr, size);
+ mach_vm_deallocate(current_map(), user_addr, size);
PSHM_SUBSYS_LOCK();
pinfo->pshm_flags &= ~PSHM_DEFINED;
{
return(ENOTSUP);
}
+
+int
+fill_pshminfo(struct pshmnode * pshm, struct pshm_info * info)
+{
+ struct pshminfo *pinfo;
+ struct stat *sb;
+
+ PSHM_SUBSYS_LOCK();
+ if ((pinfo = pshm->pinfo) == PSHMINFO_NULL){
+ PSHM_SUBSYS_UNLOCK();
+ return(EINVAL);
+ }
+
+ sb = &info->pshm_stat;
+
+ bzero(sb, sizeof(struct stat));
+ sb->st_mode = pinfo->pshm_mode;
+ sb->st_uid = pinfo->pshm_uid;
+ sb->st_gid = pinfo->pshm_gid;
+ sb->st_size = pinfo->pshm_length;
+
+ info->pshm_mappaddr = pshm->mapp_addr;
+ bcopy(&pinfo->pshm_name[0], &info->pshm_name[0], PSHMNAMLEN+1);
+
+ PSHM_SUBSYS_UNLOCK();
+ return(0);
+}
+
+