diff options
author | phk <phk@FreeBSD.org> | 2000-09-16 21:58:53 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2000-09-16 21:58:53 +0000 |
commit | 49cc6ddb0f85555bd69dd83b1fa1d0a6d07cffd3 (patch) | |
tree | 7ae490ff1cef71cd85ca16b6e5888f91a7552c15 /lib/libc | |
parent | d61cd51c4f6c6fbb4afb6f7d7bbae060fe2691ce (diff) | |
download | FreeBSD-src-49cc6ddb0f85555bd69dd83b1fa1d0a6d07cffd3.zip FreeBSD-src-49cc6ddb0f85555bd69dd83b1fa1d0a6d07cffd3.tar.gz |
Pickup SPECNAMELEN from <sys/param.h> 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.
Diffstat (limited to 'lib/libc')
-rw-r--r-- | lib/libc/gen/devname.c | 25 |
1 files changed, 10 insertions, 15 deletions
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 <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); } |