Deleted Added
sdiff udiff text old ( 47829 ) new ( 49413 )
full compact
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.

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

31 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
32 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
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 * $Id: kern_descrip.c,v 1.63 1999/05/31 11:27:30 phk Exp $
40 */
41
42#include "opt_compat.h"
43#include "opt_devfs.h"
44
45#include <sys/param.h>
46#include <sys/systm.h>
47#include <sys/sysproto.h>

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

96 /* dump */ nodump,
97 /* psize */ nopsize,
98 /* flags */ 0,
99 /* maxio */ 0,
100 /* bmaj */ -1
101};
102
103static int finishdup __P((struct filedesc *fdp, int old, int new, register_t *retval));
104/*
105 * Descriptor management.
106 */
107struct filelist filehead; /* head of list of open files */
108int nfiles; /* actual number of open files */
109extern int cmask;
110
111/*

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

831 * Allocate a new file descriptor.
832 * If the process has file descriptor zero open, add to the list
833 * of open files at that point, otherwise put it at the front of
834 * the list of open files.
835 */
836 nfiles++;
837 MALLOC(fp, struct file *, sizeof(struct file), M_FILE, M_WAITOK);
838 bzero(fp, sizeof(struct file));
839 if ((fq = p->p_fd->fd_ofiles[0])) {
840 LIST_INSERT_AFTER(fq, fp, f_list);
841 } else {
842 LIST_INSERT_HEAD(&filehead, fp, f_list);
843 }
844 p->p_fd->fd_ofiles[i] = fp;
845 fp->f_count = 1;
846 fp->f_cred = p->p_ucred;
847 fp->f_seqcount = 1;
848 crhold(fp->f_cred);
849 if (resultfp)
850 *resultfp = fp;
851 if (resultfd)
852 *resultfd = i;
853 return (0);
854}
855
856/*

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

1073 if ((fp->f_flag & FHASLOCK) && fp->f_type == DTYPE_VNODE) {
1074 lf.l_whence = SEEK_SET;
1075 lf.l_start = 0;
1076 lf.l_len = 0;
1077 lf.l_type = F_UNLCK;
1078 vp = (struct vnode *)fp->f_data;
1079 (void) VOP_ADVLOCK(vp, (caddr_t)fp, F_UNLCK, &lf, F_FLOCK);
1080 }
1081 if (fp->f_ops)
1082 error = (*fp->f_ops->fo_close)(fp, p);
1083 else
1084 error = 0;
1085 ffree(fp);
1086 return (error);
1087}
1088
1089/*

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

1318 devfs_token_stderr =
1319 devfs_add_devswf(&fildesc_cdevsw, 2, DV_CHR,
1320 UID_ROOT, GID_WHEEL, 0666,
1321 "stderr");
1322#endif
1323 }
1324}
1325
1326SYSINIT(fildescdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,
1327 fildesc_drvinit,NULL)
1328
1329