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.
“ | You have successfully logged in, Now press any key to log out | ” |