9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Rstat needs three size fields?
@ 2003-06-30 18:04 Sam
  2003-06-30 19:08 ` ron minnich
  2003-07-04  3:18 ` Russ Cox
  0 siblings, 2 replies; 36+ messages in thread
From: Sam @ 2003-06-30 18:04 UTC (permalink / raw)
  To: 9fans

I'm having some trouble rationalizing the extra
two byte size as documented in stat(5) BUGS.  I
see how having size[2] as part of the stat layout
helps in parsing multiple directory entries
end-to-end in a read(5).  Where I'm stuck is
why it's more consistent to add another one.

If the argument were, ``while we could elide
the size[2] field from the stat layout because
the length of the remainder of the message is known,
we leave it in for consistency with directory reads''
I would understand.

What am I missing here?

Sam






^ permalink raw reply	[flat|nested] 36+ messages in thread
* Re: [9fans] Rstat needs three size fields?
@ 2003-07-01 21:46 boyd, rounin
  0 siblings, 0 replies; 36+ messages in thread
From: boyd, rounin @ 2003-07-01 21:46 UTC (permalink / raw)
  To: 9fans

Sam asked me:

> OK, I've been thinking about this a day now and I'm
> not sure what you mean.  There shouldn't be any partial
> directory entries, right?

in the 'old days' directories had a fixed size [2 byte inode
number + 14 byte name].  so it was easy.  you could cheat
and statically allocate and we mainly did 'cos calling malloc
was a big no-no, 'cos there was next to no memory and cpu
was scarce.

then came along BSD which gave us these lunatic long names
and a namei() that took years to fix.  so you used readdir()
and a chunk of crap because just calling read was now
_too hard_ -- in fact it was illegal.

then we had NFS.  and so you had to ask the server to send
across some number of directory entries [getdents()] and this
sat under readdir().  this was all very fine, but now you
had a bunch of library functions and system calls and NFS
protocol garbage and you couldn't use read() anymore.

in fact _the only place_ the XDR encode/decode code
existed for directory entries was _in the kernel_.  that
stuff was really 'fascinating' ...

    Brushes with death were described as "fascinating."
    To be "absolutely fascinated" meant scared witless.

        -- http://www.air-america.org/Articles/Doole.htm

should you have had ultrix and wanted to write a user-mode NFS
server you had to either get a protocol analyser, tcpdump,
dick around, guess or get hold of the code.

[i wrote an NFS version of ftpfs]

there was never anything wrong with read().  the proliferation of
crap, as a result of BSD long names, added an immense amount
of useless baggage.

should read() return partial directory entries you are in a world of
pain because you have to maintain state so that you can pick up
where you left off and try and glue the partials back together.

so the solution is to just use read() and return whole directory
entries; it simplifies things on both the client and server side.
should read return 0, multiply the malloc()'d buffer by 2, realloc()
and loop.

it helps if you have some side information so that when the read()
returns you have a clue of how much stuff is in the buffer, 'cos
buffer overruns are not your friend.

i suspect the extra size info is 'side information'.



^ permalink raw reply	[flat|nested] 36+ messages in thread
* Re: [9fans] Rstat needs three size fields?
@ 2003-07-02  0:24 boyd, rounin
  0 siblings, 0 replies; 36+ messages in thread
From: boyd, rounin @ 2003-07-02  0:24 UTC (permalink / raw)
  To: 9fans

Sam asked me:
> OK, I've been thinking about this a day now and I'm
> not sure what you mean.  There shouldn't be any partial
> directory entries, right?

in the 'old days' directories had a fixed size [2 byte inode
number + 14 byte name].  so it was easy.  you could cheat
and statically allocate and we mainly did 'cos calling malloc
was a big no-no, 'cos there was next to no memory and cpu
was scarce.

then came along BSD which gave us these lunatic long names
and a namei() that took years to fix.  so you used readdir()
and a chunk of crap because just calling read was now
_too hard_ -- in fact it was illegal.

then we had NFS.  and so you had to ask the server to send
across some number of directory entries [getdents()] and this
sat under readdir().  this was all very fine, but now you
had a bunch of library functions and system calls and NFS
protocol garbage and you couldn't use read() anymore.

in fact _the only place_ the XDR encode/decode code
existed for directory entries was _in the kernel_.  that
stuff was really 'fascinating' ...

    Brushes with death were described as "fascinating."
    To be "absolutely fascinated" meant scared witless.

        -- http://www.air-america.org/Articles/Doole.htm

should you have had ultrix and wanted to write a user-mode NFS
server you had to either get a protocol analyser, tcpdump,
dick around, guess or get hold of the code.

[i wrote an NFS version of ftpfs]

there was never anything wrong with read().  the proliferation of
crap, as a result of BSD long names, added an immense amount
of useless baggage.

should read() return partial directory entries you are in a world of
pain because you have to maintain state so that you can pick up
where you left off and try and glue the partials back together.

so the solution is to just use read() and return whole directory
entries; it simplifies things on both the client and server side.
should read return 0, multiply the malloc()'d buffer by 2, realloc()
and loop.

it helps if you have some side information so that when the read()
returns you have a clue of how much stuff is in the buffer, 'cos
buffer overruns are not your friend.

i suspect the extra size info is 'side information'.



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

end of thread, other threads:[~2003-07-10 12:30 UTC | newest]

Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-06-30 18:04 [9fans] Rstat needs three size fields? Sam
2003-06-30 19:08 ` ron minnich
2003-06-30 19:15   ` boyd, rounin
2003-07-04  3:18 ` Russ Cox
2003-07-04 15:04   ` Sam
2003-07-04 17:13     ` rob pike, esq.
2003-07-07  8:33       ` Douglas A. Gwyn
2003-07-07  9:03         ` Geoff Collyer
2003-07-07 15:10           ` Douglas A. Gwyn
2003-07-08  0:49             ` ron minnich
2003-07-07 15:50           ` rob pike, esq.
2003-07-07 20:38             ` boyd, rounin
2003-07-07 21:18               ` rog
2003-07-07 21:28                 ` boyd, rounin
2003-07-07 23:23                   ` [9fans] simple, sufficient rog
2003-07-07 20:54             ` [9fans] Rstat needs three size fields? Geoff Collyer
2003-07-09  2:07           ` William Josephson
2003-07-07 15:48         ` rob pike, esq.
2003-07-07 15:58           ` Jack Johnson
2003-07-08  8:32           ` Douglas A. Gwyn
2003-07-08 10:30             ` boyd, rounin
2003-07-08 11:09               ` matt
2003-07-08 11:36                 ` Dan Cross
2003-07-08 12:12                   ` boyd, rounin
2003-07-08 14:14                     ` ron minnich
2003-07-08 17:42                 ` chris
2003-07-08 20:19                   ` matt
2003-07-08 20:41                     ` boyd, rounin
2003-07-09 14:58                       ` rog
2003-07-09 19:42                         ` boyd, rounin
2003-07-10 12:30                           ` rog
2003-07-08 22:09                   ` ron minnich
2003-07-08 22:19                     ` Dan Cross
2003-07-09  1:27                       ` ron minnich
2003-07-01 21:46 boyd, rounin
2003-07-02  0:24 boyd, rounin

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).