Deleted Added
full compact
kern_event.c (62218) kern_event.c (63452)
1/*-
2 * Copyright (c) 1999,2000 Jonathan Lemon <jlemon@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
1/*-
2 * Copyright (c) 1999,2000 Jonathan Lemon <jlemon@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 9 unchanged lines hidden (view full) ---

18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 *
26 * $FreeBSD: head/sys/kern/kern_event.c 62218 2000-06-28 19:16:27Z chris $
26 * $FreeBSD: head/sys/kern/kern_event.c 63452 2000-07-18 19:31:52Z jlemon $
27 */
28
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <sys/kernel.h>
32#include <sys/proc.h>
33#include <sys/malloc.h>
34#include <sys/unistd.h>

--- 279 unchanged lines hidden (view full) ---

314 fdp->fd_knlistsize = 0; /* mark this fdesc as having a kq */
315 kq->kq_fdp = fdp;
316 return (error);
317}
318
319#ifndef _SYS_SYSPROTO_H_
320struct kevent_args {
321 int fd;
27 */
28
29#include <sys/param.h>
30#include <sys/systm.h>
31#include <sys/kernel.h>
32#include <sys/proc.h>
33#include <sys/malloc.h>
34#include <sys/unistd.h>

--- 279 unchanged lines hidden (view full) ---

314 fdp->fd_knlistsize = 0; /* mark this fdesc as having a kq */
315 kq->kq_fdp = fdp;
316 return (error);
317}
318
319#ifndef _SYS_SYSPROTO_H_
320struct kevent_args {
321 int fd;
322 struct kevent *changelist;
322 int nchanges;
323 int nchanges;
323 struct kevent **changelist;
324 int nevents;
325 struct kevent *eventlist;
324 struct kevent *eventlist;
325 int nevents;
326 struct timespec *timeout;
327};
328#endif
329int
330kevent(struct proc *p, struct kevent_args *uap)
331{
326 struct timespec *timeout;
327};
328#endif
329int
330kevent(struct proc *p, struct kevent_args *uap)
331{
332 struct filedesc* fdp = p->p_fd;
333 struct kevent kev;
332 struct filedesc* fdp = p->p_fd;
333 struct kevent *kevp;
334 struct kqueue *kq;
334 struct kqueue *kq;
335 struct file *fp;
335 struct file *fp;
336 struct timespec ts;
337 int i, n, nerrors, error;
338
339 if (((u_int)uap->fd) >= fdp->fd_nfiles ||
340 (fp = fdp->fd_ofiles[uap->fd]) == NULL ||
341 (fp->f_type != DTYPE_KQUEUE))
342 return (EBADF);
343
344 if (uap->timeout != NULL) {
336 struct timespec ts;
337 int i, n, nerrors, error;
338
339 if (((u_int)uap->fd) >= fdp->fd_nfiles ||
340 (fp = fdp->fd_ofiles[uap->fd]) == NULL ||
341 (fp->f_type != DTYPE_KQUEUE))
342 return (EBADF);
343
344 if (uap->timeout != NULL) {
345 error = copyin((caddr_t)uap->timeout, (caddr_t)&ts,
346 sizeof(ts));
345 error = copyin(uap->timeout, &ts, sizeof(ts));
347 if (error)
348 return error;
349 uap->timeout = &ts;
350 }
351
352 kq = (struct kqueue *)fp->f_data;
353 nerrors = 0;
354
355 while (uap->nchanges > 0) {
356 n = uap->nchanges > KQ_NEVENTS ? KQ_NEVENTS : uap->nchanges;
346 if (error)
347 return error;
348 uap->timeout = &ts;
349 }
350
351 kq = (struct kqueue *)fp->f_data;
352 nerrors = 0;
353
354 while (uap->nchanges > 0) {
355 n = uap->nchanges > KQ_NEVENTS ? KQ_NEVENTS : uap->nchanges;
357 error = copyin((caddr_t)uap->changelist, (caddr_t)kq->kq_kevp,
358 n * sizeof(struct kevent *));
356 error = copyin(uap->changelist, kq->kq_kev,
357 n * sizeof(struct kevent));
359 if (error)
360 return (error);
361 for (i = 0; i < n; i++) {
358 if (error)
359 return (error);
360 for (i = 0; i < n; i++) {
362 error = copyin((caddr_t)kq->kq_kevp[i],
363 (caddr_t)&kev, sizeof(kev));
364 if (error)
365 return (error);
366 kev.flags &= ~EV_SYSFLAGS;
367 error = kqueue_register(kq, &kev, p);
361 kevp = &kq->kq_kev[i];
362 kevp->flags &= ~EV_SYSFLAGS;
363 error = kqueue_register(kq, kevp, p);
368 if (error) {
369 if (uap->nevents != 0) {
364 if (error) {
365 if (uap->nevents != 0) {
370 kev.flags = EV_ERROR;
371 kev.data = error;
372 (void) copyout((caddr_t)&kev,
366 kevp->flags = EV_ERROR;
367 kevp->data = error;
368 (void) copyout((caddr_t)kevp,
373 (caddr_t)uap->eventlist,
369 (caddr_t)uap->eventlist,
374 sizeof(kev));
370 sizeof(*kevp));
375 uap->eventlist++;
376 uap->nevents--;
377 nerrors++;
378 } else {
379 return (error);
380 }
381 }
382 }

--- 522 unchanged lines hidden ---
371 uap->eventlist++;
372 uap->nevents--;
373 nerrors++;
374 } else {
375 return (error);
376 }
377 }
378 }

--- 522 unchanged lines hidden ---