summaryrefslogtreecommitdiff
path: root/lib/libc/gen/devname.c
diff options
context:
space:
mode:
authorPoul-Henning Kamp <phk@FreeBSD.org>2000-09-16 21:58:53 +0000
committerPoul-Henning Kamp <phk@FreeBSD.org>2000-09-16 21:58:53 +0000
commit3cea59524893fcf7cf98909cbcc4f35b067d008d (patch)
tree1a356ac948bc451c1b5524b0aa598db710139740 /lib/libc/gen/devname.c
parenta2cdd9d93e6854da072770e9d7e9b4cefa6bfb13 (diff)
Notes
Diffstat (limited to 'lib/libc/gen/devname.c')
-rw-r--r--lib/libc/gen/devname.c25
1 files changed, 10 insertions, 15 deletions
diff --git a/lib/libc/gen/devname.c b/lib/libc/gen/devname.c
index 7d84037917ac..69c51e3d92d7 100644
--- a/lib/libc/gen/devname.c
+++ b/lib/libc/gen/devname.c
@@ -47,6 +47,7 @@ static char sccsid[] = "@(#)devname.c 8.2 (Berkeley) 4/29/95";
#include <paths.h>
#include <stdio.h>
#include <string.h>
+#include <sys/param.h>
#include <sys/stat.h>
static char *
@@ -63,10 +64,8 @@ xdevname(dev, type)
DBT data, key;
if (!db && !failure &&
- !(db = dbopen(_PATH_DEVDB, O_RDONLY, 0, DB_HASH, NULL))) {
- warn("warning: %s", _PATH_DEVDB);
+ !(db = dbopen(_PATH_DEVDB, O_RDONLY, 0, DB_HASH, NULL)))
failure = 1;
- }
if (failure)
return (NULL);
@@ -88,7 +87,7 @@ devname(dev, type)
dev_t dev;
mode_t type;
{
- static char buf[30]; /* XXX: pick up from <sys/conf.h> */
+ static char buf[SPECNAMELEN + 1];
int i, j;
char *r;
@@ -106,15 +105,11 @@ devname(dev, type)
}
/* Finally just format it */
- 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);
+ if (minor(dev) > 255)
+ r = "#%c:%d:0x%x";
+ else
+ r = "#%c:%d:0x%d";
+ snprintf(buf, SPECNAMELEN + 1, r,
+ (type & S_IFMT) == S_IFCHR ? 'C' : 'B', major(dev), minor(dev));
+ return (buf);
}