From a8ea97ec7f2d06570190ec072f118c63916e13c7 Mon Sep 17 00:00:00 2001 From: Julian Elischer Date: Wed, 6 Sep 1995 09:29:19 +0000 Subject: [PATCH] more devfs cleanups.. if this keeps simplifying there won't be any left :) --- sys/miscfs/devfs/devfs_proto.h | 12 ++++++------ sys/miscfs/devfs/devfs_tree.c | 10 +++++++--- sys/miscfs/devfs/devfs_vfsops.c | 15 +++++++++------ sys/miscfs/devfs/devfs_vnops.c | 4 ++-- sys/miscfs/devfs/devfsdefs.h | 10 +++++----- 5 files changed, 29 insertions(+), 22 deletions(-) diff --git a/sys/miscfs/devfs/devfs_proto.h b/sys/miscfs/devfs/devfs_proto.h index 77cd5aca0079..5314b35d1735 100644 --- a/sys/miscfs/devfs/devfs_proto.h +++ b/sys/miscfs/devfs/devfs_proto.h @@ -1,19 +1,19 @@ /* 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*/; +int dev_add_node(char *name, dn_p dirnode,devnm_p back, int entrytype, union typeinfo *by, devnm_p *devnm_pp) /*proto*/; +int dev_remove(devnm_p devnmp) /*proto*/; 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*/; 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*/; +dn_p dev_findname(dn_p dir,char *name) /*proto*/; +int dev_mk_front(dn_p parent, devnm_p back, devnm_p *dnm_pp, struct devfsmount *dvm) /*proto*/; int devfs_make_plane(struct devfsmount *devfs_mp_p) /*proto*/; void devfs_free_plane(struct devfsmount *devfs_mp_p) /*proto*/; -void devfs_remove_fronts(devnm_p devbp) /*proto*/; -void dev_free_front(devnm_p devfp) /*proto*/; +void devfs_remove_fronts(devnm_p devnmp) /*proto*/; +void dev_free_name(devnm_p devnmp) /*proto*/; int devfs_vntodn(struct vnode *vn_p, dn_p *dn_pp) /*proto*/; int devfs_dntovn(dn_p dnp, struct vnode **vn_pp) /*proto*/; int devfs_init(void) /*proto*/; diff --git a/sys/miscfs/devfs/devfs_tree.c b/sys/miscfs/devfs/devfs_tree.c index bb485c9df8f7..753dca0c2317 100644 --- a/sys/miscfs/devfs/devfs_tree.c +++ b/sys/miscfs/devfs/devfs_tree.c @@ -2,7 +2,7 @@ /* * Written by Julian Elischer (julian@DIALix.oz.au) * - * $Header: /home/ncvs/src/sys/miscfs/devfs/devfs_front.c,v 1.5 1995/09/03 08:39:26 julian Exp $ + * $Header: /home/ncvs/src/sys/miscfs/devfs/devfs_tree.c,v 1.1 1995/09/06 08:26:51 julian Exp $ */ #include "param.h" @@ -40,10 +40,13 @@ void devfs_sinit() /*proto*/ * call the right routine at the right time with the right args.... */ retval = dev_add_node("root",NULL,NULL,DEV_DIR,NULL,&dev_root); +#ifdef PARANOID + if(retval) panic("devfs_sinit: dev_add_node failed "); +#endif devfs_hidden_mount = (struct mount *)malloc(sizeof(struct mount), M_MOUNT,M_NOWAIT); #ifdef PARANOID - if(!devfs_hidden_mount) panic("devfs-main-mount: malloc failed"); + if(!devfs_hidden_mount) panic("devfs_sinit: malloc failed"); #endif bzero(devfs_hidden_mount,sizeof(struct mount)); devfs_mount(devfs_hidden_mount,"dummy",NULL,NULL,NULL); @@ -176,7 +179,6 @@ int dev_add_node(char *name, dn_p dirnode,devnm_p back, int entrytype, union typ dnp = dev_findname(dirnode,name); if(dnp) /* if we actually found it.. */ return(EEXIST); - dnp = NULL; /*just want the return code..*/ } /* * make sure the name is legal @@ -291,9 +293,11 @@ int dev_add_node(char *name, dn_p dirnode,devnm_p back, int entrytype, union typ /* inherrit our parent's mount info */ if(dirnode) { dnp->dvm = dirnode->dvm; + if(!dnp->dvm) printf("parent had null dvm "); } } else { dnp = back->dnp; + if(!dnp->dvm) printf("node has null dvm "); } /* diff --git a/sys/miscfs/devfs/devfs_vfsops.c b/sys/miscfs/devfs/devfs_vfsops.c index 7edb6cce8445..4ac67f75d9c3 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.3 1995/05/30 08:06:52 rgrimes Exp $ + * $Header: /home/ncvs/src/sys/miscfs/devfs/devfs_vfsops.c,v 1.4 1995/09/03 05:43:42 julian Exp $ * * */ @@ -70,10 +70,14 @@ DBPRINT(("mount ")); * as best we can with whatever we can think of at the time */ devfs_mp_p = (struct devfsmount *)mp->mnt_data; - copyinstr(path, (caddr_t)mp->mnt_stat.f_mntonname, - sizeof(mp->mnt_stat.f_mntonname)-1, &size); - bzero(mp->mnt_stat.f_mntonname + size, - sizeof(mp->mnt_stat.f_mntonname) - size); + if(devfs_up_and_going) { + copyinstr(path, (caddr_t)mp->mnt_stat.f_mntonname, + sizeof(mp->mnt_stat.f_mntonname)-1, &size); + bzero(mp->mnt_stat.f_mntonname + size, + sizeof(mp->mnt_stat.f_mntonname) - size); + } else { + bcopy("dummy_mount", (caddr_t)mp->mnt_stat.f_mntonname,12); + } bzero(mp->mnt_stat.f_mntfromname , MNAMELEN ); bcopy("devfs",mp->mnt_stat.f_mntfromname, 5); (void)devfs_statfs(mp, &mp->mnt_stat, p); @@ -137,7 +141,6 @@ DBPRINT(("unmount ")); /* return the address of the root vnode in *vpp */ int devfs_root(struct mount *mp, struct vnode **vpp) /*proto*/ { - struct denode *ndep; struct devfsmount *devfs_mp_p = (struct devfsmount *)(mp->mnt_data); DBPRINT(("root ")); diff --git a/sys/miscfs/devfs/devfs_vnops.c b/sys/miscfs/devfs/devfs_vnops.c index 8f00d6a8a95d..dd346b49f30d 100644 --- a/sys/miscfs/devfs/devfs_vnops.c +++ b/sys/miscfs/devfs/devfs_vnops.c @@ -1,7 +1,7 @@ /* * Written by Julian Elischer (julian@DIALix.oz.au) * - * $Header: /home/ncvs/src/sys/miscfs/devfs/devfs_vnops.c,v 1.7 1995/09/02 07:09:01 julian Exp $ + * $Header: /home/ncvs/src/sys/miscfs/devfs/devfs_vnops.c,v 1.8 1995/09/04 00:20:30 dyson Exp $ * * symlinks can wait 'til later. */ @@ -174,7 +174,7 @@ DBPRINT(("errr, maybe not cached ")); heldchar = cnp->cn_nameptr[cnp->cn_namelen]; cnp->cn_nameptr[cnp->cn_namelen] = '\0'; - new_node = dev_findfront(dir_node,cnp->cn_nameptr); + new_node = dev_findname(dir_node,cnp->cn_nameptr); cnp->cn_nameptr[cnp->cn_namelen] = heldchar; if(new_node) { diff --git a/sys/miscfs/devfs/devfsdefs.h b/sys/miscfs/devfs/devfsdefs.h index c6216e208d5c..1a9674560c8b 100644 --- a/sys/miscfs/devfs/devfsdefs.h +++ b/sys/miscfs/devfs/devfsdefs.h @@ -1,3 +1,4 @@ +#define DEVFS_DEBUG 1 #ifdef DEVFS_DEBUG #define DBPRINT(A) printf(A) #else @@ -7,11 +8,13 @@ /* * Written by Julian Elischer (julian@DIALIX.oz.au) * - * $Header: /home/ncvs/src/sys/miscfs/devfs/devfsdefs.h,v 1.3 1995/05/03 23:06:31 julian Exp $ + * $Header: /home/ncvs/src/sys/miscfs/devfs/devfsdefs.h,v 1.4 1995/05/30 08:06:55 rgrimes Exp $ */ /* first a couple of defines for compatibility with inodes */ +#define M_DEVFSNAME M_DEVFSBACK + #define ISUID 04000 /* set user identifier when exec'ing */ #define ISGID 02000 /* set group identifier when exec'ing */ #define ISVTX 01000 /* save execution information on exit */ @@ -132,21 +135,18 @@ struct dev_name union { struct { devnm_p aliases; /* aliase chain (kill with us)*/ - int alias_count; /* # 'alias' nodes for us. */ } back; struct { devnm_p realthing; /* ptr to the backing node */ - devnm_p file_node; /* our file node */ - } front; } as; /*-----------------------the front-back chain-------------*/ devnm_p next_front; /* the linked list of all our front nodes */ devnm_p *prev_frontp; /* the end of the front node chain */ - int frontcount; /* number of front nodes that reference us*/ }; typedef struct dev_name devnm_t; +extern int devfs_up_and_going; extern devnm_p dev_root;