| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: kern_descrip.c,v 1.247 2020/08/26 22:56:55 christos Exp $ */ | | 1 | /* $NetBSD: kern_descrip.c,v 1.248 2020/08/28 06:47:18 riastradh Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Andrew Doran. | | 8 | * by Andrew Doran. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -60,27 +60,27 @@ | | | @@ -60,27 +60,27 @@ |
60 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 60 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
61 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 61 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
62 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 62 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
63 | * SUCH DAMAGE. | | 63 | * SUCH DAMAGE. |
64 | * | | 64 | * |
65 | * @(#)kern_descrip.c 8.8 (Berkeley) 2/14/95 | | 65 | * @(#)kern_descrip.c 8.8 (Berkeley) 2/14/95 |
66 | */ | | 66 | */ |
67 | | | 67 | |
68 | /* | | 68 | /* |
69 | * File descriptor management. | | 69 | * File descriptor management. |
70 | */ | | 70 | */ |
71 | | | 71 | |
72 | #include <sys/cdefs.h> | | 72 | #include <sys/cdefs.h> |
73 | __KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.247 2020/08/26 22:56:55 christos Exp $"); | | 73 | __KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.248 2020/08/28 06:47:18 riastradh Exp $"); |
74 | | | 74 | |
75 | #include <sys/param.h> | | 75 | #include <sys/param.h> |
76 | #include <sys/systm.h> | | 76 | #include <sys/systm.h> |
77 | #include <sys/filedesc.h> | | 77 | #include <sys/filedesc.h> |
78 | #include <sys/kernel.h> | | 78 | #include <sys/kernel.h> |
79 | #include <sys/proc.h> | | 79 | #include <sys/proc.h> |
80 | #include <sys/file.h> | | 80 | #include <sys/file.h> |
81 | #include <sys/socket.h> | | 81 | #include <sys/socket.h> |
82 | #include <sys/socketvar.h> | | 82 | #include <sys/socketvar.h> |
83 | #include <sys/stat.h> | | 83 | #include <sys/stat.h> |
84 | #include <sys/ioctl.h> | | 84 | #include <sys/ioctl.h> |
85 | #include <sys/fcntl.h> | | 85 | #include <sys/fcntl.h> |
86 | #include <sys/pool.h> | | 86 | #include <sys/pool.h> |
| @@ -2299,27 +2299,27 @@ sysctl_kern_file2(SYSCTLFN_ARGS) | | | @@ -2299,27 +2299,27 @@ sysctl_kern_file2(SYSCTLFN_ARGS) |
2299 | | | 2299 | |
2300 | static void | | 2300 | static void |
2301 | fill_file(struct file *fp, const struct file *fpsrc) | | 2301 | fill_file(struct file *fp, const struct file *fpsrc) |
2302 | { | | 2302 | { |
2303 | const bool allowaddr = get_expose_address(curproc); | | 2303 | const bool allowaddr = get_expose_address(curproc); |
2304 | | | 2304 | |
2305 | memset(fp, 0, sizeof(*fp)); | | 2305 | memset(fp, 0, sizeof(*fp)); |
2306 | | | 2306 | |
2307 | fp->f_offset = fpsrc->f_offset; | | 2307 | fp->f_offset = fpsrc->f_offset; |
2308 | COND_SET_PTR(fp->f_cred, fpsrc->f_cred, allowaddr); | | 2308 | COND_SET_PTR(fp->f_cred, fpsrc->f_cred, allowaddr); |
2309 | COND_SET_CPTR(fp->f_ops, fpsrc->f_ops, allowaddr); | | 2309 | COND_SET_CPTR(fp->f_ops, fpsrc->f_ops, allowaddr); |
2310 | COND_SET_STRUCT(fp->f_undata, fpsrc->f_undata, allowaddr); | | 2310 | COND_SET_STRUCT(fp->f_undata, fpsrc->f_undata, allowaddr); |
2311 | COND_SET_STRUCT(fp->f_list, fpsrc->f_list, allowaddr); | | 2311 | COND_SET_STRUCT(fp->f_list, fpsrc->f_list, allowaddr); |
2312 | COND_SET_STRUCT(fp->f_lock, fpsrc->f_lock, allowaddr); | | 2312 | memset(&fp->f_lock, 0, sizeof(fp->f_lock)); |
2313 | fp->f_flag = fpsrc->f_flag; | | 2313 | fp->f_flag = fpsrc->f_flag; |
2314 | fp->f_marker = fpsrc->f_marker; | | 2314 | fp->f_marker = fpsrc->f_marker; |
2315 | fp->f_type = fpsrc->f_type; | | 2315 | fp->f_type = fpsrc->f_type; |
2316 | fp->f_advice = fpsrc->f_advice; | | 2316 | fp->f_advice = fpsrc->f_advice; |
2317 | fp->f_count = fpsrc->f_count; | | 2317 | fp->f_count = fpsrc->f_count; |
2318 | fp->f_msgcount = fpsrc->f_msgcount; | | 2318 | fp->f_msgcount = fpsrc->f_msgcount; |
2319 | fp->f_unpcount = fpsrc->f_unpcount; | | 2319 | fp->f_unpcount = fpsrc->f_unpcount; |
2320 | COND_SET_STRUCT(fp->f_unplist, fpsrc->f_unplist, allowaddr); | | 2320 | COND_SET_STRUCT(fp->f_unplist, fpsrc->f_unplist, allowaddr); |
2321 | } | | 2321 | } |
2322 | | | 2322 | |
2323 | static void | | 2323 | static void |
2324 | fill_file2(struct kinfo_file *kp, const file_t *fp, const fdfile_t *ff, | | 2324 | fill_file2(struct kinfo_file *kp, const file_t *fp, const fdfile_t *ff, |
2325 | int i, pid_t pid) | | 2325 | int i, pid_t pid) |