devnm(3) Library Functions Manual devnm(3)
devnm - 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 order.
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 (see stat(2)).
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 result.
pathlen Tells the available length of the path string, including 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. However, 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,
provided the saved information is not refreshed. However, 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 mem-
ory 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 undefined.
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 current call.
was created by HP.
devnm(1M), stat(2), ftw(3C), malloc(3C), ttyname(3C), stat(5), thread_safety(5).