From 49cc6ddb0f85555bd69dd83b1fa1d0a6d07cffd3 Mon Sep 17 00:00:00 2001 From: phk Date: Sat, 16 Sep 2000 21:58:53 +0000 Subject: Pickup SPECNAMELEN from and use it. A missing _PATH_DEVDB ("/var/run/dev.db") is not cause for a warning anymore, the file is effectively optional these days. --- lib/libc/gen/devname.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'lib') diff --git a/lib/libc/gen/devname.c b/lib/libc/gen/devname.c index 7d84037..69c51e3 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 #include #include +#include #include 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 */ + 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); } -- cgit v1.1