X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/0a7de7458d150b5d4dffc935ba399be265ef0a1a..a991bd8d3e7fe02dbca0644054bab73c5b75324a:/bsd/kern/posix_shm.c diff --git a/bsd/kern/posix_shm.c b/bsd/kern/posix_shm.c index 3cd6aebd1..bffc46999 100644 --- a/bsd/kern/posix_shm.c +++ b/bsd/kern/posix_shm.c @@ -86,13 +86,9 @@ #include #include -#define f_flag f_fglob->fg_flag -#define f_type f_fglob->fg_ops->fo_type -#define f_msgcount f_fglob->fg_msgcount -#define f_cred f_fglob->fg_cred -#define f_ops f_fglob->fg_ops -#define f_offset f_fglob->fg_offset -#define f_data f_fglob->fg_data +#define f_flag fp_glob->fg_flag +#define f_ops fp_glob->fg_ops +#define f_data fp_glob->fg_data /* * Used to construct the list of memory objects @@ -187,29 +183,22 @@ static pshm_info_t *pshm_cache_search(pshm_info_t * look); static void pshm_cache_add(pshm_info_t *entry); static void pshm_cache_delete(pshm_info_t *entry); -static int pshm_read(struct fileproc *fp, struct uio *uio, int flags, vfs_context_t ctx); -static int pshm_write(struct fileproc *fp, struct uio *uio, int flags, vfs_context_t ctx); -static int pshm_ioctl(struct fileproc *fp, u_long com, caddr_t data, vfs_context_t ctx); -static int pshm_select(struct fileproc *fp, int which, void *wql, vfs_context_t ctx); static int pshm_closefile(struct fileglob *fg, vfs_context_t ctx); -static int pshm_kqfilter(struct fileproc *fp, struct knote *kn, - struct kevent_internal_s *kev, vfs_context_t ctx); - static int pshm_access(pshm_info_t *pinfo, int mode, kauth_cred_t cred, proc_t p); int pshm_cache_purge_all(proc_t p); static int pshm_unlink_internal(pshm_info_t *pinfo); static const struct fileops pshmops = { - .fo_type = DTYPE_PSXSHM, - .fo_read = pshm_read, - .fo_write = pshm_write, - .fo_ioctl = pshm_ioctl, - .fo_select = pshm_select, - .fo_close = pshm_closefile, - .fo_kqfilter = pshm_kqfilter, - .fo_drain = NULL, + .fo_type = DTYPE_PSXSHM, + .fo_read = fo_no_read, + .fo_write = fo_no_write, + .fo_ioctl = fo_no_ioctl, + .fo_select = fo_no_select, + .fo_close = pshm_closefile, + .fo_drain = fo_no_drain, + .fo_kqfilter = fo_no_kqfilter, }; /* @@ -358,12 +347,12 @@ shm_open(proc_t p, struct shm_open_args *uap, int32_t *retval) pshmnode_t *new_pnode = NULL; struct fileproc *fp = NULL; int fmode; - int cmode = uap->mode; + mode_t cmode = (mode_t)uap->mode; bool incache = false; bool have_label = false; AUDIT_ARG(fflags, uap->oflag); - AUDIT_ARG(mode, uap->mode); + AUDIT_ARG(mode, cmode); /* * Allocate data structures we need. We parse the userspace name into @@ -572,7 +561,7 @@ pshm_truncate( user_map = current_map(); - if (fp->f_type != DTYPE_PSXSHM) { + if (FILEGLOB_DTYPE(fp->fp_glob) != DTYPE_PSXSHM) { return EINVAL; } @@ -745,7 +734,7 @@ pshm_stat(pshmnode_t *pnode, void *ub, int isstat64) static int pshm_access(pshm_info_t *pinfo, int mode, kauth_cred_t cred, __unused proc_t p) { - int mode_req = ((mode & FREAD) ? S_IRUSR : 0) | + mode_t mode_req = ((mode & FREAD) ? S_IRUSR : 0) | ((mode & FWRITE) ? S_IWUSR : 0); /* Otherwise, user id 0 always gets access. */ @@ -908,7 +897,7 @@ pshm_mmap( if (file_pos >= map_pos + pshmobj->pshmo_size) { continue; } - map_size = pshmobj->pshmo_size - (file_pos - map_pos); + map_size = (vm_map_size_t)(pshmobj->pshmo_size - (file_pos - map_pos)); if (map_size > user_size) { map_size = user_size; } @@ -955,7 +944,7 @@ out_deref: switch (kret) { case KERN_SUCCESS: - *retval = (user_start_addr + pageoff); + *retval = (user_addr_t)(user_start_addr + pageoff); return 0; case KERN_INVALID_ADDRESS: case KERN_NO_SPACE: @@ -1128,43 +1117,6 @@ pshm_closefile(struct fileglob *fg, __unused vfs_context_t ctx) return error; } -static int -pshm_read(__unused struct fileproc *fp, __unused struct uio *uio, - __unused int flags, __unused vfs_context_t ctx) -{ - return ENOTSUP; -} - -static int -pshm_write(__unused struct fileproc *fp, __unused struct uio *uio, - __unused int flags, __unused vfs_context_t ctx) -{ - return ENOTSUP; -} - -static int -pshm_ioctl(__unused struct fileproc *fp, __unused u_long com, - __unused caddr_t data, __unused vfs_context_t ctx) -{ - return ENOTSUP; -} - -static int -pshm_select(__unused struct fileproc *fp, __unused int which, __unused void *wql, - __unused vfs_context_t ctx) -{ - return ENOTSUP; -} - -static int -pshm_kqfilter(__unused struct fileproc *fp, struct knote *kn, - __unused struct kevent_internal_s *kev, __unused vfs_context_t ctx) -{ - kn->kn_flags = EV_ERROR; - kn->kn_data = ENOTSUP; - return 0; -} - int fill_pshminfo(pshmnode_t * pshm, struct pshm_info * info) {