9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] read/write offset hack
@ 2008-05-30 15:15 erik quanstrom
  2008-05-30 15:27 ` roger peppe
  2008-05-30 16:09 ` Russ Cox
  0 siblings, 2 replies; 30+ messages in thread
From: erik quanstrom @ 2008-05-30 15:15 UTC (permalink / raw)
  To: 9fans

> P. P. S.  The usb audio use of offsets is not as bad as it first sounds.
> The device consumes written data at a constant rate (say, 176,400
> bytes per second for CD audio).  You can make a noise ten seconds
> from now by writing 1.7MB bytes of zeros (silence) followed by your
> sound data.  Being able to seek ahead 1.7MB instead just avoids the
> need to write the zeros.  The file offset is still bytes, not nanoseconds.
>

why not put the timing information inband?  this would allow the timed
sound to be saved to a file also without 1.7mb of zeros.

- erik



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

* Re: [9fans] read/write offset hack
  2008-05-30 15:15 [9fans] read/write offset hack erik quanstrom
@ 2008-05-30 15:27 ` roger peppe
  2008-05-30 16:09 ` Russ Cox
  1 sibling, 0 replies; 30+ messages in thread
From: roger peppe @ 2008-05-30 15:27 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Fri, May 30, 2008 at 4:15 PM, erik quanstrom <quanstro@coraid.com> wrote:
> why not put the timing information inband?  this would allow the timed
> sound to be saved to a file also without 1.7mb of zeros.

because then you'd need to quote the audio data in case it
contained something that looked like a timing command?



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

* Re: [9fans] read/write offset hack
  2008-05-30 15:15 [9fans] read/write offset hack erik quanstrom
  2008-05-30 15:27 ` roger peppe
@ 2008-05-30 16:09 ` Russ Cox
  2008-05-30 19:11   ` [9fans] /dev/audio format (was: read/write offset hack) a
  1 sibling, 1 reply; 30+ messages in thread
From: Russ Cox @ 2008-05-30 16:09 UTC (permalink / raw)
  To: 9fans

> why not put the timing information inband?  this would allow the timed
> sound to be saved to a file also without 1.7mb of zeros.

The Plan 9 audio device data format is stereo, 16-bit
little-endian PCM samples.  Given that convention, my
point was only that seeking in that kind of data stream
does make a little bit of sense.  The whole mail was
about the power of working within and respecting
existing conventions, not about redesigning the audio device.

Others might choose different conventions in different situations.
For example, I believe Nemo's Plan B audio device accepts
MP3 format audio to reduce bandwidth requirements for
sending audio to devices elsewhere on the network.
The Plan 9 audio format has the benefit of being close to
the native format for most hardware.

As always, your own context dictates whether or not
breaking established conventions is a good idea.  Of course,
the Sparc /dev/audio is not just a good idea: it's μ-law.

Russ



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

* [9fans] /dev/audio format (was: read/write offset hack)
  2008-05-30 16:09 ` Russ Cox
@ 2008-05-30 19:11   ` a
  2008-05-30 20:02     ` geoff
  0 siblings, 1 reply; 30+ messages in thread
From: a @ 2008-05-30 19:11 UTC (permalink / raw)
  To: 9fans

// The Plan 9 audio device data format is stereo, 16-bit
// little-endian PCM samples.

While I was at the labs, I'm pretty sure we had a /dev/audio that could
take different audio formats (told the format via /dev/audioctl). I can't
remember where it came from, though. Was something like this ever in
Brazil, or was this specific to our group (Mesa; Geoff?)? I believe it was
limited to things like PCM, μ-law, and friends, at different combinations
of stereo, mono, and bitrates, not anthing as complex as mp3.

Mostly just trying to fill in a memory gap.
Anthony




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

* Re: [9fans] /dev/audio format (was: read/write offset hack)
  2008-05-30 19:11   ` [9fans] /dev/audio format (was: read/write offset hack) a
@ 2008-05-30 20:02     ` geoff
  2008-05-30 20:17       ` Charles Forsyth
                         ` (2 more replies)
  0 siblings, 3 replies; 30+ messages in thread
From: geoff @ 2008-05-30 20:02 UTC (permalink / raw)
  To: 9fans

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

The devaudio Anthony remembers was in the Brazil kernel maintained by
the Mesa group and appears to have come from some Inferno BU kernel.
It supported exactly PCM, μ-law and a-law.

The current Inferno audio(3) claims to support "ulaw, alaw, pcm, pcm16
or adpcm".

[-- Attachment #2: Type: message/rfc822, Size: 2334 bytes --]

From: a@9srv.net
To: 9fans@9fans.net
Subject: [9fans] /dev/audio format (was: read/write offset hack)
Date: Fri, 30 May 2008 15:11:35 -0400
Message-ID: <3131a8932bcc91ca2802ea9d02a40c75@9srv.net>

// The Plan 9 audio device data format is stereo, 16-bit
// little-endian PCM samples.

While I was at the labs, I'm pretty sure we had a /dev/audio that could
take different audio formats (told the format via /dev/audioctl). I can't
remember where it came from, though. Was something like this ever in
Brazil, or was this specific to our group (Mesa; Geoff?)? I believe it was
limited to things like PCM, μ-law, and friends, at different combinations
of stereo, mono, and bitrates, not anthing as complex as mp3.

Mostly just trying to fill in a memory gap.
Anthony


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

* Re: [9fans] /dev/audio format (was: read/write offset hack)
  2008-05-30 20:02     ` geoff
@ 2008-05-30 20:17       ` Charles Forsyth
  2008-05-30 22:31       ` erik quanstrom
  2008-05-31  0:53       ` Bruce Ellis
  2 siblings, 0 replies; 30+ messages in thread
From: Charles Forsyth @ 2008-05-30 20:17 UTC (permalink / raw)
  To: 9fans

> The current Inferno audio(3) claims to support "ulaw, alaw, pcm, pcm16
> or adpcm".

if the device supports it.  reading the ctl file reveals available formats.




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

* Re: [9fans] /dev/audio format (was: read/write offset hack)
  2008-05-30 20:02     ` geoff
  2008-05-30 20:17       ` Charles Forsyth
@ 2008-05-30 22:31       ` erik quanstrom
  2008-05-30 22:38         ` andrey mirtchovski
  2008-05-31  0:53       ` Bruce Ellis
  2 siblings, 1 reply; 30+ messages in thread
From: erik quanstrom @ 2008-05-30 22:31 UTC (permalink / raw)
  To: 9fans

> The devaudio Anthony remembers was in the Brazil kernel maintained by
> the Mesa group and appears to have come from some Inferno BU kernel.
> It supported exactly PCM, μ-law and a-law.
>
> The current Inferno audio(3) claims to support "ulaw, alaw, pcm, pcm16
> or adpcm".

a search on "inferno bu" turns up this

	http://cgi.ebay.com/3Racing-Rear-Anti-Roll-Bar-for-Kyosho-Mini-Inferno-BU_W0QQitemZ160244218723QQcmdZViewItem?IMSfp=TL0805280137r6123

does anyone have any ptrs or information about either of the aforementioned?

- erik



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

* Re: [9fans] /dev/audio format (was: read/write offset hack)
  2008-05-30 22:31       ` erik quanstrom
@ 2008-05-30 22:38         ` andrey mirtchovski
  2008-05-30 22:58           ` Skip Tavakkolian
  0 siblings, 1 reply; 30+ messages in thread
From: andrey mirtchovski @ 2008-05-30 22:38 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

BU is the "Business Unit". the reason we're not using Plan 9 and
Inferno instead of Linux and Java ;)



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

* Re: [9fans] /dev/audio format (was: read/write offset hack)
  2008-05-30 22:38         ` andrey mirtchovski
@ 2008-05-30 22:58           ` Skip Tavakkolian
  0 siblings, 0 replies; 30+ messages in thread
From: Skip Tavakkolian @ 2008-05-30 22:58 UTC (permalink / raw)
  To: 9fans

> BU is the "Business Unit". the reason we're not using Plan 9 and
> Inferno instead of Linux and Java ;)

i don't think their marketing really understood what they had.

on the plus side, M$ is embracing and extending the ideas with their
singularity "innovation".  also, windows7 is coming out soon, and
maybe we'll get to windows9 in 4-6 years; one can hope windows9 would
be like plan9 only gui-er.




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

* Re: [9fans] /dev/audio format (was: read/write offset hack)
  2008-05-30 20:02     ` geoff
  2008-05-30 20:17       ` Charles Forsyth
  2008-05-30 22:31       ` erik quanstrom
@ 2008-05-31  0:53       ` Bruce Ellis
  2008-05-31  8:07         ` Charles Forsyth
  2008-06-01 10:02         ` Enrico Weigelt
  2 siblings, 2 replies; 30+ messages in thread
From: Bruce Ellis @ 2008-05-31  0:53 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Correct. There were several generations of audio (and later
multimedia) drivers in both BU Inferno and Research Inferno. e.g. the
Windows driver supports any installed codec.

There was also the Inferno Audio File format which was rather fb like.
The file began with text lines describing the stuff and then after a
\n\n the rest was data. (The drivers didn't know the format, the
player and other tools did.)

An unofficial history of Inferno would be amusing. Maybe it'll be
penned up in a bar at a future IWP9. ericvh was lucky enough to have
been in the /dev/caveman meeting. The "third party fools" era was
entertaining too, though very sad.

brucee

On 5/31/08, geoff@plan9.bell-labs.com <geoff@plan9.bell-labs.com> wrote:
> The devaudio Anthony remembers was in the Brazil kernel maintained by
> the Mesa group and appears to have come from some Inferno BU kernel.
> It supported exactly PCM, μ-law and a-law.

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

* Re: [9fans] /dev/audio format (was: read/write offset hack)
  2008-05-31  8:07         ` Charles Forsyth
@ 2008-05-31  8:05           ` Bruce Ellis
  0 siblings, 0 replies; 30+ messages in thread
From: Bruce Ellis @ 2008-05-31  8:05 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Sorry if you were eating dinner.

On 5/31/08, Charles Forsyth <forsyth@terzarima.net> wrote:
> > The "third party fools" era was
> > entertaining too, though very sad.
>
> don't remind me.



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

* Re: [9fans] /dev/audio format (was: read/write offset hack)
  2008-05-31  0:53       ` Bruce Ellis
@ 2008-05-31  8:07         ` Charles Forsyth
  2008-05-31  8:05           ` Bruce Ellis
  2008-06-01 10:02         ` Enrico Weigelt
  1 sibling, 1 reply; 30+ messages in thread
From: Charles Forsyth @ 2008-05-31  8:07 UTC (permalink / raw)
  To: 9fans

> The "third party fools" era was
> entertaining too, though very sad.

don't remind me.




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

* Re: [9fans] /dev/audio format (was: read/write offset hack)
  2008-05-31  0:53       ` Bruce Ellis
  2008-05-31  8:07         ` Charles Forsyth
@ 2008-06-01 10:02         ` Enrico Weigelt
  2008-06-01 10:10           ` Bruce Ellis
  1 sibling, 1 reply; 30+ messages in thread
From: Enrico Weigelt @ 2008-06-01 10:02 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

* Bruce Ellis <bruce.ellis@gmail.com> wrote:

Hi,

> There was also the Inferno Audio File format which was rather fb
> like.The file began with text lines describing the stuff and then
> after a\n\n the rest was data.

Interesting idea.
We could also use something like HTTP or mail headers - easy to
understand for many people :)

Maybe an advanced audio server could even directly understand
mimetypes ? ,-O

BTW: some weeks ago, I started hacking on an 9P'ed pulseaudio.
It will be configurable completely via 9P and also support
audio I/O via 9P. But I'm still looking for a suitable interface.

The audio interface should be capable of completely replacing
other common interfaces (in GNU world), so eg. understand
all hw-supported formats, realtime-capable, etc.

Once this works, I intend to rewrite certain client libs for
other audio servers (pulse, esd, arts, ...) to go through
that new 9P interface.


Suggestions appreciated :)


cu
--
----------------------------------------------------------------------
 Enrico Weigelt, metux IT service -- http://www.metux.de/

 cellphone: +49 174 7066481   email: info@metux.de   skype: nekrad666
----------------------------------------------------------------------
 Embedded-Linux / Portierung / Opensource-QM / Verteilte Systeme
----------------------------------------------------------------------



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

* Re: [9fans] /dev/audio format (was: read/write offset hack)
  2008-06-01 10:02         ` Enrico Weigelt
@ 2008-06-01 10:10           ` Bruce Ellis
  0 siblings, 0 replies; 30+ messages in thread
From: Bruce Ellis @ 2008-06-01 10:10 UTC (permalink / raw)
  To: weigelt, Fans of the OS Plan 9 from Bell Labs

mime type of x-iaf was used successfully.

On 6/1/08, Enrico Weigelt <weigelt@metux.de> wrote:
> * Bruce Ellis <bruce.ellis@gmail.com> wrote:
>
> Hi,
>
> > There was also the Inferno Audio File format which was rather fb
> > like.The file began with text lines describing the stuff and then
> > after a\n\n the rest was data.
>
> Interesting idea.
> We could also use something like HTTP or mail headers - easy to
> understand for many people :)
>
> Maybe an advanced audio server could even directly understand
> mimetypes ? ,-O
>
> BTW: some weeks ago, I started hacking on an 9P'ed pulseaudio.
> It will be configurable completely via 9P and also support
> audio I/O via 9P. But I'm still looking for a suitable interface.
>
> The audio interface should be capable of completely replacing
> other common interfaces (in GNU world), so eg. understand
> all hw-supported formats, realtime-capable, etc.
>
> Once this works, I intend to rewrite certain client libs for
> other audio servers (pulse, esd, arts, ...) to go through
> that new 9P interface.
>
>
> Suggestions appreciated :)
>
>
> cu
> --
> ----------------------------------------------------------------------
>  Enrico Weigelt, metux IT service -- http://www.metux.de/
>
>  cellphone: +49 174 7066481   email: info@metux.de   skype: nekrad666
> ----------------------------------------------------------------------
>  Embedded-Linux / Portierung / Opensource-QM / Verteilte Systeme
> ----------------------------------------------------------------------
>
>



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

* Re: [9fans] read/write offset hack
  2008-05-30  8:43 Nyang A. Phra
                   ` (3 preceding siblings ...)
  2008-05-30 16:20 ` ron minnich
@ 2008-06-02  8:53 ` Nyang A. Phra
  4 siblings, 0 replies; 30+ messages in thread
From: Nyang A. Phra @ 2008-06-02  8:53 UTC (permalink / raw)
  To: 9fans

On May 30, 6:06 pm, r...@swtch.com (Russ Cox) wrote:
> If you want to violate a convention, Plan 9 won't stop you,
> but in doing so you give up compatibility with programs that
> depend on that convention (bind /net/tcp /proc; ps).
> Sure, you could replace ctl and clone and other special files with reads
> and writes at magic offsets, but in doing so you give up accessing
> those files with standard programs like echo and cat.  For me,
> the main benefit of user-level file servers is exactly that I can
> interact with them from a wide variety of programs, including
> scripts and interactive shell sessions.  I'd need a pretty compelling
> reason before I gave that up.

Thanks Russ for such a thorough and pragmatic response, I'm happy to
have learned something :)

Nyang



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

* Re: [9fans] read/write offset hack
  2008-05-30 19:04   ` a
@ 2008-05-30 19:22     ` Roman Shaposhnik
  0 siblings, 0 replies; 30+ messages in thread
From: Roman Shaposhnik @ 2008-05-30 19:22 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Fri, 2008-05-30 at 15:04 -0400, a@9srv.net wrote:
> Very well explained. I've seen this question come up lots of times
> when introducing fs-based interfaces to people. When we had some
> off-shore devs to bring up to speed, they kept coming back to it: "so
> can we just define a protocol to put all these streams in one file?". I
> tried to explaing that having them as distinct files *was* that
> protocol, but it never stuck. I wish I'd had this explanation then.

I believe that part of the difficulty might come from the fact that
Plan9 is exceptional in a sense that it offers an extremely effective
environment in a basic package. You don't have to devise complicated
GUI "shells" to be productive. Acme is as fancy as it gets.
Unfortunately not everybody is lucky enough to be able to run Plan9
environment. People come from backgrounds of different level of
suckiness. The environments where GUI "shells" are a necessity
(did you know both KDE and GNOME implement incompatible filesystems
at the level of their Explorers?). That's why these folks never trust
their basic environment. They never expect the tools that come with
it to be of any significant use. Their default reasoning is always
to add more "protocols" to the bloated monsters they call "GUI shells".
They just don't know any better.

Thanks,
Roman.




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

* Re: [9fans] read/write offset hack
  2008-05-30 15:01 ` Russ Cox
  2008-05-30 16:50   ` Robert William Fuller
@ 2008-05-30 19:04   ` a
  2008-05-30 19:22     ` Roman Shaposhnik
  1 sibling, 1 reply; 30+ messages in thread
From: a @ 2008-05-30 19:04 UTC (permalink / raw)
  To: 9fans

Very well explained. I've seen this question come up lots of times
when introducing fs-based interfaces to people. When we had some
off-shore devs to bring up to speed, they kept coming back to it: "so
can we just define a protocol to put all these streams in one file?". I
tried to explaing that having them as distinct files *was* that
protocol, but it never stuck. I wish I'd had this explanation then.
Anthony




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

* Re: [9fans] read/write offset hack
  2008-05-30 15:01 ` Russ Cox
@ 2008-05-30 16:50   ` Robert William Fuller
  2008-05-30 19:04   ` a
  1 sibling, 0 replies; 30+ messages in thread
From: Robert William Fuller @ 2008-05-30 16:50 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Russ Cox wrote:

<snip>

> If you want to violate a convention, Plan 9 won't stop you,
> but in doing so you give up compatibility with programs that
> depend on that convention (bind /net/tcp /proc; ps).
> Sure, you could replace ctl and clone and other special files with reads
> and writes at magic offsets, but in doing so you give up accessing
> those files with standard programs like echo and cat.  For me,
> the main benefit of user-level file servers is exactly that I can
> interact with them from a wide variety of programs, including
> scripts and interactive shell sessions.  I'd need a pretty compelling
> reason before I gave that up.

Thank you.  Posts like these are the reason I follow this list, even
though I do not have Plan9 installed!  (I have an interest in operating
system design and a background in filesystems.)




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

* Re: [9fans] read/write offset hack
  2008-05-30  8:43 Nyang A. Phra
                   ` (2 preceding siblings ...)
  2008-05-30 15:01 ` Russ Cox
@ 2008-05-30 16:20 ` ron minnich
  2008-06-02  8:53 ` Nyang A. Phra
  4 siblings, 0 replies; 30+ messages in thread
From: ron minnich @ 2008-05-30 16:20 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Fri, May 30, 2008 at 1:43 AM, Nyang A. Phra <naphra@gmail.com> wrote:
> Poking around Plan 9 and 9P, I was wondering whether it would be a
> neat hack or some sort of abuse to read and write dynamically served
> files at different offsets to get different semantics, instead of
> reading and writing different files (ctl, clone, etc.) to do that.

it's a step backwards in time to very old ideas. And it's a terrible
idea. Heed your spider sense.

Just consider the QID  as your differentiator.

ron



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

* Re: [9fans] read/write offset hack
  2008-05-30 15:35 [9fans] read/write offset hack erik quanstrom
@ 2008-05-30 16:12 ` Stefan Hajnoczi
  0 siblings, 0 replies; 30+ messages in thread
From: Stefan Hajnoczi @ 2008-05-30 16:12 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Excellent, excellent response Russ.  If a question like this comes up
again, your post is a great reference.

Stefan

On Fri, May 30, 2008 at 4:35 PM, erik quanstrom <quanstro@coraid.com> wrote:
>> On Fri, May 30, 2008 at 4:15 PM, erik quanstrom <quanstro@coraid.com> wrote:
>> > why not put the timing information inband?  this would allow the timed
>> > sound to be saved to a file also without 1.7mb of zeros.
>>
>> because then you'd need to quote the audio data in case it
>> contained something that looked like a timing command?
>
> if the size of the chunks is not obvious, say due to compression,
> run-length encoding would solve that problem.
>
> - erik
>
>



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

* Re: [9fans] read/write offset hack
@ 2008-05-30 15:35 erik quanstrom
  2008-05-30 16:12 ` Stefan Hajnoczi
  0 siblings, 1 reply; 30+ messages in thread
From: erik quanstrom @ 2008-05-30 15:35 UTC (permalink / raw)
  To: 9fans

> On Fri, May 30, 2008 at 4:15 PM, erik quanstrom <quanstro@coraid.com> wrote:
> > why not put the timing information inband?  this would allow the timed
> > sound to be saved to a file also without 1.7mb of zeros.
>
> because then you'd need to quote the audio data in case it
> contained something that looked like a timing command?

if the size of the chunks is not obvious, say due to compression,
run-length encoding would solve that problem.

- erik



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

* Re: [9fans] read/write offset hack
  2008-05-30  8:43 Nyang A. Phra
  2008-05-30  9:27 ` Charles Forsyth
  2008-05-30 10:53 ` roger peppe
@ 2008-05-30 15:01 ` Russ Cox
  2008-05-30 16:50   ` Robert William Fuller
  2008-05-30 19:04   ` a
  2008-05-30 16:20 ` ron minnich
  2008-06-02  8:53 ` Nyang A. Phra
  4 siblings, 2 replies; 30+ messages in thread
From: Russ Cox @ 2008-05-30 15:01 UTC (permalink / raw)
  To: 9fans

> Poking around Plan 9 and 9P, I was wondering whether it would be a
> neat hack or some sort of abuse to read and write dynamically served
> files at different offsets to get different semantics, instead of
> reading and writing different files (ctl, clone, etc.) to do that.
>
> Given that the system encourages to perceive files as having arbitrary
> semantics (as opposed to having regular sequential file semantics) it
> would make sense (to me) to have reads and writes at arbitrary offsets
> to have arbitrary semantics as well -- that's, after all, what offset
> (kind of) does on a regular file, too, although in a rather trivial
> way.

The semantics of files on Plan 9 are not as ad hoc as you suggest.

In Unix there is essentially one file server, and thus essentially
one file interface.  (There are of course little differences;
for example, can you cat a directory?)

In Plan 9 there are many different file servers, but there are
relatively few different file interfaces.  The paucity of distinct
interfaces is essential to being able to reuse common tools
across multiple file systems.  Of course, each file server does
implement some special behavior (that's why it exists) but
the most effective ones implement those behaviors in a way
that existing tools continue to work.

A network directory is a special kind of tree, but the
many file servers that provide networks agree on a single
interface.  Programs that dial(3) work just as well with
the kernel-provided /net/tcp, /net/il, and /net/ether0
as they do with drawterm's networks (bind /mnt/term/net/tcp /net/tcp)
or with programs like sshnet.  If every network server used
a different interface, every program that used the network
would have to be changed when a new kind of network
was introduced.  (In Unix they do, and it's very frustrating!)

File servers are of course free to introduce whole new
intrfaces, but they usually do it in a way that simple
programs can continue to use their files.  For example,
even though some network directory files have special
semantics, the /net/xxx/0/data file behaves no different
from a pipe, so that programs that can talk to a pipe can
talk to the network, assuming some other program sets up
the connection.

As another example, upas/fs presents your mail box as a file tree.
The mail readers--nedmail and Mail--are deeply aware of
the structure of the tree, but mail-ignorant programs can
still access the files.  Upas/fs would be much less useful if
	file /mail/fs/mbox/1/2/3/body.jpg
	tar c /mail/fs/mbox/1/2/3/body.jpg >/usr/rsc/jpg.tar
	lp /mail/fs/mbox/1/2/3/body.jpg
	page /mail/fs/mbox/1/2/3/body.jpg
did not work.  (In p9p on Unix they don't, and it's very frustrating!)

File servers sometimes have good reason to buck convention,
but doing so always comes at a cost.  For example, pipes and
network devices cannot provide random access, so they ignore
the file offset in reads and writes; in doing so they become
incompatible with programs that read the data multiple times
(like page in the above examples).  Of course, pipes and networks
are so common, on both Plan 9 and Unix, that many programs
avoid the assumption of random access when possible.

Another common violation is to return a file size of 0 in stat
even though reading the file would produce bytes.  File servers
do this because it is not always simple to compute the size
of dynamically-generated file contents; in doing so, they become
incompatible with programs that depend on the file size being
accurate.  If upas/fs returned a file size of 0 for body.jpg
(it doesn't), then the tar command above would not work
as well, because it needs to write the file size into the tar file
before it copies in the file contents.  (Why can't it seek back?
Because it avoids random access on its output for compatibility
with pipes and networks.)  Not-actually-zero-length files
are so common that many programs, on Plan 9 at least, avoid
the assumption that stat's length matches the length of read.

If you want to violate a convention, Plan 9 won't stop you,
but in doing so you give up compatibility with programs that
depend on that convention (bind /net/tcp /proc; ps).
Sure, you could replace ctl and clone and other special files with reads
and writes at magic offsets, but in doing so you give up accessing
those files with standard programs like echo and cat.  For me,
the main benefit of user-level file servers is exactly that I can
interact with them from a wide variety of programs, including
scripts and interactive shell sessions.  I'd need a pretty compelling
reason before I gave that up.

Russ


P. S.  I'll ignore the fact that you've also replaced the human-friendly
names with human-unfriendly magic numbers.)

P. P. S.  The usb audio use of offsets is not as bad as it first sounds.
The device consumes written data at a constant rate (say, 176,400
bytes per second for CD audio).  You can make a noise ten seconds
from now by writing 1.7MB bytes of zeros (silence) followed by your
sound data.  Being able to seek ahead 1.7MB instead just avoids the
need to write the zeros.  The file offset is still bytes, not nanoseconds.



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

* Re: [9fans] read/write offset hack
  2008-05-30 11:09     ` Nyang A. Phra
@ 2008-05-30 11:28       ` Nick LaForge
  0 siblings, 0 replies; 30+ messages in thread
From: Nick LaForge @ 2008-05-30 11:28 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

>> Nyang: I must say one thing: you are simply going to LOVE an
>> abomination of an acme feature i am working on!
>
> Do let us in on the secret (if you wish) :)
>
>

lets discuss it as soon as i get the code out... watch this space ;)

nkl



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

* Re: [9fans] read/write offset hack
  2008-05-30  9:45   ` Charles Forsyth
  2008-05-30 10:10     ` Nick LaForge
@ 2008-05-30 11:09     ` Nyang A. Phra
  2008-05-30 11:28       ` Nick LaForge
  1 sibling, 1 reply; 30+ messages in thread
From: Nyang A. Phra @ 2008-05-30 11:09 UTC (permalink / raw)
  To: 9fans

> Nyang: I must say one thing: you are simply going to LOVE an
> abomination of an acme feature i am working on!

Do let us in on the secret (if you wish) :)



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

* Re: [9fans] read/write offset hack
  2008-05-30  8:43 Nyang A. Phra
  2008-05-30  9:27 ` Charles Forsyth
@ 2008-05-30 10:53 ` roger peppe
  2008-05-30 15:01 ` Russ Cox
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 30+ messages in thread
From: roger peppe @ 2008-05-30 10:53 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> Given that the system encourages to perceive files as having arbitrary
> semantics (as opposed to having regular sequential file semantics) it
> would make sense (to me) to have reads and writes at arbitrary offsets
> to have arbitrary semantics as well -- that's, after all, what offset
> (kind of) does on a regular file, too, although in a rather trivial
> way.

the nearest i've seen to this (abusing offset semantics)
in the system i've found in the usb device. from usb(3):

: S is the size of the DMA operations on the device (i.e., the
: minimum useful size for reads and writes), b is the number
: of bytes currently buffered for input or output, and o and t
: should be interpreted to mean that byte offset o was/will be
: reached at time t (nanoseconds since the epoch).  The data
: can be used to map file offsets to points in time.  To play
: or record samples exactly at some predetermined time, use o
: and t with the sampling rate to calculate the offset to seek
: to.

this works ok if you're always getting exactly the same number
of bytes per second, but wouldn't if you were streaming variable bit-rate
data.

the advantage of this over using a control file is that there's no
additional latency
or syscall overhead to exactly specifiying a sample time, which could make
a significant difference, i guess, particularly if you were using the device
over a network.

is this an abuse? i'm not sure, though rob pike definitely seemed to think
it was when i mentioned this to him at usenix one time.



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

* Re: [9fans] read/write offset hack
  2008-05-30  9:45   ` Charles Forsyth
@ 2008-05-30 10:10     ` Nick LaForge
  2008-05-30 11:09     ` Nyang A. Phra
  1 sibling, 0 replies; 30+ messages in thread
From: Nick LaForge @ 2008-05-30 10:10 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

>>> we haven't got a task force to rip
>>> keyboards from careless hands

>>this is excellent!

> but Nick LaForge reminds us we can use more effective methods

>       Vercotti: Doug (takes a drink) Well, I was terrified.
>       Everyone was terrified of Doug.  I've seen grown men pull
>       their own heads off rather than see Doug.  Even Dinsdale was
>       frightened of Doug.

>       2nd Interviewer: What did he do?

>       Vercotti: He used...  sarcasm.  He knew all the tricks,
>       dramatic irony, metaphor, bathos, puns, parody, litotes and...
>       satire.  He was vicious.

my apologies. :)

Nyang: I must say one thing: you are simply going to LOVE an
abomination of an acme feature i am working on!



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

* Re: [9fans] read/write offset hack
  2008-05-30  9:27 ` Charles Forsyth
  2008-05-30  9:32   ` Nick LaForge
@ 2008-05-30  9:45   ` Charles Forsyth
  2008-05-30 10:10     ` Nick LaForge
  2008-05-30 11:09     ` Nyang A. Phra
  1 sibling, 2 replies; 30+ messages in thread
From: Charles Forsyth @ 2008-05-30  9:45 UTC (permalink / raw)
  To: 9fans

>> we haven't got a task force to rip
>> keyboards from careless hands

>this is excellent!

but Nick LaForge reminds us we can use more effective methods

	Vercotti: Doug (takes a drink) Well, I was terrified.
	Everyone was terrified of Doug.  I've seen grown men pull
	their own heads off rather than see Doug.  Even Dinsdale was
	frightened of Doug.

	2nd Interviewer: What did he do?

	Vercotti: He used...  sarcasm.  He knew all the tricks,
	dramatic irony, metaphor, bathos, puns, parody, litotes and...
	satire.  He was vicious.




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

* Re: [9fans] read/write offset hack
  2008-05-30  9:27 ` Charles Forsyth
@ 2008-05-30  9:32   ` Nick LaForge
  2008-05-30  9:45   ` Charles Forsyth
  1 sibling, 0 replies; 30+ messages in thread
From: Nick LaForge @ 2008-05-30  9:32 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> Poking around Plan 9 and 9P, I was wondering whether it would be a
> neat hack or some sort of abuse to read and write dynamically served
> files at different offsets to get different semantics, instead of
> reading and writing different files (ctl, clone, etc.) to do that.

> Given that the system encourages to perceive files as having arbitrary
> semantics (as opposed to having regular sequential file semantics) it
> would make sense (to me) to have reads and writes at arbitrary offsets
> to have arbitrary semantics as well -- that's, after all, what offset
> (kind of) does on a regular file, too, although in a rather trivial
> way.

> ...but my spider-sense is telling me this would probably be either
> rather pointless, or troublesome, or prohibited. Please set me
> straight.

this is excellent!  The only thing you need now is a new name to mark
the address of the new block, a mechanism to seek to this address,
and an interface to standard I/O such that writes append to the block's
end.

nkl



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

* Re: [9fans] read/write offset hack
  2008-05-30  8:43 Nyang A. Phra
@ 2008-05-30  9:27 ` Charles Forsyth
  2008-05-30  9:32   ` Nick LaForge
  2008-05-30  9:45   ` Charles Forsyth
  2008-05-30 10:53 ` roger peppe
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 30+ messages in thread
From: Charles Forsyth @ 2008-05-30  9:27 UTC (permalink / raw)
  To: 9fans

> ...but my spider-sense is telling me this would probably be either
> rather pointless, or troublesome, or prohibited. Please set me
> straight.

well, of those, it can't be prohibited, because we haven't got a task force to rip
keyboards from careless hands, although given the system's background,
alien abduction is always a possibility.

i suppose i don't see the point, so i'd go with the first one.




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

* [9fans] read/write offset hack
@ 2008-05-30  8:43 Nyang A. Phra
  2008-05-30  9:27 ` Charles Forsyth
                   ` (4 more replies)
  0 siblings, 5 replies; 30+ messages in thread
From: Nyang A. Phra @ 2008-05-30  8:43 UTC (permalink / raw)
  To: 9fans

Poking around Plan 9 and 9P, I was wondering whether it would be a
neat hack or some sort of abuse to read and write dynamically served
files at different offsets to get different semantics, instead of
reading and writing different files (ctl, clone, etc.) to do that.

Given that the system encourages to perceive files as having arbitrary
semantics (as opposed to having regular sequential file semantics) it
would make sense (to me) to have reads and writes at arbitrary offsets
to have arbitrary semantics as well -- that's, after all, what offset
(kind of) does on a regular file, too, although in a rather trivial
way.

...but my spider-sense is telling me this would probably be either
rather pointless, or troublesome, or prohibited. Please set me
straight.

Nyang



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

end of thread, other threads:[~2008-06-02  8:53 UTC | newest]

Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-05-30 15:15 [9fans] read/write offset hack erik quanstrom
2008-05-30 15:27 ` roger peppe
2008-05-30 16:09 ` Russ Cox
2008-05-30 19:11   ` [9fans] /dev/audio format (was: read/write offset hack) a
2008-05-30 20:02     ` geoff
2008-05-30 20:17       ` Charles Forsyth
2008-05-30 22:31       ` erik quanstrom
2008-05-30 22:38         ` andrey mirtchovski
2008-05-30 22:58           ` Skip Tavakkolian
2008-05-31  0:53       ` Bruce Ellis
2008-05-31  8:07         ` Charles Forsyth
2008-05-31  8:05           ` Bruce Ellis
2008-06-01 10:02         ` Enrico Weigelt
2008-06-01 10:10           ` Bruce Ellis
  -- strict thread matches above, loose matches on Subject: below --
2008-05-30 15:35 [9fans] read/write offset hack erik quanstrom
2008-05-30 16:12 ` Stefan Hajnoczi
2008-05-30  8:43 Nyang A. Phra
2008-05-30  9:27 ` Charles Forsyth
2008-05-30  9:32   ` Nick LaForge
2008-05-30  9:45   ` Charles Forsyth
2008-05-30 10:10     ` Nick LaForge
2008-05-30 11:09     ` Nyang A. Phra
2008-05-30 11:28       ` Nick LaForge
2008-05-30 10:53 ` roger peppe
2008-05-30 15:01 ` Russ Cox
2008-05-30 16:50   ` Robert William Fuller
2008-05-30 19:04   ` a
2008-05-30 19:22     ` Roman Shaposhnik
2008-05-30 16:20 ` ron minnich
2008-06-02  8:53 ` Nyang A. Phra

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