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