diff options
author | scrappy <scrappy@FreeBSD.org> | 1996-03-28 14:32:27 +0000 |
---|---|---|
committer | scrappy <scrappy@FreeBSD.org> | 1996-03-28 14:32:27 +0000 |
commit | 745bb4c905709976ab384f4b85c1564cb2a78513 (patch) | |
tree | 50caeb4c4774343d58abe5f34b1d63eb22f2b035 /sys/miscfs | |
parent | 85dc41d2a0bf4b66009df220e45b05172b70a077 (diff) | |
download | FreeBSD-src-745bb4c905709976ab384f4b85c1564cb2a78513.zip FreeBSD-src-745bb4c905709976ab384f4b85c1564cb2a78513.tar.gz |
Added dev_linkf() function (dev_link() + printf-style arguments)
Reviewed by: julian@freebsd.org
Diffstat (limited to 'sys/miscfs')
-rw-r--r-- | sys/miscfs/devfs/devfs_tree.c | 55 |
1 files changed, 54 insertions, 1 deletions
diff --git a/sys/miscfs/devfs/devfs_tree.c b/sys/miscfs/devfs/devfs_tree.c index a425f87..62ad9b6 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.18 1996/02/18 07:29:53 julian Exp $ + * $Header: /home/ncvs/src/sys/miscfs/devfs/devfs_tree.c,v 1.19 1996/03/25 21:56:59 julian Exp $ */ #include "param.h" @@ -1017,3 +1017,56 @@ void *dev_link(char *path, char *name, void *original) 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.. * +* this function is exported.. see sys/devfsext.h * +\***********************************************************************/ +void *dev_linkf(void *original, char *fmt, ...) +{ + devnm_p new_dev; + devnm_p orig = (devnm_p) original; + dn_p dirnode; /* devnode for parent directory */ + int retval; + int major ; + union typeinfo by; + + va_list ap; + char *p, buf[256]; /* XXX */ + int i; + + va_start(ap, fmt); + i = kvprintf(fmt, NULL, (void*)buf, 32, ap); + va_end(ap); + buf[i] = '\0'; + p = NULL; + + for(i=strlen(buf); i>0; i--) + if(buf[i] == '/') { + p=&buf[i]; + buf[i]=0; + break; + } + + DBPRINT(("dev_add\n")); + + /* + * The DEV_CDEV below is not used other than it must NOT be DEV_DIR + * the correctness of original shuold be checked.. + */ + + if (p) { + *p++ = '\0'; + retval = dev_finddir(buf,NULL,1,&dirnode); + if (retval) return 0; + if( dev_add_name(p, dirnode, NULL, orig->dnp, &new_dev)) + return NULL; + } else { + retval = dev_finddir("/",NULL,1,&dirnode); + if (retval) return 0; + if( dev_add_name(buf, dirnode, NULL, orig->dnp, &new_dev)) + return NULL; + } + return new_dev; +} + |