diff options
author | hsu <hsu@FreeBSD.org> | 1996-03-11 02:17:30 +0000 |
---|---|---|
committer | hsu <hsu@FreeBSD.org> | 1996-03-11 02:17:30 +0000 |
commit | 4ce83d9416d326466a861477103572379108d59d (patch) | |
tree | 709b87b2b59e132c00c5ad6a02b55240d7ae18b7 /sys | |
parent | 986af46af945c7bae3a66d639ca06d3275278279 (diff) | |
download | FreeBSD-src-4ce83d9416d326466a861477103572379108d59d.zip FreeBSD-src-4ce83d9416d326466a861477103572379108d59d.tar.gz |
Merge in Lite2: LIST replacement for f_filef, f_fileb, and filehead.
Did not accept change of second argument to ioctl from int to u_long.
Reviewed by: davidg & bde
Diffstat (limited to 'sys')
-rw-r--r-- | sys/kern/kern_descrip.c | 34 | ||||
-rw-r--r-- | sys/sys/file.h | 12 |
2 files changed, 20 insertions, 26 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 8dc24d7..26f3ace 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)kern_descrip.c 8.6 (Berkeley) 4/19/94 - * $Id: kern_descrip.c,v 1.25 1996/02/04 19:56:34 dyson Exp $ + * $Id: kern_descrip.c,v 1.28 1996/02/25 09:38:18 hsu Exp $ */ #include <sys/param.h> @@ -80,8 +80,8 @@ static int finishdup(struct filedesc *fdp, int old, int new, int *retval); /* * Descriptor management. */ -struct file *filehead; /* head of list of open files */ -int nfiles; /* actual number of open files */ +struct filelist filehead; /* head of list of open files */ +int nfiles; /* actual number of open files */ extern int cmask; /* @@ -259,7 +259,7 @@ fcntl(p, uap, retval) return (0); } error = (*fp->f_ops->fo_ioctl) - (fp, (int)TIOCGPGRP, (caddr_t)retval, p); + (fp, TIOCGPGRP, (caddr_t)retval, p); *retval = -*retval; return (error); @@ -277,7 +277,7 @@ fcntl(p, uap, retval) uap->arg = p1->p_pgrp->pg_id; } return ((*fp->f_ops->fo_ioctl) - (fp, (int)TIOCSPGRP, (caddr_t)&uap->arg, p)); + (fp, TIOCSPGRP, (caddr_t)&uap->arg, p)); case F_SETLKW: flg |= F_WAIT; @@ -641,7 +641,7 @@ falloc(p, resultfp, resultfd) struct file **resultfp; int *resultfd; { - register struct file *fp, *fq, **fpp; + register struct file *fp, *fq; int error, i; if ((error = fdalloc(p, 0, &i))) @@ -659,16 +659,12 @@ falloc(p, resultfp, resultfd) nfiles++; MALLOC(fp, struct file *, sizeof(struct file), M_FILE, M_WAITOK); bzero(fp, sizeof(struct file)); - if ((fq = p->p_fd->fd_ofiles[0])) - fpp = &fq->f_filef; - else - fpp = &filehead; + if ((fq = p->p_fd->fd_ofiles[0])) { + LIST_INSERT_AFTER(fq, fp, f_list); + } else { + LIST_INSERT_HEAD(&filehead, fp, f_list); + } p->p_fd->fd_ofiles[i] = fp; - if ((fq = *fpp)) - fq->f_fileb = &fp->f_filef; - fp->f_filef = fq; - fp->f_fileb = fpp; - *fpp = fp; fp->f_count = 1; fp->f_cred = p->p_ucred; crhold(fp->f_cred); @@ -688,13 +684,9 @@ ffree(fp) { register struct file *fq; - if ((fq = fp->f_filef)) - fq->f_fileb = fp->f_fileb; - *fp->f_fileb = fq; + LIST_REMOVE(fp, f_list); crfree(fp->f_cred); #ifdef DIAGNOSTIC - fp->f_filef = NULL; - fp->f_fileb = NULL; fp->f_count = 0; #endif nfiles--; @@ -1085,7 +1077,7 @@ sysctl_kern_file SYSCTL_HANDLER_ARGS /* * followed by an array of file structures */ - for (fp = filehead; fp != NULL; fp = fp->f_filef) { + for (fp = filehead.lh_first; fp != NULL; fp = fp->f_list.le_next) { error = SYSCTL_OUT(req, (caddr_t)fp, sizeof (struct file)); if (error) return (error); diff --git a/sys/sys/file.h b/sys/sys/file.h index df210ac..24b7d54 100644 --- a/sys/sys/file.h +++ b/sys/sys/file.h @@ -30,8 +30,8 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * @(#)file.h 8.1 (Berkeley) 6/2/93 - * $Id: file.h,v 1.5 1995/03/16 18:16:16 bde Exp $ + * @(#)file.h 8.3 (Berkeley) 1/9/95 + * $Id: file.h,v 1.8 1996/02/29 00:07:11 hsu Exp $ */ #ifndef _SYS_FILE_H_ @@ -41,6 +41,8 @@ #include <sys/unistd.h> #ifdef KERNEL +#include <sys/queue.h> + struct proc; struct uio; @@ -49,8 +51,7 @@ struct uio; * One entry for each open kernel vnode and socket. */ struct file { - struct file *f_filef; /* list of active files */ - struct file **f_fileb; /* list of active files */ + LIST_ENTRY(file) f_list;/* list of active files */ short f_flag; /* see fcntl.h */ #define DTYPE_VNODE 1 /* file */ #define DTYPE_SOCKET 2 /* communications endpoint */ @@ -74,7 +75,8 @@ struct file { caddr_t f_data; /* vnode or socket */ }; -extern struct file *filehead; /* head of list of open files */ +LIST_HEAD(filelist, file); +extern struct filelist filehead; /* head of list of open files */ extern struct fileops vnops; extern int maxfiles; /* kernel limit on number of open files */ extern int maxfilesperproc; /* per process limit on number of open files */ |