PERFORCE change 31112 for review

Peter Wemm peter at FreeBSD.org
Tue May 13 19:14:16 PDT 2003


http://perforce.freebsd.org/chv.cgi?CH=31112

Change 31112 by peter at peter_hammer on 2003/05/13 19:13:51

	Oh Joy.  We need to swab the kevent structures too.
	With this, the kernel no longer printf's about unknown filters
	on the console when running the p4 client.

Affected files ...

.. //depot/projects/hammer/sys/amd64/ia32/ia32_misc.c#3 edit
.. //depot/projects/hammer/sys/amd64/ia32/syscalls.master#3 edit

Differences ...

==== //depot/projects/hammer/sys/amd64/ia32/ia32_misc.c#3 (text+ko) ====

@@ -536,6 +536,83 @@
 	return (select(td, (struct select_args *) uap));
 }
 
+struct kevent32 {
+	u_int32_t	ident;		/* identifier for this event */
+	short		filter;		/* filter for event */
+	u_short		flags;
+	u_int		fflags;
+	int32_t		data;
+	u_int32_t	udata;		/* opaque user data identifier */
+};
+
+int
+ia32_kevent(struct thread *td, struct ia32_kevent_args *uap)
+{
+	int error;
+	caddr_t sg;
+	struct timespec32 ts32;
+	struct timespec ts;
+	struct kevent32 ks32;
+	struct kevent *ks;
+	struct kevent_args a;
+	int i;
+
+	sg = stackgap_init();
+
+	a.fd = uap->fd;
+	a.changelist = uap->changelist;
+	a.nchanges = uap->nchanges;
+	a.eventlist = uap->eventlist;
+	a.nevents = uap->nevents;
+	a.timeout = NULL;
+
+	if (uap->timeout) {
+		a.timeout = stackgap_alloc(&sg, sizeof(struct timespec));
+		error = copyin(uap->timeout, &ts32, sizeof(ts32));
+		if (error)
+			return (error);
+		CP(ts32, ts, tv_sec);
+		CP(ts32, ts, tv_nsec);
+		error = copyout(&ts, (void *)(uintptr_t)a.timeout, sizeof(ts));
+		if (error)
+			return (error);
+	}
+	if (uap->changelist) {
+		a.changelist = (struct kevent *)stackgap_alloc(&sg, uap->nchanges * sizeof(struct kevent));
+		for (i = 0; i < uap->nchanges; i++) {
+			error = copyin(&uap->changelist[i], &ks32, sizeof(ks32));
+			if (error)
+				return (error);
+			ks = (struct kevent *)(uintptr_t)&a.changelist[i];
+			CP(ks32, *ks, ident);
+			CP(ks32, *ks, filter);
+			CP(ks32, *ks, flags);
+			CP(ks32, *ks, fflags);
+			CP(ks32, *ks, data);
+			PTRIN_CP(ks32, *ks, udata);
+		}
+	}
+	if (uap->eventlist) {
+		a.eventlist = stackgap_alloc(&sg, uap->nevents * sizeof(struct kevent));
+	}
+	error = kevent(td, &a);
+	if (uap->eventlist && error > 0) {
+		for (i = 0; i < error; i++) {
+			ks = &a.eventlist[i];
+			CP(*ks, ks32, ident);
+			CP(*ks, ks32, filter);
+			CP(*ks, ks32, flags);
+			CP(*ks, ks32, fflags);
+			CP(*ks, ks32, data);
+			PTROUT_CP(*ks, ks32, udata);
+			error = copyout(&ks32, &uap->eventlist[i], sizeof(ks32));
+			if (error)
+				return (error);
+		}
+	}
+	return error;
+}
+
 int
 ia32_gettimeofday(struct thread *td, struct ia32_gettimeofday_args *uap)
 {

==== //depot/projects/hammer/sys/amd64/ia32/syscalls.master#3 (text+ko) ====

@@ -521,7 +521,7 @@
 360	MNOPROTO BSD	{ int getresuid(uid_t *ruid, uid_t *euid, uid_t *suid); }
 361	MNOPROTO BSD	{ int getresgid(gid_t *rgid, gid_t *egid, gid_t *sgid); }
 362	MNOPROTO BSD	{ int kqueue(void); }
-363	MNOPROTO BSD	{ int kevent(int fd, \
+363	MSTD BSD	{ int ia32_kevent(int fd, \
 			    const struct kevent *changelist, int nchanges, \
 			    struct kevent *eventlist, int nevents, \
 			    const struct timespec *timeout); }


More information about the p4-projects mailing list