diff options
| author | Julian Elischer <julian@FreeBSD.org> | 1995-12-09 09:11:25 +0000 |
|---|---|---|
| committer | Julian Elischer <julian@FreeBSD.org> | 1995-12-09 09:11:25 +0000 |
| commit | 4d92e19833832c97168f61a5f39d9b4da951bbee (patch) | |
| tree | 34f9b606ff29b54150992119d72901fdf34ff07b /sys/miscfs/devfs | |
| parent | d88800474555a7cfa9facdbee2f48da6004268ca (diff) | |
Notes
Diffstat (limited to 'sys/miscfs/devfs')
| -rw-r--r-- | sys/miscfs/devfs/devfs_proto.h | 2 | ||||
| -rw-r--r-- | sys/miscfs/devfs/devfs_tree.c | 107 |
2 files changed, 16 insertions, 93 deletions
diff --git a/sys/miscfs/devfs/devfs_proto.h b/sys/miscfs/devfs/devfs_proto.h index 01dd194f13ab..e8571e8e8d19 100644 --- a/sys/miscfs/devfs/devfs_proto.h +++ b/sys/miscfs/devfs/devfs_proto.h @@ -14,8 +14,6 @@ int dev_dup_entry(dn_p parent, devnm_p back, devnm_p *dnm_pp, struct devfsmount 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 get_cdev_major_num(caddr_t addr) /*proto*/; -int get_bdev_major_num(caddr_t addr) /*proto*/; int dev_add_entry(char *name, dn_p parent, int type, union typeinfo *by, devnm_p *nm_pp) /*proto*/ ; int devfs_init(void) /*proto*/; int devfs_mount( struct mount *mp, char *path, caddr_t data, struct nameidata *ndp, struct proc *p) /*proto*/; diff --git a/sys/miscfs/devfs/devfs_tree.c b/sys/miscfs/devfs/devfs_tree.c index 6f3232249146..746305e566b9 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_tree.c,v 1.9 1995/11/29 10:48:36 julian Exp $ + * $Header: /u1/ncvs/src/sys/miscfs/devfs/devfs_tree.c,v 1.10 1995/12/08 11:17:33 julian Exp $ */ #include "param.h" @@ -134,7 +134,19 @@ int dev_finddir(char *orig_path, dn_p dirnode, int create, dn_p *dn_pp) /*proto* path = pathbuf; strcpy(path,orig_path); - while(*path == '/') path++; /* always absolute, skip leading / */ + /***************************************\ + * always absolute, skip leading / * + * get rid of / or // or /// etc. * + \***************************************/ + while(*path == '/') path++; + /***************************************\ + * If nothing left, then parent was it.. * + \***************************************/ + if ( *path == '\0' ) { + *dn_pp = dirnode; + return 0; + } + /***************************************\ * find the next segment of the name * \***************************************/ @@ -143,6 +155,7 @@ int dev_finddir(char *orig_path, dn_p dirnode, int create, dn_p *dn_pp) /*proto* { cp++; } + /***********************************************\ * Check to see if it's the last component * \***********************************************/ @@ -838,48 +851,7 @@ DBPRINT(("(New vnode)")); } /***********************************************************************\ -* UTILITY routine: * -* Return the major number for the cdevsw entry containing the given * -* address. * -\***********************************************************************/ -int get_cdev_major_num(caddr_t addr) /*proto*/ -{ - int index = 0; - - DBPRINT(("get_cdev_major_num\n")); - while (index < nchrdev) - { - if(((caddr_t)(cdevsw[index].d_open) == addr) - ||((caddr_t)(cdevsw[index].d_read) == addr) - ||((caddr_t)(cdevsw[index].d_ioctl) == addr)) - { - return index; - } - index++; - } - return -1; -} - -int get_bdev_major_num(caddr_t addr) /*proto*/ -{ - int index = 0; - - DBPRINT(("get_bdev_major_num\n")); - while (index < nblkdev) - { - if(((caddr_t)(bdevsw[index].d_open) == addr) - ||((caddr_t)(bdevsw[index].d_strategy) == addr) - ||((caddr_t)(bdevsw[index].d_ioctl) == addr)) - { - return index; - } - index++; - } - return -1; -} - -/***********************************************************************\ -* add a whole device, with not prototype.. make name element and node * +* add a whole device, with no prototype.. make name element and node * \***********************************************************************/ int dev_add_entry(char *name, dn_p parent, int type, union typeinfo *by, devnm_p *nm_pp) /*proto*/ { @@ -957,53 +929,6 @@ void *devfs_add_devsw(char *path, /***********************************************************************\ * Add the named device entry into the given directory, and make it * -* The appropriate type... (called (sometimes indirectly) by drivers..) * -\***********************************************************************/ -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 */ - int retval; - int major ; - union typeinfo by; - - DBPRINT(("dev_add\n")); - retval = dev_finddir(path,NULL,1,&dnp); - if (retval) return 0; - switch(chrblk) - { - case DV_CHR: - major = get_cdev_major_num(funct); - by.Cdev.cdevsw = cdevsw + major; - by.Cdev.dev = makedev(major, minor); - if( dev_add_entry(name, dnp, DEV_CDEV, &by,&new_dev)) - return NULL; - break; - case DV_BLK: - major = get_bdev_major_num(funct); - by.Bdev.bdevsw = bdevsw + major; - by.Bdev.dev = makedev(major, minor); - if( dev_add_entry(name, dnp, DEV_BDEV, &by, &new_dev)) - return NULL; - break; - default: - return NULL; - } - new_dev->dnp->gid = gid; - new_dev->dnp->uid = uid; - new_dev->dnp->mode |= perms; - return new_dev; -} - -/***********************************************************************\ -* Add the named device entry into the given directory, and make it * * a link to the already created device given as an arg.. * \***********************************************************************/ void *dev_link(char *path, char *name, void *original) |
