| Main index | Section 3 | Options |
#include <sys/stat.h>
#include <stdlib.h>
The fdevname() and fdevname_r() function obtains the device name directly from a file descriptor pointing to a character device. If it is unable to come up with a suitable name, these functions will return a NULL pointer.
devname() and fdevname() return the name stored in a static buffer which will be overwritten on subsequent calls. devname_r() and fdevname_r() take a buffer and length as argument to avoid this problem.
int fd; struct stat buf; char *name;fd = open("/dev/tun"); fstat(fd, &buf); printf("devname is /dev/%s\n", devname(buf.st_rdev, S_IFCHR)); printf("fdevname is /dev/%s\n", fdevname(fd));
| DEVNAME (3) | February 22, 2005 |
| Main index | Section 3 | Options |
Please direct any comments about this manual page service to Ben Bullock. Privacy policy.
| “ | A typical Unix /bin or /usr/bin directory contains a hundred different kinds of programs, written by dozens of egotistical programmers, each with its own syntax, operating paradigm, rules of use ... strategies for specifying options, and different sets of constraints. | ” |
| — The Unix Haters' handbook | ||