diff options
author | sef <sef@FreeBSD.org> | 1997-12-13 03:13:49 +0000 |
---|---|---|
committer | sef <sef@FreeBSD.org> | 1997-12-13 03:13:49 +0000 |
commit | f13ddbc86500ce893f62460b62d775089a14aba0 (patch) | |
tree | 2ef0d8080b077044d2a0ab73a9b9d1b08d002334 | |
parent | b51dc6a0ad3ce435d5255b72124d2220a345c748 (diff) | |
download | FreeBSD-src-f13ddbc86500ce893f62460b62d775089a14aba0.zip FreeBSD-src-f13ddbc86500ce893f62460b62d775089a14aba0.tar.gz |
Change the ioctls for procfs around a bit; in particular, whever possible,
change from
ioctl(fd, PIOC<foo>, &i);
to
ioctl(fd, PIOC<foo>, 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 :).
-rw-r--r-- | sys/fs/procfs/procfs_vnops.c | 7 | ||||
-rw-r--r-- | sys/miscfs/procfs/procfs_vnops.c | 7 | ||||
-rw-r--r-- | sys/sys/pioctl.h | 13 | ||||
-rw-r--r-- | usr.bin/truss/main.c | 4 | ||||
-rw-r--r-- | usr.bin/truss/setup.c | 22 | ||||
-rw-r--r-- | usr.sbin/procctl/procctl.c | 8 |
6 files changed, 29 insertions, 32 deletions
diff --git a/sys/fs/procfs/procfs_vnops.c b/sys/fs/procfs/procfs_vnops.c index f660f3a..9a40ea3 100644 --- a/sys/fs/procfs/procfs_vnops.c +++ b/sys/fs/procfs/procfs_vnops.c @@ -36,7 +36,7 @@ * * @(#)procfs_vnops.c 8.18 (Berkeley) 5/21/95 * - * $Id: procfs_vnops.c,v 1.46 1997/12/08 22:09:24 sef Exp $ + * $Id: procfs_vnops.c,v 1.47 1997/12/12 03:33:43 sef Exp $ */ /* @@ -243,8 +243,9 @@ procfs_ioctl(ap) break; case PIOCSFL: procp->p_pfsflags = (unsigned char)*(unsigned int*)ap->a_data; - *(unsigned int*)ap->a_data = procp->p_stops; break; + case PIOCGFL: + *(unsigned int*)ap->a_data = (unsigned int)procp->p_pfsflags; case PIOCSTATUS: psp = (struct procfs_status *)ap->a_data; psp->state = (procp->p_step == 0); @@ -273,7 +274,7 @@ procfs_ioctl(ap) case PIOCCONT: /* Restart a proc */ if (procp->p_step == 0) return EINVAL; /* Can only start a stopped process */ - if (ap->a_data && (signo = *(int*)ap->a_data)) { + if (signo = *(int*)ap->a_data) { if (signo >= NSIG || signo <= 0) return EINVAL; psignal(procp, signo); diff --git a/sys/miscfs/procfs/procfs_vnops.c b/sys/miscfs/procfs/procfs_vnops.c index f660f3a..9a40ea3 100644 --- a/sys/miscfs/procfs/procfs_vnops.c +++ b/sys/miscfs/procfs/procfs_vnops.c @@ -36,7 +36,7 @@ * * @(#)procfs_vnops.c 8.18 (Berkeley) 5/21/95 * - * $Id: procfs_vnops.c,v 1.46 1997/12/08 22:09:24 sef Exp $ + * $Id: procfs_vnops.c,v 1.47 1997/12/12 03:33:43 sef Exp $ */ /* @@ -243,8 +243,9 @@ procfs_ioctl(ap) break; case PIOCSFL: procp->p_pfsflags = (unsigned char)*(unsigned int*)ap->a_data; - *(unsigned int*)ap->a_data = procp->p_stops; break; + case PIOCGFL: + *(unsigned int*)ap->a_data = (unsigned int)procp->p_pfsflags; case PIOCSTATUS: psp = (struct procfs_status *)ap->a_data; psp->state = (procp->p_step == 0); @@ -273,7 +274,7 @@ procfs_ioctl(ap) case PIOCCONT: /* Restart a proc */ if (procp->p_step == 0) return EINVAL; /* Can only start a stopped process */ - if (ap->a_data && (signo = *(int*)ap->a_data)) { + if (signo = *(int*)ap->a_data) { if (signo >= NSIG || signo <= 0) return EINVAL; psignal(procp, signo); diff --git a/sys/sys/pioctl.h b/sys/sys/pioctl.h index 8981782..60b6701 100644 --- a/sys/sys/pioctl.h +++ b/sys/sys/pioctl.h @@ -1,7 +1,7 @@ /* * procfs ioctl definitions. * - * $Id: pioctl.h,v 1.2 1997/12/07 03:59:26 sef Exp $ + * $Id: pioctl.h,v 1.3 1997/12/08 22:09:39 sef Exp $ */ #ifndef _SYS_PIOCTL_H @@ -17,14 +17,15 @@ struct procfs_status { unsigned long val; /* Any extra data */ }; -# define PIOCBIS _IOW('p', 1, unsigned int) /* Set event flag */ -# define PIOCBIC _IOW('p', 2, unsigned int) /* Clear event flag */ -# define PIOCSFL _IOW('p', 3, unsigned int) /* Set flags */ +# define PIOCBIS _IO('p', 1) /* Set event flag */ +# define PIOCBIC _IO('p', 2) /* Clear event flag */ +# define PIOCSFL _IO('p', 3) /* Set flags */ /* wait for proc to stop */ # define PIOCWAIT _IOR('p', 4, struct procfs_status) -# define PIOCCONT _IOW('p', 5, int) /* Continue a process */ +# define PIOCCONT _IO('p', 5) /* Continue a process */ /* Get proc status */ -# define PIOCSTATUS _IOW('p', 6, struct procfs_status) +# define PIOCSTATUS _IOR('p', 6, struct procfs_status) +# define PIOCGFL _IOR('p', 7, unsigned int) /* Get flags */ # define S_EXEC 0x00000001 /* stop-on-exec */ # define S_SIG 0x00000002 /* stop-on-signal */ 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 <stdio.h> @@ -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 <stdio.h> @@ -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); } diff --git a/usr.sbin/procctl/procctl.c b/usr.sbin/procctl/procctl.c index 2578c47..ae3894b 100644 --- a/usr.sbin/procctl/procctl.c +++ b/usr.sbin/procctl/procctl.c @@ -7,7 +7,7 @@ * for some annoying circumstances.) */ /* - * $Id$ + * $Id: procctl.c,v 1.1 1997/12/06 04:19:09 sef Exp $ */ #include <stdio.h> @@ -39,13 +39,11 @@ main(int ac, char **av) { av[0], av[i], strerror(errno)); continue; } - mask = ~0; - if (ioctl(fd, PIOCBIC, &mask) == -1) { + if (ioctl(fd, PIOCBIC, ~0) == -1) { fprintf(stderr, "%s: cannot clear process %s's event mask: %s\n", av[0], av[i], strerror(errno)); } - mask = 0; - if (ioctl(fd, PIOCCONT, &mask) == -1 && errno != EINVAL) { + if (ioctl(fd, PIOCCONT, 0) == -1 && errno != EINVAL) { fprintf(stderr, "%s: cannot continue process %s: %s\n", av[0], av[i], strerror(errno)); } |