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*46325Sbostic static char sccsid[] = "@(#)devname.c 5.9 (Berkeley) 02/08/91"; 1040966Smarc #endif /* LIBC_SCCS and not lint */ 1140966Smarc 1240258Smarc #include <sys/types.h> 13*46325Sbostic #include <fcntl.h> 14*46325Sbostic #include <ndbm.h> 1545158Smarc #include <stdio.h> 16*46325Sbostic #include "pathnames.h" 1740258Smarc 1840258Smarc char * 19*46325Sbostic devname(dev) 2040258Smarc dev_t dev; 2140258Smarc { 22*46325Sbostic static DBM *db; 23*46325Sbostic static int failure; 24*46325Sbostic datum dp, key; 2540258Smarc 26*46325Sbostic if (!db && !(db = dbm_open(_PATH_DEVDB, O_RDONLY, 0))) { 27*46325Sbostic (void)fprintf(stderr, 28*46325Sbostic "ps: no device database %s\n", _PATH_DEVDB); 29*46325Sbostic failure = 1; 3040258Smarc } 31*46325Sbostic if (failure) 32*46325Sbostic return("??"); 3340258Smarc 34*46325Sbostic key.dptr = (char *)&dev; 35*46325Sbostic key.dsize = sizeof(dev); 36*46325Sbostic dp = dbm_fetch(db, key); 37*46325Sbostic return(dp.dptr ? dp.dptr : "??"); 3840258Smarc } 39