filedesc.h (110906) | filedesc.h (115702) |
---|---|
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 110906 2003-02-15 05:52:56Z alfred $ | 34 * $FreeBSD: head/sys/sys/filedesc.h 115702 2003-06-02 16:05:32Z tegge $ |
35 */ 36 37#ifndef _SYS_FILEDESC_H_ 38#define _SYS_FILEDESC_H_ 39 40#include <sys/_lock.h> 41#include <sys/_mutex.h> 42#include <sys/queue.h> --- 27 unchanged lines hidden (view full) --- 70 u_short fd_cmask; /* mask for file creation */ 71 u_short fd_refcnt; /* reference count */ 72 73 int fd_knlistsize; /* size of knlist */ 74 struct klist *fd_knlist; /* list of attached knotes */ 75 u_long fd_knhashmask; /* size of knhash */ 76 struct klist *fd_knhash; /* hash table for attached knotes */ 77 struct mtx fd_mtx; /* mtx to protect the members of struct filedesc */ | 35 */ 36 37#ifndef _SYS_FILEDESC_H_ 38#define _SYS_FILEDESC_H_ 39 40#include <sys/_lock.h> 41#include <sys/_mutex.h> 42#include <sys/queue.h> --- 27 unchanged lines hidden (view full) --- 70 u_short fd_cmask; /* mask for file creation */ 71 u_short fd_refcnt; /* reference count */ 72 73 int fd_knlistsize; /* size of knlist */ 74 struct klist *fd_knlist; /* list of attached knotes */ 75 u_long fd_knhashmask; /* size of knhash */ 76 struct klist *fd_knhash; /* hash table for attached knotes */ 77 struct mtx fd_mtx; /* mtx to protect the members of struct filedesc */ |
78 int fd_holdleaderscount; /* block fdfree() for shared close() */ 79 int fd_holdleaderswakeup; /* fdfree() needs wakeup */ |
|
78}; 79 80/* 81 * Basic allocation of descriptors: 82 * one of the above, plus arrays for NDFILE descriptors. 83 */ 84struct filedesc0 { 85 struct filedesc fd_fd; 86 /* 87 * These arrays are used when the number of open files is 88 * <= NDFILE, and are then pointed to by the pointers above. 89 */ 90 struct file *fd_dfiles[NDFILE]; 91 char fd_dfileflags[NDFILE]; 92}; 93 | 80}; 81 82/* 83 * Basic allocation of descriptors: 84 * one of the above, plus arrays for NDFILE descriptors. 85 */ 86struct filedesc0 { 87 struct filedesc fd_fd; 88 /* 89 * These arrays are used when the number of open files is 90 * <= NDFILE, and are then pointed to by the pointers above. 91 */ 92 struct file *fd_dfiles[NDFILE]; 93 char fd_dfileflags[NDFILE]; 94}; 95 |
96 97 |
|
94/* | 98/* |
99 * Structure to keep track of (process leader, struct fildedesc) tuples. 100 * Each process has a pointer to such a structure when detailed tracking 101 * is needed. e.g. when rfork(RFPROC | RFMEM) causes a file descriptor 102 * table to be shared by processes having different "p_leader" pointers 103 * and thus distinct POSIX style locks. 104 * 105 * fdl_refcount and fdl_holdcount are protected by struct filedesc mtx. 106 */ 107struct filedesc_to_leader { 108 int fdl_refcount; /* references from struct proc */ 109 int fdl_holdcount; /* temporary hold during closef */ 110 int fdl_wakeup; /* fdfree() waits on closef() */ 111 struct proc *fdl_leader; /* owner of POSIX locks */ 112 /* Circular list */ 113 struct filedesc_to_leader *fdl_prev; 114 struct filedesc_to_leader *fdl_next; 115}; 116 117/* |
|
95 * Per-process open flags. 96 */ 97#define UF_EXCLOSE 0x01 /* auto-close on exec */ 98#if 0 99#define UF_MAPPED 0x02 /* mapped from device */ 100#endif 101 102/* --- 23 unchanged lines hidden (view full) --- 126void fdfree(struct thread *td); 127struct filedesc *fdinit(struct filedesc *fdp); 128struct filedesc *fdshare(struct filedesc *fdp); 129void ffree(struct file *fp); 130static __inline struct file * fget_locked(struct filedesc *fdp, int fd); 131int getvnode(struct filedesc *fdp, int fd, struct file **fpp); 132void setugidsafety(struct thread *td); 133 | 118 * Per-process open flags. 119 */ 120#define UF_EXCLOSE 0x01 /* auto-close on exec */ 121#if 0 122#define UF_MAPPED 0x02 /* mapped from device */ 123#endif 124 125/* --- 23 unchanged lines hidden (view full) --- 149void fdfree(struct thread *td); 150struct filedesc *fdinit(struct filedesc *fdp); 151struct filedesc *fdshare(struct filedesc *fdp); 152void ffree(struct file *fp); 153static __inline struct file * fget_locked(struct filedesc *fdp, int fd); 154int getvnode(struct filedesc *fdp, int fd, struct file **fpp); 155void setugidsafety(struct thread *td); 156 |
157struct filedesc_to_leader * 158filedesc_to_leader_alloc(struct filedesc_to_leader *old, 159 struct filedesc *fdp, 160 struct proc *leader); 161 162 |
|
134static __inline struct file * 135fget_locked(struct filedesc *fdp, int fd) 136{ 137 138 /* u_int cast checks for negative descriptors. */ 139 return ((u_int)fd >= (u_int)fdp->fd_nfiles ? NULL : fdp->fd_ofiles[fd]); 140} 141 142extern struct mtx fdesc_mtx; 143 144#endif /* _KERNEL */ 145 146#endif /* !_SYS_FILEDESC_H_ */ | 163static __inline struct file * 164fget_locked(struct filedesc *fdp, int fd) 165{ 166 167 /* u_int cast checks for negative descriptors. */ 168 return ((u_int)fd >= (u_int)fdp->fd_nfiles ? NULL : fdp->fd_ofiles[fd]); 169} 170 171extern struct mtx fdesc_mtx; 172 173#endif /* _KERNEL */ 174 175#endif /* !_SYS_FILEDESC_H_ */ |