Make devname(3) return something more intelligent than NULL if it doesn't
find anything in the database.
This commit is contained in:
parent
43d5ccb239
commit
9d4ee2f2ef
@ -44,9 +44,10 @@ static char sccsid[] = "@(#)devname.c 8.2 (Berkeley) 4/29/95";
|
||||
#include <paths.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user