man.bsd.lv manual page server

Manual Page Search Parameters
DEVNAME(3) Library Functions Manual DEVNAME(3)

devname, devname_r, fdevname, fdevname_rget device name

library “libc”

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

char *
devname(dev_t dev, mode_t type);

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

char *
fdevname(int fd);

int
fdevname_r(int fd, char *buf, size_t len);

The () and () functions return a pointer to 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. To find the right name, devname() and devname_r() first search the device database created by dev_mkdb(8); if that fails, it will format the information encapsulated in dev and type in a human-readable format.

The () and () function obtain the device name directly from a file descriptor pointing to a character device.

() and fdevname() returns a pointer to an internal static object; thus, subsequent calls will modify the same buffer. devname_r() and fdevname_r() avoid this problem by taking a buffer buf and a buffer length len as arguments.

The devname(), devname_r() and fdevname() functions return a pointer to the name of the block or character device in /dev if successful; otherwise NULL is returned. If fdevname() fails, errno is set to indicate the error.

The fdevname_r() function returns 0 if successful. Otherwise an error number is returned.

The fdevname() and fdevname_r() functions may fail and return the following error codes:

[]
The fd is not a valid open file descriptor.
[]
The fd must belong to a character device.

The fdevname_r() function may fail and return the following error code:

[]
The len argument is smaller than the length of the string to be returned.

stat(2), dev_mkdb(8)

The devname() function appeared in 4.4BSD.

The devname_r() function appeared in DragonFly 1.0 and the fdevname() and fdevname_r() functions appeared in DragonFly 2.3.

August 11, 2009 DragonFly-5.6.1