DragonFly On-Line Manual Pages

Search: Section:  


DEVNAME(3)            DragonFly Library Functions Manual            DEVNAME(3)

NAME

devname, devname_r, fdevname, fdevname_r -- get device name

LIBRARY

Standard C Library (libc, -lc)

SYNOPSIS

#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);

DESCRIPTION

The devname() and devname_r() 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 fdevname() and fdevname_r() function obtain the device name directly from a file descriptor pointing to a character device. devname() 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.

RETURN VALUES

The devname(), devname_r() and fdevname() functions return a pointer to the name of the block or character device in /dev if successful; other- wise 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.

ERRORS

The fdevname() and fdevname_r() functions may fail and return the follow- ing error codes: [EBADF] The fd is not a valid open file descriptor. [EINVAL] The fd must belong to a character device. The fdevname_r() function may fail and return the following error code: [ERANGE] The len argument is smaller than the length of the string to be returned.

SEE ALSO

stat(2), dev_mkdb(8)

HISTORY

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. DragonFly 3.5 August 11, 2009 DragonFly 3.5

Search: Section: