* [9fans] dirread() and dirreadall()
@ 2005-09-22 22:10 Ronald G Minnich
2005-09-22 22:18 ` Charles Forsyth
0 siblings, 1 reply; 6+ messages in thread
From: Ronald G Minnich @ 2005-09-22 22:10 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
As I read the man page for dirread(), it kind of implies that it returns
an array of entries, and also implies that it returns one dir entry at a
time.
"It [dirread] reads from fd and unpacks the data into an
array of Dir structures whose address is returned in *buf (see stat(3)
for the layout of a Dir)."
but
" by contrast, dirread steps through a directory one read(3) at a time."
Anyways, FWIW, dirread reads in as much as it can, up to a limit of
DIRMAX bytes, and fails if it can not allocate that much; and dirreadall
reads in as much as it can, up to a limit of allocatable memory, and
fails if it can not allocate that much.
For dirreadone(), I think, ya rolls yer own.
apologies if the error here is my inability to parse english.
ron
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [9fans] dirread() and dirreadall()
2005-09-22 22:10 [9fans] dirread() and dirreadall() Ronald G Minnich
@ 2005-09-22 22:18 ` Charles Forsyth
2005-09-22 22:26 ` Ronald G Minnich
0 siblings, 1 reply; 6+ messages in thread
From: Charles Forsyth @ 2005-09-22 22:18 UTC (permalink / raw)
To: 9fans
> As I read the man page for dirread(), it kind of implies that it returns
> an array of entries, and also implies that it returns one dir entry at a
> time.
The data returned by a read(2) on a directory is a set of
complete directory entries ...
`a set'
... by contrast, dirread steps through a directory one
read(2) at a time.
the result of dirread is the result of one read, which might be a set.
... A successful read of a directory always returns an integral number of complete
directory entries; dirread always returns complete Dir structures.
Dirread and dirreadall return the number of Dir structures
filled in buf.
this also suggests the possibility of more than one.
why did you want at most one at a time?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [9fans] dirread() and dirreadall()
2005-09-22 22:18 ` Charles Forsyth
@ 2005-09-22 22:26 ` Ronald G Minnich
2005-09-22 22:33 ` Russ Cox
0 siblings, 1 reply; 6+ messages in thread
From: Ronald G Minnich @ 2005-09-22 22:26 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
Charles Forsyth wrote:
> why did you want at most one at a time?
>
well, it was my inability to parse english, after all.
I'm pulling one at a time since the server code I'm fooling with right
now only returns one at a time. The Req struct in /sys/include/9p.h is a
one-at-a-time struct, near as I can tell:
Dir d;
So I can read lotsa dir entries, but return one at a time via the server
code I'm using. Ah, unless I am not parsing something else correctly ...
I plan to stop doing things this way at some point, but for now I have
other fish to fry. Not to mention, attend some remedial English classes.
ron
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [9fans] dirread() and dirreadall()
2005-09-22 22:26 ` Ronald G Minnich
@ 2005-09-22 22:33 ` Russ Cox
2005-09-22 22:44 ` Ronald G Minnich
2005-09-22 22:49 ` Ronald G Minnich
0 siblings, 2 replies; 6+ messages in thread
From: Russ Cox @ 2005-09-22 22:33 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
> now only returns one at a time. The Req struct in /sys/include/9p.h is a
> one-at-a-time struct, near as I can tell:
>
> Dir d;
That's for stat and wstat. It's not for read.
Read (even read of a directory) uses count and data.
You can use dirread9p to make your life easier.
Filling in d shouldn't work at all! This is all discussed
in 9p(2) in the Read section.
Russ
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [9fans] dirread() and dirreadall()
2005-09-22 22:33 ` Russ Cox
@ 2005-09-22 22:44 ` Ronald G Minnich
2005-09-22 22:49 ` Ronald G Minnich
1 sibling, 0 replies; 6+ messages in thread
From: Ronald G Minnich @ 2005-09-22 22:44 UTC (permalink / raw)
To: Russ Cox, Fans of the OS Plan 9 from Bell Labs
Russ Cox wrote:
> That's for stat and wstat. It's not for read.
> Read (even read of a directory) uses count and data.
> You can use dirread9p to make your life easier.
> Filling in d shouldn't work at all! This is all discussed
> in 9p(2) in the Read section.
thanks, now I remember why I like this list.
ron
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [9fans] dirread() and dirreadall()
2005-09-22 22:33 ` Russ Cox
2005-09-22 22:44 ` Ronald G Minnich
@ 2005-09-22 22:49 ` Ronald G Minnich
1 sibling, 0 replies; 6+ messages in thread
From: Ronald G Minnich @ 2005-09-22 22:49 UTC (permalink / raw)
To: Russ Cox, Fans of the OS Plan 9 from Bell Labs
Russ Cox wrote:
> That's for stat and wstat. It's not for read.
> Read (even read of a directory) uses count and data.
> You can use dirread9p to make your life easier.
> Filling in d shouldn't work at all! This is all discussed
> in 9p(2) in the Read section.
ah, I got it, I am using dirread9p after all, probably incorrectly.
thanks again
ron
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2005-09-22 22:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-09-22 22:10 [9fans] dirread() and dirreadall() Ronald G Minnich
2005-09-22 22:18 ` Charles Forsyth
2005-09-22 22:26 ` Ronald G Minnich
2005-09-22 22:33 ` Russ Cox
2005-09-22 22:44 ` Ronald G Minnich
2005-09-22 22:49 ` Ronald G Minnich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).