]>
Commit | Line | Data |
---|---|---|
a1eaacb1 | 1 | '\" t |
fea681da MK |
2 | .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) |
3 | .\" | |
5fbde956 | 4 | .\" SPDX-License-Identifier: Linux-man-pages-copyleft |
fea681da MK |
5 | .\" |
6 | .\" References consulted: | |
7 | .\" Linux libc source code | |
8 | .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) | |
9 | .\" 386BSD man pages | |
10 | .\" Modified Sat Jul 24 17:48:42 1993 by Rik Faith (faith@cs.unc.edu) | |
4c1c5274 | 11 | .TH telldir 3 (date) "Linux man-pages (unreleased)" |
fea681da MK |
12 | .SH NAME |
13 | telldir \- return current location in directory stream | |
715858f5 AC |
14 | .SH LIBRARY |
15 | Standard C library | |
8fc3b2cf | 16 | .RI ( libc ", " \-lc ) |
fea681da MK |
17 | .SH SYNOPSIS |
18 | .nf | |
19 | .B #include <dirent.h> | |
68e4db0a | 20 | .PP |
48e39fa7 | 21 | .BI "long telldir(DIR *" dirp ); |
fea681da | 22 | .fi |
68e4db0a | 23 | .PP |
d39ad78f | 24 | .RS -4 |
cc4615cc MK |
25 | Feature Test Macro Requirements for glibc (see |
26 | .BR feature_test_macros (7)): | |
d39ad78f | 27 | .RE |
68e4db0a | 28 | .PP |
cc4615cc | 29 | .BR telldir (): |
9d281e06 MK |
30 | .nf |
31 | _XOPEN_SOURCE | |
75c018a1 AC |
32 | || /* glibc >= 2.19: */ _DEFAULT_SOURCE |
33 | || /* glibc <= 2.19: */ _BSD_SOURCE || _SVID_SOURCE | |
9d281e06 | 34 | .fi |
fea681da | 35 | .SH DESCRIPTION |
60a90ecd MK |
36 | The |
37 | .BR telldir () | |
38 | function returns the current location associated with | |
6dea120e | 39 | the directory stream \fIdirp\fP. |
47297adb | 40 | .SH RETURN VALUE |
60a90ecd MK |
41 | On success, the |
42 | .BR telldir () | |
43 | function returns the current location | |
cca657e2 MK |
44 | in the directory stream. |
45 | On error, \-1 is returned, and | |
46 | .I errno | |
f6a4078b | 47 | is set to indicate the error. |
fea681da MK |
48 | .SH ERRORS |
49 | .TP | |
50 | .B EBADF | |
6dea120e | 51 | Invalid directory stream descriptor \fIdirp\fP. |
f7dbb1ea | 52 | .SH ATTRIBUTES |
a257b544 PH |
53 | For an explanation of the terms used in this section, see |
54 | .BR attributes (7). | |
55 | .TS | |
56 | allbox; | |
c466875e | 57 | lbx lb lb |
a257b544 PH |
58 | l l l. |
59 | Interface Attribute Value | |
60 | T{ | |
9e54434e BR |
61 | .na |
62 | .nh | |
f7dbb1ea | 63 | .BR telldir () |
a257b544 PH |
64 | T} Thread safety MT-Safe |
65 | .TE | |
c466875e | 66 | .sp 1 |
3113c7f3 | 67 | .SH STANDARDS |
4131356c AC |
68 | POSIX.1-2008. |
69 | .SH HISTORY | |
70 | POSIX.1-2001, 4.3BSD. | |
71 | .PP | |
b324e17d | 72 | Up to glibc 2.1.1, the return type of |
48e39fa7 MK |
73 | .BR telldir () |
74 | was | |
75 | .IR off_t . | |
76 | POSIX.1-2001 specifies | |
77 | .IR long , | |
78 | and this is the type used since glibc 2.1.2. | |
847e0d88 | 79 | .PP |
9ee4a2b6 | 80 | In early filesystems, the value returned by |
73f4bf1e MK |
81 | .BR telldir () |
82 | was a simple file offset within a directory. | |
9ee4a2b6 | 83 | Modern filesystems use tree or hash structures, rather than flat tables, |
73f4bf1e | 84 | to represent directories. |
9ee4a2b6 | 85 | On such filesystems, the value returned by |
73f4bf1e MK |
86 | .BR telldir () |
87 | (and used internally by | |
88 | .BR readdir (3)) | |
89 | is a "cookie" that is used by the implementation | |
90 | to derive a position within a directory. | |
91 | .\" https://lwn.net/Articles/544298/ | |
92 | Application programs should treat this strictly as an opaque value, making | |
93 | .I no | |
94 | assumptions about its contents. | |
47297adb | 95 | .SH SEE ALSO |
fea681da MK |
96 | .BR closedir (3), |
97 | .BR opendir (3), | |
98 | .BR readdir (3), | |
99 | .BR rewinddir (3), | |
100 | .BR scandir (3), | |
101 | .BR seekdir (3) |