devnm(3)devnm(3)NAMEdevnm - map device ID to file path
Given a device type, a device ID, and a string in which to return the
result, maps the type and ID to a block or character special file
(device file) name by searching It returns in path the full path name
of the first special file encountered with a matching device type and
ID. It searches and all its subdirectories recursively in unspecified
The parameters are:
devtype One of the file type values or documented in stat(5).
Bits other than those in the set are ignored. Hence
the value can be, for example, an value returned by
devid A device ID (the combined major and minor numbers)
such as returned by in the or field.
path Pointer to the buffer in which to return the path name
pathlen Tells the available length of the path string, includ‐
ing the NUL terminator character. If path is too
short to hold the full path name, only the first
pathlen−1 characters are returned in a null-terminated
string, and the return value is altered (see below).
cache A flag that tells whether to save file information in
memory allocated by and later, whether to use that
saved information instead of searching again. How‐
ever, an attempt to refresh the saved information will
be made if the cache appears stale or if the file is
not found. A subsequent call with cache non-zero can
be much faster, especially if is a large tree, pro‐
vided the saved information is not refreshed. How‐
ever, the first call with cache true might be slower
because must read all of the tree once to create the
cache, rather than returning immediately upon finding
a matching file. Any call with cache set to zero
ignores the cache, if any, and reads the directory.
To allow for possible future enhancements, cache
should be restricted to the values 0 and 1.
There is no way to tell to free its cached memory.
ignores unreadable directories and files for which fails.
returns one of the following values:
The result is in path.
failed. contains the value returned from path might be altered
if cache is set. If cache was set for the first time,
freed any memory allocated by the current call.
No matching special file was found.
is undefined. path is unaltered.
A matching special file was found,
but the name was truncated to fit in path. is unde‐
If fails, silently abandons the attempt to do caching in the current or
any later call with cache true, and frees any memory allocated by the
was created by HP.
SEE ALSOdevnm(1M), stat(2), ftw(3C), malloc(3C), ttyname(3C), stat(5),