man.bsd.lv manual page server

Manual Page Search Parameters

DEVNAME(3) Library Functions Manual DEVNAME(3)

devname, devname_rget device name

library “libc”

#include <stdlib.h>
#include <sys/stat.h>

char *
devname(dev_t dev, mode_t type);

int
devname_r(dev_t dev, mode_t type, char *path, size_t len);

The () function returns a pointer to the static buffer with the name of the block or character device in “/dev” with a device number of dev, and a file type matching the one encoded in type which must be one of S_IFBLK or S_IFCHR. If no device matches the specified values, or no information is available, NULL is returned.

The () function is a reentrant and thread-safe version of devname(). This function returns the device name by copying it into the path argument with up to len characters. The path argument is always nul-terminated.

The traditional display for applications when no device is found is the string “??”.

If successful, devname() returns a pointer to a nul-terminated string containing the name of the device. If an error occurs devname will return NULL.

If successful, devname_r() places a nul-terminated string containing the name of the device in the buffer pointed to by path and returns 0. If an error occurs devname_r() will return an error number from <sys/errno.h> indicating what went wrong.

/var/run/dev.cdb
Device database file.

The devname_r() function may fail if:

[]
The corresponding device does not exist.
[]
The passed buffer length is too short.

stat(2), dev_mkdb(8)

The devname function call appeared in 4.4BSD.

The devname_r() function first appeared in NetBSD 6.0.

September 9, 2017 NetBSD-9.2