summaryrefslogtreecommitdiffstats
path: root/sys/miscfs
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>1995-09-03 05:43:50 +0000
committerjulian <julian@FreeBSD.org>1995-09-03 05:43:50 +0000
commit3b421a628b770ce7d903f166e047d7dc8e672ed7 (patch)
tree48c036cfd246d74ad2a6c99044f9938396941363 /sys/miscfs
parent6759a9710d59bc29e3766f8fa8c2699111015c60 (diff)
downloadFreeBSD-src-3b421a628b770ce7d903f166e047d7dc8e672ed7.zip
FreeBSD-src-3b421a628b770ce7d903f166e047d7dc8e672ed7.tar.gz
devfs changes..
changes to allow devices that don't probe (e.g. /dev/mem) to create devfs entries this required giving 'configure' its own SYSINIT entry so we could duck in just before it with a DEVFS init and some device inits.. my devfs now looks like: ./misc ./misc/speaker ./misc/mem ./misc/kmem ./misc/null ./misc/zero ./misc/io ./misc/console ./misc/pcaudio ./misc/pcaudioctl ./disks ./disks/rfloppy ./disks/rfloppy/fd0.1440 ./disks/rfloppy/fd1.1200 ./disks/floppy ./disks/floppy/fd0.1440 ./disks/floppy/fd1.1200 also some sligt cleanups.. DEVFS needs a lot of work but I'm getting back to it..
Diffstat (limited to 'sys/miscfs')
-rw-r--r--sys/miscfs/devfs/devfs_back.c145
-rw-r--r--sys/miscfs/devfs/devfs_proto.h6
-rw-r--r--sys/miscfs/devfs/devfs_vfsops.c6
-rw-r--r--sys/miscfs/devfs/reproto.sh6
4 files changed, 84 insertions, 79 deletions
diff --git a/sys/miscfs/devfs/devfs_back.c b/sys/miscfs/devfs/devfs_back.c
index 5e615cb..0a15e40 100644
--- a/sys/miscfs/devfs/devfs_back.c
+++ b/sys/miscfs/devfs/devfs_back.c
@@ -2,7 +2,7 @@
/*
* Written by Julian Elischer (julian@DIALix.oz.au)
*
- * $Header: /home/ncvs/src/sys/miscfs/devfs/devfs_back.c,v 1.2 1995/04/20 07:34:51 julian Exp $
+ * $Header: /home/ncvs/src/sys/miscfs/devfs/devfs_back.c,v 1.3 1995/05/30 08:06:49 rgrimes Exp $
*/
#include "param.h"
@@ -17,11 +17,12 @@
#include "malloc.h"
#include "dir.h" /* defines dirent structure */
#include "devfsdefs.h"
+#include "sys/devfsext.h"
+SYSINIT(devfs, SI_SUB_DEVFS, SI_ORDER_FIRST, devfs_sinit, NULL)
devnm_p dev_root; /* root of the backing tree */
-int devfs_set_up = 0; /* note tha we HAVE set up the backing tree */
/*
* Set up the root directory node in the backing plane
@@ -30,82 +31,76 @@ int devfs_set_up = 0; /* note tha we HAVE set up the backing tree */
* Notice that the ops are by indirection.. as they haven't
* been set up yet!
*/
-void devfs_back_init() /*proto*/
+void devfs_sinit() /*proto*/
{
devnm_p devbp;
dn_p dnp;
+
+ /*
+ * Allocate and fill out a new backing node
+ */
+ if(!(devbp = (devnm_p)malloc(sizeof(devnm_t),
+ M_DEVFSBACK, M_NOWAIT)))
+ {
+ return ;
+ }
+ bzero(devbp,sizeof(devnm_t));
/*
- * This may be called several times.. only do it if it needs
- * to be done.
+ * And the devnode associated with it
*/
- if(!devfs_set_up)
+ if(!(dnp = (dn_p)malloc(sizeof(devnode_t),
+ M_DEVFSNODE, M_NOWAIT)))
{
- /*
- * Allocate and fill out a new backing node
- */
- if(!(devbp = (devnm_p)malloc(sizeof(devnm_t),
- M_DEVFSBACK, M_NOWAIT)))
- {
- return ;
- }
- bzero(devbp,sizeof(devnm_t));
- /*
- * And the devnode associated with it
- */
- if(!(dnp = (dn_p)malloc(sizeof(devnode_t),
- M_DEVFSNODE, M_NOWAIT)))
- {
- free(devbp,M_DEVFSBACK);
- return ;
- }
- bzero(dnp,sizeof(devnode_t));
- /*
- * Link the two together
- */
- devbp->dnp = dnp;
- dnp->links = 1;
- /*
- * set up the directory node for the root
- * and put in all the usual entries for a directory node
- */
- dnp->type = DEV_DIR;
- dnp->links++; /* for .*/
- /* root loops to self */
- dnp->by.Dir.parent = dnp;
- dnp->links++; /* for ..*/
- /*
- * set up the list of children (none so far)
- */
- dnp->by.Dir.dirlist = (devnm_p)0;
- dnp->by.Dir.dirlast =
- &dnp->by.Dir.dirlist;
- dnp->by.Dir.myname = devbp;
- /*
- * set up a pointer to directory type ops
- */
- dnp->ops = &devfs_vnodeop_p;
- dnp->mode |= 0555; /* default perms */
- /*
- * note creation times etc, as now (boot time)
- */
- TIMEVAL_TO_TIMESPEC(&time,&(dnp->ctime))
- dnp->mtime = dnp->ctime;
- dnp->atime = dnp->ctime;
+ free(devbp,M_DEVFSBACK);
+ return ;
+ }
+ bzero(dnp,sizeof(devnode_t));
+ /*
+ * Link the two together
+ */
+ devbp->dnp = dnp;
+ dnp->links = 1;
+ /*
+ * set up the directory node for the root
+ * and put in all the usual entries for a directory node
+ */
+ dnp->type = DEV_DIR;
+ dnp->links++; /* for .*/
+ /* root loops to self */
+ dnp->by.Dir.parent = dnp;
+ dnp->links++; /* for ..*/
+ /*
+ * set up the list of children (none so far)
+ */
+ dnp->by.Dir.dirlist = (devnm_p)0;
+ dnp->by.Dir.dirlast =
+ &dnp->by.Dir.dirlist;
+ dnp->by.Dir.myname = devbp;
+ /*
+ * set up a pointer to directory type ops
+ */
+ dnp->ops = &devfs_vnodeop_p;
+ dnp->mode |= 0555; /* default perms */
+ /*
+ * note creation times etc, as now (boot time)
+ */
+ TIMEVAL_TO_TIMESPEC(&time,&(dnp->ctime))
+ dnp->mtime = dnp->ctime;
+ dnp->atime = dnp->ctime;
- /*
- * and the list of layers
- */
- devbp->next_front = NULL;
- devbp->prev_frontp = &(devbp->next_front);
+ /*
+ * and the list of layers
+ */
+ devbp->next_front = NULL;
+ devbp->prev_frontp = &(devbp->next_front);
- /*
- * next time, we don't need to do all this
- */
- dev_root = devbp;
- devfs_set_up = 1;
- }
+ /*
+ * next time, we don't need to do all this
+ */
+ dev_root = devbp;
+ printf("DEVFS: ready for devices\n");
}
/***********************************************************************\
@@ -135,7 +130,6 @@ int dev_finddir(char *orig_path, dn_p dirnode, int create, dn_p *dn_pp) /*proto*
DBPRINT(("dev_finddir\n"));
- devfs_back_init(); /* in case we are the first */
if(!dirnode) dirnode = dev_root->dnp;
if(dirnode->type != DEV_DIR) return ENOTDIR;
if(strlen(orig_path) > (DEVMAXPATHSIZE - 1)) return ENAMETOOLONG;
@@ -458,7 +452,14 @@ int get_bdev_major_num(caddr_t addr) /*proto*/
* Add the named device entry into the given directory, and make it *
* The appropriate type... (called (sometimes indirectly) by drivers..) *
\***********************************************************************/
-devnm_p dev_add(char *path,char *name,caddr_t funct,int minor,int chrblk,uid_t uid,gid_t gid, int perms) /*proto*/
+void *dev_add(char *path,
+ char *name,
+ void *funct,
+ int minor,
+ int chrblk,
+ uid_t uid,
+ gid_t gid,
+ int perms)
{
devnm_p new_dev;
dn_p dnp; /* devnode for parent directory */
@@ -471,7 +472,7 @@ devnm_p dev_add(char *path,char *name,caddr_t funct,int minor,int chrblk,uid_t u
if (retval) return 0;
switch(chrblk)
{
- case 0:
+ case DV_CHR:
major = get_cdev_major_num(funct);
by.Cdev.cdevsw = cdevsw + major;
by.Cdev.dev = makedev(major, minor);
@@ -479,7 +480,7 @@ devnm_p dev_add(char *path,char *name,caddr_t funct,int minor,int chrblk,uid_t u
&by,&new_dev))
return 0;
break;
- case 1:
+ case DV_BLK:
major = get_bdev_major_num(funct);
by.Bdev.bdevsw = bdevsw + major;
by.Bdev.dev = makedev(major, minor);
diff --git a/sys/miscfs/devfs/devfs_proto.h b/sys/miscfs/devfs/devfs_proto.h
index a4ac67b..77cd5ac 100644
--- a/sys/miscfs/devfs/devfs_proto.h
+++ b/sys/miscfs/devfs/devfs_proto.h
@@ -1,4 +1,5 @@
-void devfs_back_init() /*proto*/;
+/* THIS FILE PRODUCED AUTOMATICALLY */
+void devfs_sinit() /*proto*/;
int dev_finddir(char *orig_path, dn_p dirnode, int create, dn_p *dn_pp) /*proto*/;
int dev_add_node(char *name, dn_p dirnode, int entrytype, union typeinfo *by, devnm_p *devnm_pp) /*proto*/;
int dev_remove(devnm_p devbp) /*proto*/;
@@ -6,7 +7,6 @@ int dev_touch(devnm_p key) /* update the node for this dev */ /*proto*/;
void devfs_dn_free(dn_p dnp) /*proto*/;
int get_cdev_major_num(caddr_t addr) /*proto*/;
int get_bdev_major_num(caddr_t addr) /*proto*/;
-devnm_p dev_add(char *path,char *name,caddr_t funct,int minor,int chrblk,uid_t uid,gid_t gid, int perms) /*proto*/;
int devfs_add_fronts(devnm_p parent,devnm_p child) /*proto*/;
dn_p dev_findfront(dn_p dir,char *name) /*proto*/;
int dev_mk_front(dn_p parent,devnm_p back,devnm_p *devnm_pp , struct devfsmount *dvm) /*proto*/;
@@ -29,3 +29,5 @@ int devfs_vget(struct mount *mp, ino_t ino,struct vnode **vpp) /*proto*/;
int devfs_fhtovp (struct mount *mp, struct fid *fhp, struct mbuf *nam, struct vnode **vpp, int *exflagsp, struct ucred **credanonp) /*proto*/;
int devfs_vptofh (struct vnode *vp, struct fid *fhp) /*proto*/;
void devfs_dropvnode(dn_p dnp) /*proto*/;
+/* THIS FILE PRODUCED AUTOMATICALLY */
+/* DO NOT EDIT (see reproto.sh) */
diff --git a/sys/miscfs/devfs/devfs_vfsops.c b/sys/miscfs/devfs/devfs_vfsops.c
index 5781df7..7edb6cc 100644
--- a/sys/miscfs/devfs/devfs_vfsops.c
+++ b/sys/miscfs/devfs/devfs_vfsops.c
@@ -1,7 +1,7 @@
/*
* Written by Julian Elischer (julian@DIALix.oz.au)
*
- * $Header: /home/ncvs/src/sys/miscfs/devfs/devfs_vfsops.c,v 1.2 1995/04/20 07:34:53 julian Exp $
+ * $Header: /home/ncvs/src/sys/miscfs/devfs/devfs_vfsops.c,v 1.3 1995/05/30 08:06:52 rgrimes Exp $
*
*
*/
@@ -22,9 +22,7 @@
int devfs_init(void) /*proto*/
{
- printf("devfs initialised\n");
- devfs_back_init();
- /* devfs_front_init();*/ /* nothing to do at the moment */
+ printf("devfs ready to run\n");
return 0; /*XXX*/
}
diff --git a/sys/miscfs/devfs/reproto.sh b/sys/miscfs/devfs/reproto.sh
index dc4b731..277f68a 100644
--- a/sys/miscfs/devfs/reproto.sh
+++ b/sys/miscfs/devfs/reproto.sh
@@ -1,2 +1,6 @@
#!/bin/sh
-grep -h '/\*proto\*/' *.c |awk '{print $0 ";"}' >devfs_proto.h
+echo "/* THIS FILE PRODUCED AUTOMATICALLY */" >devfs_proto.h
+grep -h '/\*proto\*/' *.c |awk '{print $0 ";"}' >>devfs_proto.h
+echo "/* THIS FILE PRODUCED AUTOMATICALLY */" >>devfs_proto.h
+echo "/* DO NOT EDIT (see reproto.sh) */" >>devfs_proto.h
+
OpenPOWER on IntegriCloud