From 84baf7a20fc203e9a85ebe0d54c0a8be1ab72d6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Wed, 31 Jul 2002 12:16:51 +0000 Subject: [PATCH] Add struct xfile, which will be used instead of struct file for sysctl purposes. Sponsored by: DARPA, NAI Labs --- sys/sys/file.h | 40 ++++++++++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/sys/sys/file.h b/sys/sys/file.h index 7bf33db852f1..640120fcae4e 100644 --- a/sys/sys/file.h +++ b/sys/sys/file.h @@ -40,9 +40,7 @@ #ifndef _KERNEL #include #include -#endif - -#ifdef _KERNEL +#else #include #include #include @@ -54,6 +52,16 @@ struct knote; struct vnode; struct socket; +#endif /* _KERNEL */ + +#define DTYPE_VNODE 1 /* file */ +#define DTYPE_SOCKET 2 /* communications endpoint */ +#define DTYPE_PIPE 3 /* pipe */ +#define DTYPE_FIFO 4 /* fifo (named pipe) */ +#define DTYPE_KQUEUE 5 /* event queue */ + +#ifdef _KERNEL + /* * Kernel descriptor table. * One entry for each open kernel vnode and socket. @@ -67,11 +75,6 @@ struct socket; struct file { LIST_ENTRY(file) f_list;/* (fl) list of active files */ short f_gcflag; /* used by thread doing fd garbage collection */ -#define DTYPE_VNODE 1 /* file */ -#define DTYPE_SOCKET 2 /* communications endpoint */ -#define DTYPE_PIPE 3 /* pipe */ -#define DTYPE_FIFO 4 /* fifo (named pipe) */ -#define DTYPE_KQUEUE 5 /* event queue */ short f_type; /* descriptor type */ int f_count; /* (f) reference count */ int f_msgcount; /* (f) references from message queue */ @@ -104,6 +107,27 @@ struct file { struct mtx *f_mtxp; /* mutex to protect data */ }; +#endif /* _KERNEL */ + +/* + * Userland version of struct file, for sysctl + */ +struct xfile { + size_t xf_size; /* size of struct xfile */ + pid_t xf_pid; /* owning process */ + uid_t xf_uid; /* effective uid of owning process */ + int xf_fd; /* descriptor number */ + void *xf_file; /* address of struct file */ + short xf_type; /* descriptor type */ + int xf_count; /* reference count */ + int xf_msgcount; /* references from message queue */ + off_t xf_offset; /* file offset */ + void *xf_data; /* pointer to vnode or socket */ + u_int xf_flag; /* flags (see fcntl.h) */ +}; + +#ifdef _KERNEL + #ifdef MALLOC_DECLARE MALLOC_DECLARE(M_FILE); #endif