diff --git a/lib/libc/gen/devname.c b/lib/libc/gen/devname.c index 39178fec2364..898c8e88d10e 100644 --- a/lib/libc/gen/devname.c +++ b/lib/libc/gen/devname.c @@ -44,9 +44,10 @@ static char sccsid[] = "@(#)devname.c 8.2 (Berkeley) 4/29/95"; #include #include #include +#include -char * -devname(dev, type) +static char * +xdevname(dev, type) dev_t dev; mode_t type; { @@ -78,3 +79,27 @@ devname(dev, type) key.size = sizeof(bkey); return ((db->get)(db, &key, &data, 0) ? NULL : (char *)data.data); } + +char * +devname(dev, type) + dev_t dev; + mode_t type; +{ + static char buf[20]; + char *r; + + r = xdevname(dev, type); + if (!r) { + r = buf; + if (minor(dev) > 255) { + sprintf(buf, "#%c%d:0x%x", + (type & S_IFMT) == S_IFCHR ? 'C' : 'B', + major(dev), minor(dev)); + } else { + sprintf(buf, "#%c%d:%d", + (type & S_IFMT) == S_IFCHR ? 'C' : 'B', + major(dev), minor(dev)); + } + } + return (r); +}