Deleted Added
full compact
filedesc.h (83366) filedesc.h (89306)
1/*
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)filedesc.h 8.1 (Berkeley) 6/2/93
1/*
2 * Copyright (c) 1990, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 17 unchanged lines hidden (view full) ---

26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)filedesc.h 8.1 (Berkeley) 6/2/93
34 * $FreeBSD: head/sys/sys/filedesc.h 83366 2001-09-12 08:38:13Z julian $
34 * $FreeBSD: head/sys/sys/filedesc.h 89306 2002-01-13 11:58:06Z alfred $
35 */
36
37#ifndef _SYS_FILEDESC_H_
38#define _SYS_FILEDESC_H_
39
35 */
36
37#ifndef _SYS_FILEDESC_H_
38#define _SYS_FILEDESC_H_
39
40#include <sys/lock.h>
41#include <sys/mutex.h>
40#include <sys/queue.h>
42#include <sys/queue.h>
43#include <sys/sx.h>
41
42/*
43 * This structure is used for the management of descriptors. It may be
44 * shared by multiple processes.
45 *
46 * A process is initially started out with NDFILE descriptors stored within
47 * this structure, selected to be enough for typical applications based on
48 * the historical limit of 20 open files (and the usage of descriptors by

--- 9 unchanged lines hidden (view full) ---

58
59struct filedesc {
60 struct file **fd_ofiles; /* file structures for open files */
61 char *fd_ofileflags; /* per-process open file flags */
62 struct vnode *fd_cdir; /* current directory */
63 struct vnode *fd_rdir; /* root directory */
64 struct vnode *fd_jdir; /* jail root directory */
65 int fd_nfiles; /* number of open files allocated */
44
45/*
46 * This structure is used for the management of descriptors. It may be
47 * shared by multiple processes.
48 *
49 * A process is initially started out with NDFILE descriptors stored within
50 * this structure, selected to be enough for typical applications based on
51 * the historical limit of 20 open files (and the usage of descriptors by

--- 9 unchanged lines hidden (view full) ---

61
62struct filedesc {
63 struct file **fd_ofiles; /* file structures for open files */
64 char *fd_ofileflags; /* per-process open file flags */
65 struct vnode *fd_cdir; /* current directory */
66 struct vnode *fd_rdir; /* root directory */
67 struct vnode *fd_jdir; /* jail root directory */
68 int fd_nfiles; /* number of open files allocated */
66 u_short fd_lastfile; /* high-water mark of fd_ofiles */
67 u_short fd_freefile; /* approx. next free file */
69 int fd_lastfile; /* high-water mark of fd_ofiles */
70 int fd_freefile; /* approx. next free file */
68 u_short fd_cmask; /* mask for file creation */
69 u_short fd_refcnt; /* reference count */
70
71 int fd_knlistsize; /* size of knlist */
72 struct klist *fd_knlist; /* list of attached knotes */
73 u_long fd_knhashmask; /* size of knhash */
74 struct klist *fd_knhash; /* hash table for attached knotes */
71 u_short fd_cmask; /* mask for file creation */
72 u_short fd_refcnt; /* reference count */
73
74 int fd_knlistsize; /* size of knlist */
75 struct klist *fd_knlist; /* list of attached knotes */
76 u_long fd_knhashmask; /* size of knhash */
77 struct klist *fd_knhash; /* hash table for attached knotes */
78 struct mtx fd_mtx; /* mtx to protect the members of struct filedesc */
75};
76
77/*
78 * Basic allocation of descriptors:
79 * one of the above, plus arrays for NDFILE descriptors.
80 */
81struct filedesc0 {
82 struct filedesc fd_fd;

--- 37 unchanged lines hidden (view full) ---

120 pid_t sio_pgid; /* pgid for signals */
121};
122#define sio_proc sio_u.siu_proc
123#define sio_pgrp sio_u.siu_pgrp
124
125SLIST_HEAD(sigiolst, sigio);
126
127#ifdef _KERNEL
79};
80
81/*
82 * Basic allocation of descriptors:
83 * one of the above, plus arrays for NDFILE descriptors.
84 */
85struct filedesc0 {
86 struct filedesc fd_fd;

--- 37 unchanged lines hidden (view full) ---

124 pid_t sio_pgid; /* pgid for signals */
125};
126#define sio_proc sio_u.siu_proc
127#define sio_pgrp sio_u.siu_pgrp
128
129SLIST_HEAD(sigiolst, sigio);
130
131#ifdef _KERNEL
132
133/* Lock a file descriptor table. */
134/*#define FILEDESC_LOCK_DEBUG*/
135#ifdef FILEDESC_LOCK_DEBUG
136#define FILEDESC_LOCK(fd) \
137 do { \
138 printf("FD_LCK: %p %s %d\n", &(fd)->fd_mtx, __FILE__, __LINE__); \
139 mtx_lock(&(fd)->fd_mtx); \
140 } while (0)
141#define FILEDESC_UNLOCK(fd) \
142 do { \
143 printf("FD_REL: %p %s %d\n", &(fd)->fd_mtx, __FILE__, __LINE__); \
144 mtx_unlock(&(fd)->fd_mtx); \
145 } while (0)
146#else
147#define FILEDESC_LOCK(fd) mtx_lock(&(fd)->fd_mtx)
148#define FILEDESC_UNLOCK(fd) mtx_unlock(&(fd)->fd_mtx)
149#endif
150#define FILEDESC_LOCKED(fd) mtx_owned(&(fd)->fd_mtx)
151#define FILEDESC_LOCK_ASSERT(fd, type) mtx_assert(&(fd)->fd_mtx, (type))
152
128int closef __P((struct file *fp, struct thread *p));
129int dupfdopen __P((struct thread *td, struct filedesc *fdp, int indx, int dfd, int mode,
130 int error));
131int falloc __P((struct thread *p, struct file **resultfp, int *resultfd));
132int fdalloc __P((struct thread *p, int want, int *result));
133int fdavail __P((struct thread *td, int n));
134void fdcloseexec __P((struct thread *td));
135struct filedesc *fdcopy __P((struct thread *td));

--- 15 unchanged lines hidden ---
153int closef __P((struct file *fp, struct thread *p));
154int dupfdopen __P((struct thread *td, struct filedesc *fdp, int indx, int dfd, int mode,
155 int error));
156int falloc __P((struct thread *p, struct file **resultfp, int *resultfd));
157int fdalloc __P((struct thread *p, int want, int *result));
158int fdavail __P((struct thread *td, int n));
159void fdcloseexec __P((struct thread *td));
160struct filedesc *fdcopy __P((struct thread *td));

--- 15 unchanged lines hidden ---