From f13ddbc86500ce893f62460b62d775089a14aba0 Mon Sep 17 00:00:00 2001 From: sef Date: Sat, 13 Dec 1997 03:13:49 +0000 Subject: Change the ioctls for procfs around a bit; in particular, whever possible, change from ioctl(fd, PIOC, &i); to ioctl(fd, PIOC, i); This is going from the _IOW to _IO ioctl macro. The kernel, procctl, and truss must be in synch for it all to work (not doing so will get errors about inappropriate ioctl's, fortunately). Hopefully I didn't forget anything :). --- usr.bin/truss/main.c | 4 ++-- usr.bin/truss/setup.c | 22 +++++++++------------- 2 files changed, 11 insertions(+), 15 deletions(-) (limited to 'usr.bin/truss') diff --git a/usr.bin/truss/main.c b/usr.bin/truss/main.c index 838237a..9f9b4f7 100644 --- a/usr.bin/truss/main.c +++ b/usr.bin/truss/main.c @@ -4,7 +4,7 @@ * do a lot of the work :). */ /* - * $Id: main.c,v 1.3 1997/12/06 14:41:41 peter Exp $ + * $Id: main.c,v 1.4 1997/12/06 17:13:54 sef Exp $ */ #include @@ -196,7 +196,7 @@ main(int ac, char **av) { break; } } - if (ioctl(Procfd, PIOCCONT, &val) == -1) + if (ioctl(Procfd, PIOCCONT, val) == -1) perror("PIOCCONT"); } while (pfs.why != S_EXIT); return 0; diff --git a/usr.bin/truss/setup.c b/usr.bin/truss/setup.c index 6cc1164..eb1ed46 100644 --- a/usr.bin/truss/setup.c +++ b/usr.bin/truss/setup.c @@ -3,7 +3,7 @@ * I'm afraid. */ /* - * $Id: setup.c,v 1.3 1997/12/06 14:42:58 peter Exp $ + * $Id: setup.c,v 1.4 1997/12/07 04:08:48 sef Exp $ */ #include @@ -47,7 +47,7 @@ setup_and_wait(char *command[]) { if (fd == -1) err(2, "cannot open /proc/curproc/mem"); fcntl(fd, F_SETFD, 1); - if (ioctl(fd, PIOCBIS, &mask) == -1) + if (ioctl(fd, PIOCBIS, mask) == -1) err(3, "PIOCBIS"); flags = PF_LINGER; /* @@ -55,11 +55,11 @@ setup_and_wait(char *command[]) { * process on last close; normally, this is the behaviour * we want. */ - if (ioctl(fd, PIOCSFL, &flags) == -1) + if (ioctl(fd, PIOCSFL, flags) == -1) perror("cannot set PF_LINGER"); execvp(command[0], command); mask = ~0; - ioctl(fd, PIOCBIC, &mask); + ioctl(fd, PIOCBIC, ~0); err(4, "execvp %s", command[0]); } /* Only in the parent here */ @@ -78,9 +78,8 @@ setup_and_wait(char *command[]) { if (ioctl(fd, PIOCWAIT, &pfs) == -1) err(6, "PIOCWAIT"); if (pfs.why == S_EXIT) { - int zero = 0; fprintf(stderr, "process exited before exec'ing\n"); - ioctl(fd, PIOCCONT, &zero); + ioctl(fd, PIOCCONT, 0); wait(0); exit(7); } @@ -110,7 +109,7 @@ start_tracing(int pid, int flags) { } evflags = tmp.events; - if (ioctl(fd, PIOCBIS, &flags) == -1) + if (ioctl(fd, PIOCBIS, flags) == -1) err(9, "cannot set procfs event bit mask"); /* @@ -119,8 +118,7 @@ start_tracing(int pid, int flags) { * needs to be woken up via procctl. */ - flags = 0; - if (ioctl(fd, PIOCSFL, &flags) == -1) + if (ioctl(fd, PIOCSFL, 0) == -1) perror("cannot clear PF_LINGER"); return fd; @@ -135,11 +133,9 @@ start_tracing(int pid, int flags) { void restore_proc(int signo) { extern int Procfd; - int i; - i = ~0; - ioctl(Procfd, PIOCBIC, &i); + ioctl(Procfd, PIOCBIC, ~0); if (evflags) - ioctl(Procfd, PIOCBIS, &evflags); + ioctl(Procfd, PIOCBIS, evflags); exit(0); } -- cgit v1.1