140966Smarc /* 240966Smarc * Copyright (c) 1989 The Regents of the University of California. 340966Smarc * All rights reserved. 440966Smarc * 542537Sbostic * %sccs.include.redist.c% 640966Smarc */ 740966Smarc 840966Smarc #if defined(LIBC_SCCS) && !defined(lint) 9*46945Sbostic static char sccsid[] = "@(#)devname.c 5.13 (Berkeley) 03/03/91"; 1040966Smarc #endif /* LIBC_SCCS and not lint */ 1140966Smarc 1240258Smarc #include <sys/types.h> 1346325Sbostic #include <fcntl.h> 14*46945Sbostic #include <db.h> 1545158Smarc #include <stdio.h> 1646337Sbostic #include <paths.h> 1740258Smarc 1840258Smarc char * 1946325Sbostic devname(dev) 2040258Smarc dev_t dev; 2140258Smarc { 2246943Sbostic static DB *db; 2346325Sbostic static int failure; 2446943Sbostic DBT data, key; 2540258Smarc 2646943Sbostic if (!db && !failure && 2746943Sbostic !(db = hash_open(_PATH_DEVDB, O_RDONLY, 0, NULL))) { 2846325Sbostic (void)fprintf(stderr, 2946325Sbostic "ps: no device database %s\n", _PATH_DEVDB); 3046325Sbostic failure = 1; 3140258Smarc } 3246325Sbostic if (failure) 3346325Sbostic return("??"); 3440258Smarc 3546943Sbostic key.data = (u_char *)&dev; 3646943Sbostic key.size = sizeof(dev); 3746943Sbostic return((db->get)(db, &key, &data, 0L) ? "??" : (char *)data.data); 3840258Smarc } 39