public inbox for linux-man@vger.kernel.org
 help / color / mirror / Atom feed
* What's the equivalent of readdirat()?
@ 2008-02-18 20:26 Rob Landley
  2008-02-18 22:00 ` Sam Varshavchik
  0 siblings, 1 reply; 2+ messages in thread
From: Rob Landley @ 2008-02-18 20:26 UTC (permalink / raw)
  To: linux-man-u79uwXL29TY76Z2rM5mHXA

I'm moving some code to use openat() and friends, but there doesn't appear to 
be a readdirat().

The problem is that readdir(3) takes a path from cwd.  The syscall readdir(2) 
takes a file descriptor, but the man page for readdir(2) says it was 
supplanted by getdents.  The getdents man page says that's an internal 
syscall that glibc doesn't even bother to _wrap_, and points me back at 
readdir(3) which still takes a path from cwd...

None of the "see also" stuff at the end of any of these pages is useful.

Any hints?

Rob
-- 
"One of my most productive days was throwing away 1000 lines of code."
  - Ken Thompson.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: What's the equivalent of readdirat()?
  2008-02-18 20:26 What's the equivalent of readdirat()? Rob Landley
@ 2008-02-18 22:00 ` Sam Varshavchik
  0 siblings, 0 replies; 2+ messages in thread
From: Sam Varshavchik @ 2008-02-18 22:00 UTC (permalink / raw)
  To: linux-man-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 442 bytes --]

Rob Landley writes:

> I'm moving some code to use openat() and friends, but there doesn't appear to 
> be a readdirat().
> 
> The problem is that readdir(3) takes a path from cwd.

No, it doesn't. readdir() takes an existing DIR pointer, that was previously 
returned by opendir(3).

You will note that the opendir(3) man page also described an alternative 
fdopendir() function, which in conjunction with openat(3) will do what you 
want.


[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-02-18 22:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-18 20:26 What's the equivalent of readdirat()? Rob Landley
2008-02-18 22:00 ` Sam Varshavchik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox