kern_descrip.c (12662) | kern_descrip.c (12675) |
---|---|
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 | 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.19 1995/12/05 21:51:28 bde Exp $ | 39 * $Id: kern_descrip.c,v 1.20 1995/12/07 12:46:38 davidg Exp $ |
40 */ 41 42#include <sys/param.h> 43#include <sys/systm.h> 44#include <sys/sysproto.h> 45#include <sys/conf.h> 46#include <sys/filedesc.h> 47#include <sys/kernel.h> --- 9 unchanged lines hidden (view full) --- 57#include <sys/malloc.h> 58#include <sys/unistd.h> 59#include <sys/resourcevar.h> 60 61#include <vm/vm.h> 62#include <vm/vm_param.h> 63#include <vm/vm_extern.h> 64 | 40 */ 41 42#include <sys/param.h> 43#include <sys/systm.h> 44#include <sys/sysproto.h> 45#include <sys/conf.h> 46#include <sys/filedesc.h> 47#include <sys/kernel.h> --- 9 unchanged lines hidden (view full) --- 57#include <sys/malloc.h> 58#include <sys/unistd.h> 59#include <sys/resourcevar.h> 60 61#include <vm/vm.h> 62#include <vm/vm_param.h> 63#include <vm/vm_extern.h> 64 |
65#ifdef JREMOD 66#include <sys/conf.h> | |
67#ifdef DEVFS 68#include <sys/devfsext.h> 69#endif /*DEVFS*/ | 65#ifdef DEVFS 66#include <sys/devfsext.h> 67#endif /*DEVFS*/ |
68 69static d_open_t fdopen; 70#define NUMFDESC 64 71 |
|
70#define CDEV_MAJOR 22 | 72#define CDEV_MAJOR 22 |
71#endif /*JREMOD*/ | 73struct cdevsw fildesc_cdevsw = 74 { fdopen, noclose, noread, nowrite, /*22*/ 75 noioc, nostop, nullreset, nodevtotty,/*fd(!=Fd)*/ 76 noselect, nommap, nostrat }; |
72 73int finishdup(struct filedesc *fdp, int old, int new, int *retval); 74/* 75 * Descriptor management. 76 */ 77struct file *filehead; /* head of list of open files */ 78int nfiles; /* actual number of open files */ 79 --- 811 unchanged lines hidden (view full) --- 891 * File Descriptor pseudo-device driver (/dev/fd/). 892 * 893 * Opening minor device N dup()s the file (if any) connected to file 894 * descriptor N belonging to the calling process. Note that this driver 895 * consists of only the ``open()'' routine, because all subsequent 896 * references to this file will be direct to the other driver. 897 */ 898/* ARGSUSED */ | 77 78int finishdup(struct filedesc *fdp, int old, int new, int *retval); 79/* 80 * Descriptor management. 81 */ 82struct file *filehead; /* head of list of open files */ 83int nfiles; /* actual number of open files */ 84 --- 811 unchanged lines hidden (view full) --- 896 * File Descriptor pseudo-device driver (/dev/fd/). 897 * 898 * Opening minor device N dup()s the file (if any) connected to file 899 * descriptor N belonging to the calling process. Note that this driver 900 * consists of only the ``open()'' routine, because all subsequent 901 * references to this file will be direct to the other driver. 902 */ 903/* ARGSUSED */ |
899int | 904static int |
900fdopen(dev, mode, type, p) 901 dev_t dev; 902 int mode, type; 903 struct proc *p; 904{ 905 906 /* 907 * XXX Kludge: set curproc->p_dupfd to contain the value of the --- 122 unchanged lines hidden (view full) --- 1030SYSCTL_PROC(_kern, KERN_FILE, file, CTLTYPE_OPAQUE|CTLFLAG_RD, 1031 0, 0, sysctl_kern_file, "S,file", ""); 1032 1033SYSCTL_INT(_kern, KERN_MAXFILESPERPROC, maxfilesperproc, 1034 CTLFLAG_RD, &maxfilesperproc, 0, ""); 1035 1036SYSCTL_INT(_kern, KERN_MAXFILES, maxfiles, CTLFLAG_RW, &maxfiles, 0, ""); 1037 | 905fdopen(dev, mode, type, p) 906 dev_t dev; 907 int mode, type; 908 struct proc *p; 909{ 910 911 /* 912 * XXX Kludge: set curproc->p_dupfd to contain the value of the --- 122 unchanged lines hidden (view full) --- 1035SYSCTL_PROC(_kern, KERN_FILE, file, CTLTYPE_OPAQUE|CTLFLAG_RD, 1036 0, 0, sysctl_kern_file, "S,file", ""); 1037 1038SYSCTL_INT(_kern, KERN_MAXFILESPERPROC, maxfilesperproc, 1039 CTLFLAG_RD, &maxfilesperproc, 0, ""); 1040 1041SYSCTL_INT(_kern, KERN_MAXFILES, maxfiles, CTLFLAG_RW, &maxfiles, 0, ""); 1042 |
1038#ifdef JREMOD 1039static struct cdevsw fildesc_cdevsw = 1040 { fdopen, noclose, noread, nowrite, /*22*/ 1041 noioc, nostop, nullreset, nodevtotty,/*fd(!=Fd)*/ 1042 noselect, nommap, nostrat }; 1043 | |
1044static fildesc_devsw_installed = 0; | 1043static fildesc_devsw_installed = 0; |
1044static void *devfs_token_stdin; 1045static void *devfs_token_stdout; 1046static void *devfs_token_stderr; 1047static void *devfs_token_fildesc[NUMFDESC]; |
|
1045 1046static void fildesc_drvinit(void *unused) 1047{ 1048 dev_t dev; | 1048 1049static void fildesc_drvinit(void *unused) 1050{ 1051 dev_t dev; |
1052 int i; 1053 char name[32]; |
|
1049 1050 if( ! fildesc_devsw_installed ) { 1051 dev = makedev(CDEV_MAJOR,0); 1052 cdevsw_add(&dev,&fildesc_cdevsw,NULL); 1053 fildesc_devsw_installed = 1; 1054#ifdef DEVFS | 1054 1055 if( ! fildesc_devsw_installed ) { 1056 dev = makedev(CDEV_MAJOR,0); 1057 cdevsw_add(&dev,&fildesc_cdevsw,NULL); 1058 fildesc_devsw_installed = 1; 1059#ifdef DEVFS |
1055 { 1056 int x; 1057/* default for a simple device with no probe routine (usually delete this) */ 1058/* path name devsw minor type uid gid perm*/ 1059 x=devfs_add_devsw("/","stdin",major(dev),0,DV_CHR, 1060 0, 0, 0600); 1061 x=devfs_add_devsw("/","stdout",major(dev),1,DV_CHR, 1062 0, 0, 0600); 1063 x=devfs_add_devsw("/","stderr",major(dev),2,DV_CHR, 1064 0, 0, 0600); | 1060 for ( i = 0 ; i < NUMFDESC ; i++ ) { 1061 sprintf(name,"%d",i); 1062 devfs_token_fildesc[i] = devfs_add_devsw("fd",name, 1063 &fildesc_cdevsw,0, 1064 DV_CHR, 0, 0, 0666); |
1065 } | 1065 } |
1066 devfs_token_stdin = 1067 dev_link("/","stdin",devfs_token_fildesc[0]); 1068 devfs_token_stdout = 1069 dev_link("/","stdout",devfs_token_fildesc[1]); 1070 devfs_token_stderr = 1071 dev_link("/","stderr",devfs_token_fildesc[2]); |
|
1066#endif 1067 } 1068} 1069 1070SYSINIT(fildescdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR, 1071 fildesc_drvinit,NULL) 1072 | 1072#endif 1073 } 1074} 1075 1076SYSINIT(fildescdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR, 1077 fildesc_drvinit,NULL) 1078 |
1073#endif /* JREMOD */ | 1079 |