uipc_mqueue.c (289b2d6a79801f44adc787728cfc8219d39ec076) | uipc_mqueue.c (e30621d58fa10d82f3d4a89bb6b5572e2517b024) |
---|---|
1/*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2005 David Xu <davidxu@freebsd.org> 5 * Copyright (c) 2016-2017 Robert N. M. Watson 6 * All rights reserved. 7 * 8 * Portions of this software were developed by BAE Systems, the University of --- 2261 unchanged lines hidden (view full) --- 2270 if (error == 0 && uap->oattr != NULL) { 2271 bzero(oattr.__reserved, sizeof(oattr.__reserved)); 2272 error = copyout(&oattr, uap->oattr, sizeof(oattr)); 2273 } 2274 return (error); 2275} 2276 2277int | 1/*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2005 David Xu <davidxu@freebsd.org> 5 * Copyright (c) 2016-2017 Robert N. M. Watson 6 * All rights reserved. 7 * 8 * Portions of this software were developed by BAE Systems, the University of --- 2261 unchanged lines hidden (view full) --- 2270 if (error == 0 && uap->oattr != NULL) { 2271 bzero(oattr.__reserved, sizeof(oattr.__reserved)); 2272 error = copyout(&oattr, uap->oattr, sizeof(oattr)); 2273 } 2274 return (error); 2275} 2276 2277int |
2278sys_kmq_timedreceive(struct thread *td, struct kmq_timedreceive_args *uap) | 2278kern_kmq_timedreceive(struct thread *td, int mqd, char *msg_ptr, 2279 size_t msg_len, unsigned int *msg_prio, const struct timespec *abs_timeout) |
2279{ 2280 struct mqueue *mq; 2281 struct file *fp; | 2280{ 2281 struct mqueue *mq; 2282 struct file *fp; |
2283 int error, waitok; 2284 2285 AUDIT_ARG_FD(mqd); 2286 error = getmq_read(td, mqd, &fp, NULL, &mq); 2287 if (error != 0) 2288 return (error); 2289 waitok = (fp->f_flag & O_NONBLOCK) == 0; 2290 error = mqueue_receive(mq, msg_ptr, msg_len, msg_prio, waitok, 2291 abs_timeout); 2292 fdrop(fp, td); 2293 return (error); 2294} 2295 2296int 2297sys_kmq_timedreceive(struct thread *td, struct kmq_timedreceive_args *uap) 2298{ |
|
2282 struct timespec *abs_timeout, ets; 2283 int error; | 2299 struct timespec *abs_timeout, ets; 2300 int error; |
2284 int waitok; | |
2285 | 2301 |
2286 AUDIT_ARG_FD(uap->mqd); 2287 error = getmq_read(td, uap->mqd, &fp, NULL, &mq); 2288 if (error) 2289 return (error); | |
2290 if (uap->abs_timeout != NULL) { 2291 error = copyin(uap->abs_timeout, &ets, sizeof(ets)); 2292 if (error != 0) | 2302 if (uap->abs_timeout != NULL) { 2303 error = copyin(uap->abs_timeout, &ets, sizeof(ets)); 2304 if (error != 0) |
2293 goto out; | 2305 return (error); |
2294 abs_timeout = &ets; 2295 } else 2296 abs_timeout = NULL; | 2306 abs_timeout = &ets; 2307 } else 2308 abs_timeout = NULL; |
2297 waitok = !(fp->f_flag & O_NONBLOCK); 2298 error = mqueue_receive(mq, uap->msg_ptr, uap->msg_len, 2299 uap->msg_prio, waitok, abs_timeout); 2300out: 2301 fdrop(fp, td); 2302 return (error); | 2309 2310 return (kern_kmq_timedreceive(td, uap->mqd, uap->msg_ptr, uap->msg_len, 2311 uap->msg_prio, abs_timeout)); |
2303} 2304 2305int | 2312} 2313 2314int |
2306sys_kmq_timedsend(struct thread *td, struct kmq_timedsend_args *uap) | 2315kern_kmq_timedsend(struct thread *td, int mqd, const char *msg_ptr, 2316 size_t msg_len, unsigned int msg_prio, const struct timespec *abs_timeout) |
2307{ 2308 struct mqueue *mq; 2309 struct file *fp; | 2317{ 2318 struct mqueue *mq; 2319 struct file *fp; |
2310 struct timespec *abs_timeout, ets; | |
2311 int error, waitok; 2312 | 2320 int error, waitok; 2321 |
2313 AUDIT_ARG_FD(uap->mqd); 2314 error = getmq_write(td, uap->mqd, &fp, NULL, &mq); 2315 if (error) | 2322 AUDIT_ARG_FD(mqd); 2323 error = getmq_write(td, mqd, &fp, NULL, &mq); 2324 if (error != 0) |
2316 return (error); | 2325 return (error); |
2326 waitok = (fp->f_flag & O_NONBLOCK) == 0; 2327 error = mqueue_send(mq, msg_ptr, msg_len, msg_prio, waitok, 2328 abs_timeout); 2329 fdrop(fp, td); 2330 return (error); 2331} 2332 2333int 2334sys_kmq_timedsend(struct thread *td, struct kmq_timedsend_args *uap) 2335{ 2336 struct timespec *abs_timeout, ets; 2337 int error; 2338 |
|
2317 if (uap->abs_timeout != NULL) { 2318 error = copyin(uap->abs_timeout, &ets, sizeof(ets)); 2319 if (error != 0) | 2339 if (uap->abs_timeout != NULL) { 2340 error = copyin(uap->abs_timeout, &ets, sizeof(ets)); 2341 if (error != 0) |
2320 goto out; | 2342 return (error); |
2321 abs_timeout = &ets; 2322 } else 2323 abs_timeout = NULL; | 2343 abs_timeout = &ets; 2344 } else 2345 abs_timeout = NULL; |
2324 waitok = !(fp->f_flag & O_NONBLOCK); 2325 error = mqueue_send(mq, uap->msg_ptr, uap->msg_len, 2326 uap->msg_prio, waitok, abs_timeout); 2327out: 2328 fdrop(fp, td); 2329 return (error); | 2346 2347 return (kern_kmq_timedsend(td, uap->mqd, uap->msg_ptr, uap->msg_len, 2348 uap->msg_prio, abs_timeout)); |
2330} 2331 2332int 2333kern_kmq_notify(struct thread *td, int mqd, struct sigevent *sigev) 2334{ 2335 struct filedesc *fdp; 2336 struct proc *p; 2337 struct mqueue *mq; --- 458 unchanged lines hidden (view full) --- 2796 } 2797 return (error); 2798} 2799 2800int 2801freebsd32_kmq_timedsend(struct thread *td, 2802 struct freebsd32_kmq_timedsend_args *uap) 2803{ | 2349} 2350 2351int 2352kern_kmq_notify(struct thread *td, int mqd, struct sigevent *sigev) 2353{ 2354 struct filedesc *fdp; 2355 struct proc *p; 2356 struct mqueue *mq; --- 458 unchanged lines hidden (view full) --- 2815 } 2816 return (error); 2817} 2818 2819int 2820freebsd32_kmq_timedsend(struct thread *td, 2821 struct freebsd32_kmq_timedsend_args *uap) 2822{ |
2804 struct mqueue *mq; 2805 struct file *fp; | |
2806 struct timespec32 ets32; 2807 struct timespec *abs_timeout, ets; 2808 int error; | 2823 struct timespec32 ets32; 2824 struct timespec *abs_timeout, ets; 2825 int error; |
2809 int waitok; | |
2810 | 2826 |
2811 AUDIT_ARG_FD(uap->mqd); 2812 error = getmq_write(td, uap->mqd, &fp, NULL, &mq); 2813 if (error) 2814 return (error); | |
2815 if (uap->abs_timeout != NULL) { 2816 error = copyin(uap->abs_timeout, &ets32, sizeof(ets32)); 2817 if (error != 0) | 2827 if (uap->abs_timeout != NULL) { 2828 error = copyin(uap->abs_timeout, &ets32, sizeof(ets32)); 2829 if (error != 0) |
2818 goto out; | 2830 return (error); |
2819 CP(ets32, ets, tv_sec); 2820 CP(ets32, ets, tv_nsec); 2821 abs_timeout = &ets; 2822 } else 2823 abs_timeout = NULL; | 2831 CP(ets32, ets, tv_sec); 2832 CP(ets32, ets, tv_nsec); 2833 abs_timeout = &ets; 2834 } else 2835 abs_timeout = NULL; |
2824 waitok = !(fp->f_flag & O_NONBLOCK); 2825 error = mqueue_send(mq, uap->msg_ptr, uap->msg_len, 2826 uap->msg_prio, waitok, abs_timeout); 2827out: 2828 fdrop(fp, td); 2829 return (error); | 2836 2837 return (kern_kmq_timedsend(td, uap->mqd, uap->msg_ptr, uap->msg_len, 2838 uap->msg_prio, abs_timeout)); |
2830} 2831 2832int 2833freebsd32_kmq_timedreceive(struct thread *td, 2834 struct freebsd32_kmq_timedreceive_args *uap) 2835{ | 2839} 2840 2841int 2842freebsd32_kmq_timedreceive(struct thread *td, 2843 struct freebsd32_kmq_timedreceive_args *uap) 2844{ |
2836 struct mqueue *mq; 2837 struct file *fp; | |
2838 struct timespec32 ets32; 2839 struct timespec *abs_timeout, ets; | 2845 struct timespec32 ets32; 2846 struct timespec *abs_timeout, ets; |
2840 int error, waitok; | 2847 int error; |
2841 | 2848 |
2842 AUDIT_ARG_FD(uap->mqd); 2843 error = getmq_read(td, uap->mqd, &fp, NULL, &mq); 2844 if (error) 2845 return (error); | |
2846 if (uap->abs_timeout != NULL) { 2847 error = copyin(uap->abs_timeout, &ets32, sizeof(ets32)); 2848 if (error != 0) | 2849 if (uap->abs_timeout != NULL) { 2850 error = copyin(uap->abs_timeout, &ets32, sizeof(ets32)); 2851 if (error != 0) |
2849 goto out; | 2852 return (error); |
2850 CP(ets32, ets, tv_sec); 2851 CP(ets32, ets, tv_nsec); 2852 abs_timeout = &ets; 2853 } else 2854 abs_timeout = NULL; | 2853 CP(ets32, ets, tv_sec); 2854 CP(ets32, ets, tv_nsec); 2855 abs_timeout = &ets; 2856 } else 2857 abs_timeout = NULL; |
2855 waitok = !(fp->f_flag & O_NONBLOCK); 2856 error = mqueue_receive(mq, uap->msg_ptr, uap->msg_len, 2857 uap->msg_prio, waitok, abs_timeout); 2858out: 2859 fdrop(fp, td); 2860 return (error); | 2858 2859 return (kern_kmq_timedreceive(td, uap->mqd, uap->msg_ptr, uap->msg_len, 2860 uap->msg_prio, abs_timeout)); |
2861} 2862 2863int 2864freebsd32_kmq_notify(struct thread *td, struct freebsd32_kmq_notify_args *uap) 2865{ 2866 struct sigevent ev, *evp; 2867 struct sigevent32 ev32; 2868 int error; --- 84 unchanged lines hidden --- | 2861} 2862 2863int 2864freebsd32_kmq_notify(struct thread *td, struct freebsd32_kmq_notify_args *uap) 2865{ 2866 struct sigevent ev, *evp; 2867 struct sigevent32 ev32; 2868 int error; --- 84 unchanged lines hidden --- |