| @@ -1,41 +1,41 @@ | | | @@ -1,41 +1,41 @@ |
1 | /* $NetBSD: filemon.c,v 1.23 2016/01/05 09:37:11 pgoyette Exp $ */ | | 1 | /* $NetBSD: filemon.c,v 1.24 2016/01/05 22:08:54 pgoyette Exp $ */ |
2 | /* | | 2 | /* |
3 | * Copyright (c) 2010, Juniper Networks, Inc. | | 3 | * Copyright (c) 2010, Juniper Networks, Inc. |
4 | * | | 4 | * |
5 | * Redistribution and use in source and binary forms, with or without | | 5 | * Redistribution and use in source and binary forms, with or without |
6 | * modification, are permitted provided that the following conditions | | 6 | * modification, are permitted provided that the following conditions |
7 | * are met: | | 7 | * are met: |
8 | * 1. Redistributions of source code must retain the above copyright | | 8 | * 1. Redistributions of source code must retain the above copyright |
9 | * notice, this list of conditions and the following disclaimer. | | 9 | * notice, this list of conditions and the following disclaimer. |
10 | * 2. Redistributions in binary form must reproduce the above copyright | | 10 | * 2. Redistributions in binary form must reproduce the above copyright |
11 | * notice, this list of conditions and the following disclaimer in the | | 11 | * notice, this list of conditions and the following disclaimer in the |
12 | * documentation and/or other materials provided with the distribution. | | 12 | * documentation and/or other materials provided with the distribution. |
13 | * | | 13 | * |
14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | | 14 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | | 15 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
16 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | | 16 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
17 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | | 17 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
18 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | | 18 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
19 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | | 19 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
20 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | | 20 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | | 21 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | | 22 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | | 23 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | | 24 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
25 | */ | | 25 | */ |
26 | | | 26 | |
27 | #include <sys/cdefs.h> | | 27 | #include <sys/cdefs.h> |
28 | __KERNEL_RCSID(0, "$NetBSD: filemon.c,v 1.23 2016/01/05 09:37:11 pgoyette Exp $"); | | 28 | __KERNEL_RCSID(0, "$NetBSD: filemon.c,v 1.24 2016/01/05 22:08:54 pgoyette Exp $"); |
29 | | | 29 | |
30 | #include <sys/param.h> | | 30 | #include <sys/param.h> |
31 | #include <sys/kernel.h> | | 31 | #include <sys/kernel.h> |
32 | #include <sys/module.h> | | 32 | #include <sys/module.h> |
33 | #include <sys/conf.h> | | 33 | #include <sys/conf.h> |
34 | #include <sys/file.h> | | 34 | #include <sys/file.h> |
35 | #include <sys/filedesc.h> | | 35 | #include <sys/filedesc.h> |
36 | #include <sys/systm.h> | | 36 | #include <sys/systm.h> |
37 | #include <sys/buf.h> | | 37 | #include <sys/buf.h> |
38 | #include <sys/fcntl.h> | | 38 | #include <sys/fcntl.h> |
39 | #include <sys/rwlock.h> | | 39 | #include <sys/rwlock.h> |
40 | #include <sys/condvar.h> | | 40 | #include <sys/condvar.h> |
41 | #include <sys/lwp.h> | | 41 | #include <sys/lwp.h> |
| @@ -132,26 +132,27 @@ filemon_printf(struct filemon *filemon, | | | @@ -132,26 +132,27 @@ filemon_printf(struct filemon *filemon, |
132 | | | 132 | |
133 | va_start(ap, fmt); | | 133 | va_start(ap, fmt); |
134 | len = vsnprintf(filemon->fm_msgbufr, sizeof(filemon->fm_msgbufr), | | 134 | len = vsnprintf(filemon->fm_msgbufr, sizeof(filemon->fm_msgbufr), |
135 | fmt, ap); | | 135 | fmt, ap); |
136 | va_end(ap); | | 136 | va_end(ap); |
137 | if (len > sizeof(filemon->fm_msgbufr)) | | 137 | if (len > sizeof(filemon->fm_msgbufr)) |
138 | len = sizeof(filemon->fm_msgbufr); | | 138 | len = sizeof(filemon->fm_msgbufr); |
139 | filemon_output(filemon, filemon->fm_msgbufr, len); | | 139 | filemon_output(filemon, filemon->fm_msgbufr, len); |
140 | } | | 140 | } |
141 | | | 141 | |
142 | static void | | 142 | static void |
143 | filemon_comment(struct filemon * filemon) | | 143 | filemon_comment(struct filemon * filemon) |
144 | { | | 144 | { |
| | | 145 | |
145 | filemon_printf(filemon, "# filemon version %d\n# Target pid %d\nV %d\n", | | 146 | filemon_printf(filemon, "# filemon version %d\n# Target pid %d\nV %d\n", |
146 | FILEMON_VERSION, curproc->p_pid, FILEMON_VERSION); | | 147 | FILEMON_VERSION, curproc->p_pid, FILEMON_VERSION); |
147 | } | | 148 | } |
148 | | | 149 | |
149 | | | 150 | |
150 | static struct filemon * | | 151 | static struct filemon * |
151 | filemon_pid_check(struct proc * p) | | 152 | filemon_pid_check(struct proc * p) |
152 | { | | 153 | { |
153 | struct filemon *filemon; | | 154 | struct filemon *filemon; |
154 | struct proc * lp; | | 155 | struct proc * lp; |
155 | | | 156 | |
156 | if (!TAILQ_EMPTY(&filemons_inuse)) { | | 157 | if (!TAILQ_EMPTY(&filemons_inuse)) { |
157 | while (p) { | | 158 | while (p) { |