2 .\" The Regents of the University of California. All rights reserved.
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\" notice, this list of conditions and the following disclaimer.
9 .\" 2. Redistributions in binary form must reproduce the above copyright
10 .\" notice, this list of conditions and the following disclaimer in the
11 .\" documentation and/or other materials provided with the distribution.
12 .\" 3. Neither the name of the University nor the names of its contributors
13 .\" may be used to endorse or promote products derived from this software
14 .\" without specific prior written permission.
16 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
17 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
20 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 .\" @(#)devname.3 8.2 (Berkeley) 4/29/95
29 .\" $FreeBSD: src/lib/libc/gen/devname.3,v 1.7.2.7 2003/03/15 15:11:05 trhodes Exp $
46 .Fn devname "dev_t dev" "mode_t type"
48 .Fn devname_r "dev_t dev" "mode_t type" "char *buf" "size_t len"
52 .Fn fdevname_r "int fd" "char *buf" "size_t len"
58 functions return a pointer to the name of the block or character
61 with a device number of
63 and a file type matching the one encoded in
69 To find the right name,
73 asks the kernel via the
76 If it fails, it will format the information encapsulated in
80 in a human-readable format.
86 function obtain the device name directly from a file descriptor
87 pointing to a character device.
92 returns a pointer to an internal static object; thus, subsequent calls will
93 modify the same buffer.
97 avoid this problem by taking a buffer
108 functions return a pointer to the name of the block or character
111 if successful; otherwise
118 is set to indicate the error.
122 function returns 0 if successful.
123 Otherwise an error number is returned.
125 The following code fragment determines the name of the cloned
127 device that is created by opening
129 .Bd -literal -offset indent
133 fd = open("/dev/tun", O_RDONLY);
135 printf("devname is /dev/%s\en", devname(st.st_rdev, S_IFCHR));
136 printf("fdevname is /dev/%s\en", fdevname(fd));
144 functions may fail and return the following error codes:
149 is not a valid open file descriptor.
153 must belong to a character device.
158 function may fail and return the following error code:
163 argument is smaller than the length of the string to be returned.
182 functions appeared in