kern_descrip.c (118094) | kern_descrip.c (118126) |
---|---|
1/* 2 * Copyright (c) 1982, 1986, 1989, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 25 unchanged lines hidden (view full) --- 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)kern_descrip.c 8.6 (Berkeley) 4/19/94 39 */ 40 41#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 1982, 1986, 1989, 1991, 1993 3 * The Regents of the University of California. All rights reserved. 4 * (c) UNIX System Laboratories, Inc. 5 * All or some portions of this file are derived from material licensed 6 * to the University of California by American Telephone and Telegraph 7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with 8 * the permission of UNIX System Laboratories, Inc. --- 25 unchanged lines hidden (view full) --- 34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 35 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 36 * SUCH DAMAGE. 37 * 38 * @(#)kern_descrip.c 8.6 (Berkeley) 4/19/94 39 */ 40 41#include <sys/cdefs.h> |
42__FBSDID("$FreeBSD: head/sys/kern/kern_descrip.c 118094 2003-07-27 17:04:56Z phk $"); | 42__FBSDID("$FreeBSD: head/sys/kern/kern_descrip.c 118126 2003-07-28 16:03:53Z rwatson $"); |
43 44#include "opt_compat.h" 45 46#include <sys/param.h> 47#include <sys/systm.h> 48#include <sys/syscallsubr.h> 49#include <sys/sysproto.h> 50#include <sys/conf.h> --- 2217 unchanged lines hidden (view full) --- 2268sysctl_kern_file(SYSCTL_HANDLER_ARGS) 2269{ 2270 struct xfile xf; 2271 struct filedesc *fdp; 2272 struct file *fp; 2273 struct proc *p; 2274 int error, n; 2275 | 43 44#include "opt_compat.h" 45 46#include <sys/param.h> 47#include <sys/systm.h> 48#include <sys/syscallsubr.h> 49#include <sys/sysproto.h> 50#include <sys/conf.h> --- 2217 unchanged lines hidden (view full) --- 2268sysctl_kern_file(SYSCTL_HANDLER_ARGS) 2269{ 2270 struct xfile xf; 2271 struct filedesc *fdp; 2272 struct file *fp; 2273 struct proc *p; 2274 int error, n; 2275 |
2276 /* 2277 * Note: because the number of file descriptors is calculated 2278 * in different ways for sizing vs returning the data, 2279 * there is information leakage from the first loop. However, 2280 * it is of a similar order of magnitude to the leakage from 2281 * global system statistics such as kern.openfiles. 2282 */ |
|
2276 sysctl_wire_old_buffer(req, 0); 2277 if (req->oldptr == NULL) { 2278 n = 16; /* A slight overestimate. */ 2279 sx_slock(&filelist_lock); 2280 LIST_FOREACH(fp, &filehead, f_list) { 2281 /* 2282 * We should grab the lock, but this is an 2283 * estimate, so does it really matter? --- 6 unchanged lines hidden (view full) --- 2290 return (SYSCTL_OUT(req, 0, n * sizeof(xf))); 2291 } 2292 error = 0; 2293 bzero(&xf, sizeof(xf)); 2294 xf.xf_size = sizeof(xf); 2295 sx_slock(&allproc_lock); 2296 LIST_FOREACH(p, &allproc, p_list) { 2297 PROC_LOCK(p); | 2283 sysctl_wire_old_buffer(req, 0); 2284 if (req->oldptr == NULL) { 2285 n = 16; /* A slight overestimate. */ 2286 sx_slock(&filelist_lock); 2287 LIST_FOREACH(fp, &filehead, f_list) { 2288 /* 2289 * We should grab the lock, but this is an 2290 * estimate, so does it really matter? --- 6 unchanged lines hidden (view full) --- 2297 return (SYSCTL_OUT(req, 0, n * sizeof(xf))); 2298 } 2299 error = 0; 2300 bzero(&xf, sizeof(xf)); 2301 xf.xf_size = sizeof(xf); 2302 sx_slock(&allproc_lock); 2303 LIST_FOREACH(p, &allproc, p_list) { 2304 PROC_LOCK(p); |
2305 if (p_cansee(req->td, p) != 0) { 2306 PROC_UNLOCK(p); 2307 continue; 2308 } |
|
2298 xf.xf_pid = p->p_pid; 2299 xf.xf_uid = p->p_ucred->cr_uid; 2300 PROC_UNLOCK(p); 2301 mtx_lock(&fdesc_mtx); 2302 if ((fdp = p->p_fd) == NULL) { 2303 mtx_unlock(&fdesc_mtx); 2304 continue; 2305 } --- 148 unchanged lines hidden --- | 2309 xf.xf_pid = p->p_pid; 2310 xf.xf_uid = p->p_ucred->cr_uid; 2311 PROC_UNLOCK(p); 2312 mtx_lock(&fdesc_mtx); 2313 if ((fdp = p->p_fd) == NULL) { 2314 mtx_unlock(&fdesc_mtx); 2315 continue; 2316 } --- 148 unchanged lines hidden --- |