9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] Re: Solaris thread scheaduling
@ 2000-08-18 15:34 rob pike
       [not found] ` <rob@plan9.bell-labs.com>
  0 siblings, 1 reply; 185+ messages in thread
From: rob pike @ 2000-08-18 15:34 UTC (permalink / raw)
  To: 9fans

What, we should use uncooperative threads?
Adversarial threads? Anarchic threads?

I guess I don't know the terminology.  If POSIX threads
are a good thing, perhaps I don't want to know what they're
better than.

-rob



^ permalink raw reply	[flat|nested] 185+ messages in thread
* [9fans] Getting started in Plan9 - help
@ 2002-01-20 20:02 Roshan James
  2002-01-20 21:01 ` Matt H
                   ` (3 more replies)
  0 siblings, 4 replies; 185+ messages in thread
From: Roshan James @ 2002-01-20 20:02 UTC (permalink / raw)
  To: 9fans

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

Getting started in Plan9
-------------------------    
Its been a little over a week since i got my Plan9 working and 
I still seem to be in tourist mode.Lots of questions and 
a few suggestions:
(I promise I have tried to answer these for myself before
before I am ask them)

It would be great if we have a school boy style step-by-step 
getting-off-the-ground tour of plan9, maybe somewhere in the
wiki. I would be glad to do this, if i knew enough.

Graphics
-----------
- I am working with an S3 Trio 64v2 card, the install floppy
gave me 800*600 res,but after installation i am on 640*480 and
i cant seem to be able to change it
aux/vga -l 800x600x8
gives me
'Warning (BUG) : redefinition of aperture does not change 
s3screen segment.'
in a black background in the sentre of the screen and an error
message that reads 
'aux/vga: vgactlw: <size 800x600x8 m8>: vga already configured'
in the console window. it is a low end card but I believe that 
I did have a higher res through the boot disk so it should be 
possible here too. how can i change to a higher res ?

- If plan9 is booted through xosl in 640*480 res,plan9 graphics
display ends up corrupt. the bootloader does switch to text mode
before the OS is booted. anyother resolution or a text mode boot
loader does not seem to have a problem. 
The right quarter of the screen (approx) seems to be a duplicate
of the band of the screen display between in the left part. (bad
description i know). Anyway to fix this ?


Acessibility
-------------
- How can I read a couple of html docs in Plan9 ?
- Is there a place where the uses of directories the std file system
heirarchy is discussed, esp /n ? 
- /n/c: exists, how can i access the extended partitions ?
- How can i access the floppy a: ? /n/a: exists but shows no files.
- How can i access the extended windows partitions ? 
- Problem with accessing C: File operations to /n/c: causes a problem
'%mkdir /n/c:/testdir'
'mkdir: cant create /n/c:/testdir: write to hungup channel'
also a black background error message comes (is there a generic name
for these messages ?)
'dossrv 45: suicide: sys: trap fault read addr=0xb pc=0x00004757'
help ?

Shell
------ 
- How can I find/search for a file in Plan9 ? the usual find /|grep xxx 
does not exist here, what is the equivalent ?
- Why doesnt/Can rc have autocomplete and filename completion as in 
bash ? This has become so neccessary.

Keys
-----
- Why cant the left/right arrow keys+home+end keys move the cursor,
it is really difficult to edit something by placing the cursor there
with the mouse. 
- Unless is it part of a grander plan (no pun intended), can we move 
the process interrupt key from Del to something else and have the 
conventional functionality of del back ?

General
-------
- Is the option of plan9 default boot in bootsetup (during install)
safe for other OSes that exist on the system ?
- Why arent there more applications and more developers interested
in developing for plan9 ? 

Russ, I think it would kill you to keep answering all the newbie 
questions. Russ, Imel, Thanks for all the help you have been. I 
think the Plan9 faq needs updation with some of the more generic 
questions here. This is a lesson that could learned from the Win32's, 
if you want the OS to grow, you have to get people comfortable with 
it very fast. I think we can make that happen.

Rosh.

-------------------------------------------------------------------------------------
One Ring to rule them all, One Ring to find them,
One Ring to bring them all and in the darkness bind them.
(Lord of the Rings)

[-- Attachment #2: Type: text/html, Size: 4834 bytes --]

^ permalink raw reply	[flat|nested] 185+ messages in thread
* Re: [9fans] Virtual memory in BSD and Plan9
@ 2001-10-25 17:55 Russ Cox
  2001-10-25 18:29 ` William Josephson
  0 siblings, 1 reply; 185+ messages in thread
From: Russ Cox @ 2001-10-25 17:55 UTC (permalink / raw)
  To: 9fans

	Could you please recommend me a reading on both architectures to
	understand differences between them. I read here that BSD paging has
	some drawbacks to AT&T one (used in Plan9). And I want to make this
	clear for myself.

The discussions here were talking about many-years-old
systems.  I don't think anyone even mentioned Plan 9's VM system,
which is just about the simplest thing you could imagine.
The BSDs have oodles more ``features.''  I'd look in
www.researchindex.com for the latest stuff, and in McKusick et al.
(Design and Implementation of the 4.4BSD OS) for older stuff.
You can decide for yourself whether Plan 9 needs any of it.

Russ



^ permalink raw reply	[flat|nested] 185+ messages in thread
* Re: [9fans] architectures
@ 2001-07-12  8:42 forsyth
  2001-07-12 13:56 ` Laura Creighton
  2001-07-12 16:13 ` Ozan Yigit
  0 siblings, 2 replies; 185+ messages in thread
From: forsyth @ 2001-07-12  8:42 UTC (permalink / raw)
  To: 9fans

>>i'm particularly fond of the acme interface, and i really
>>like the chording (okay, maybe it's not for everyone, but _i_
>>really like it). i'm asking about non-techie folks. for them,
>>wouldn't a single-button interface be simpler to understand?

not necessarily, since the functionality of the extra buttons
must be provided somehow, whether by menus, pop-up menus,
key-mouse combinations, keys alone, or some other way.  much might
depend on the choice of conventions for using more than one button.
that in acme all three buttons select text is a big simplification.
i usually introduce it as follows: ``button 1 selects text, button 2
selects text, and button 3 ...'' and during the following pause
nearly everyone says ``selects text?''.  i then explain
that `of course' each button does different things with
the text selected.  that seems fine.  the chording for cut/paste/copy
takes a little practice, but since it has a `feel' much like grabbing
text from the screen, that also seems fine.   outside acme,
the Blit convention (perhaps adopted from Smalltalk, i don't know)
was something like: button 1 generally selected things, button 2 provided local
operations (usually on the thing selected), and button 3 provided global operations
for the application, with a few exceptions such as paint programs.
most menus were kept fairly small.

i know at least one non- technical user of acme who sends and receives
mail, plumbing photos and other things, and editing quite happily.
other non-technical people i've shown it to wanted to use acme on
their machines for document preparation and email because the
organisation into columns and frames and the use of the buttons was
just so much more effective than their `desktop' or a clutter of
windows.  (they also like the soft use of colour.)
contrary to Tog's advice on this point: with care i suspect
you can make abstractions simple and effective enough without insisting on
drawing a tenuous likeness to something in the `real world'.



^ permalink raw reply	[flat|nested] 185+ messages in thread
* [9fans] bitsy question
@ 2001-06-26 16:33 John Packer
  2001-06-26 17:10 ` [9fans] " Dan Cross
  0 siblings, 1 reply; 185+ messages in thread
From: John Packer @ 2001-06-26 16:33 UTC (permalink / raw)
  To: 9fans

I have Plan9 installed on my ipaq, but I don't have a pcmcia sleeve,
or wavelan on my network.

So I have been trying to link the bitsy to my terminal using ppp over
the 
serial port. (I made a ramdisk with ip/ppp).

PPP tries to authenticate for 30 seconds (through chap, I think) then
times out.


I've tried running ppp a few different ways, but something like
	
	ip/ppp -df -b 115200 -p /dev/eia0 -s $user:$secret 135.104.99.5

on the bitsy and something like
	
	ip/ppp -dfS -b 115200 -p /dev/eia0 135.104.99.1

on the server.

Has anyone tried this? What am I doing wrong?

Thanks, 

John


^ permalink raw reply	[flat|nested] 185+ messages in thread
[parent not found: <matt@proweb.co.uk>]
[parent not found: <vikki@proweb.co.uk>]
* Re: [9fans] could those of you who have students check this out for
@ 2001-06-09 17:22 forsyth
  2001-06-09 18:50 ` [9fans] Re: the 'science' in computer science andrey mirtchovski
  0 siblings, 1 reply; 185+ messages in thread
From: forsyth @ 2001-06-09 17:22 UTC (permalink / raw)
  To: 9fans

>>our computer science department has strong roots in algorithmics.

that might be true, but do the students, in the main, write programs
except those they are required to do for assessments and projects?



^ permalink raw reply	[flat|nested] 185+ messages in thread
* Re: [9fans] new versions of graphics programs?
@ 2000-09-07 21:57 rob pike
  2000-09-07 22:50 ` Jim Choate
  0 siblings, 1 reply; 185+ messages in thread
From: rob pike @ 2000-09-07 21:57 UTC (permalink / raw)
  To: 9fans

I started on a couple of the tools.  Since the PIC format is
now largely irrelevant - the standard image format captures
much of its capabilities - it seemed worth retiring the fb
software.  Retiring it also helped keep the distribution smaller
and easier to assemble.  But clearly, some of the tools in 
fb/ are worth having.

I worked on a couple of the tools and stumbled into original
bugs that I didn't see how to fix, so that project has stalled.
The shipped gif and jpg tools and the iconv program should
address some of the lower-level needs.  Higher-level
image processing is a project for a dedicated soul; it's a big
job.

-rob




^ permalink raw reply	[flat|nested] 185+ messages in thread
* Re: [9fans] pipefile
@ 2000-08-03 23:46 okamoto
  0 siblings, 0 replies; 185+ messages in thread
From: okamoto @ 2000-08-03 23:46 UTC (permalink / raw)
  To: 9fans

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

I'm very happy to hear it.  

Yesterday, I went out from our Univ. after that success, because 
I was too happy to continue to sit down on the chair.  ☺

However, this is the success of Rob's idea not mine.

Kenji


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

From: "Matt" <matt@proweb.co.uk>
To: <9fans@cse.psu.edu>
Subject: Re: [9fans] pipefile
Date: Thu, 3 Aug 2000 08:14:27 +0100
Message-ID: <009301bffd1a$7a022080$02a7b6c3@lucid.proweb.net>

> これは初めて release 3 Plan 9 + pipefile + acme + my version of ktrans
を使って書いているテスト
> メールです。日本語を読めない皆さまには御免なさい
> です。
>
> This is the first Japanese mail written under
> the release 3 Plan 9 + pipefile + acme + my
> version of ktrans.  Please forgive me if you
> don't want to read Japanese.
>
> Kenji

congratulations on your success

I *do* want to read japanese I just can't

it's not your fault

Matt


^ permalink raw reply	[flat|nested] 185+ messages in thread
* Re: [9fans] pipefile
@ 2000-08-03  4:49 rob pike
  0 siblings, 0 replies; 185+ messages in thread
From: rob pike @ 2000-08-03  4:49 UTC (permalink / raw)
  To: 9fans

> >Could one stack pipefiles?
> No...

Why not?

% pipefile -w 'tr a-z A-Z' /dev/cons
% pipefile -w 'tr A-J 0-9' /dev/cons
% rc < /dev/cons > /dev/cons >[2] /dev/cons
% date
THU 0UG  3 00:48:13 43T 2000
% 




^ permalink raw reply	[flat|nested] 185+ messages in thread
* Re: [9fans] pipefile
@ 2000-08-03  4:15 okamoto
  0 siblings, 0 replies; 185+ messages in thread
From: okamoto @ 2000-08-03  4:15 UTC (permalink / raw)
  To: 9fans

>/dev/kbd may seem more natural, but the idea that an arbitrary

Now I believe pipfile method is superior, because we can input
Japanese onto any window anytime.

>Pipefile may not be as convenient, 

Now, I believe it's not inconvenient.

>but it's much safer because you
>must explicitly create the process; there's nothing like /dev/kbd
>hanging around ready to receive random characters.

I still have problem to understand this.  In Plan 9, all the /dev
files are owned by hostowner which means s/he has superior
permission to key input anything.  I feel this is natural...

Kenji



^ permalink raw reply	[flat|nested] 185+ messages in thread
* Re: [9fans] pipefile
@ 2000-08-03  3:44 okamoto
  2000-08-03  7:14 ` Matt
  0 siblings, 1 reply; 185+ messages in thread
From: okamoto @ 2000-08-03  3:44 UTC (permalink / raw)
  To: 9fans

これは初めて release 3 Plan 9 + pipefile + acme + my version of ktrans を使って書いているテスト
メールです。日本語を読めない皆さまには御免なさい
です。

This is the first Japanese mail written under
the release 3 Plan 9 + pipefile + acme + my 
version of ktrans.  Please forgive me if you 
don't want to read Japanese.

Kenji


^ permalink raw reply	[flat|nested] 185+ messages in thread
* Re: [9fans] pipefile
@ 2000-08-03  3:19 okamoto
  0 siblings, 0 replies; 185+ messages in thread
From: okamoto @ 2000-08-03  3:19 UTC (permalink / raw)
  To: 9fans

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

This problem has been solved completely through discussions
between Russ.

Now I can input Japanese on this new plan 9 release.
Thank you very much Russ.

Kenji


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

[-- Attachment #2.1.1: Type: text/plain, Size: 685 bytes --]

I'm using my version of ktrans to test this, where we can change
language.  Yes, this is true.  My point is that:

> When I input Japanese like below:
> 
> term% 日本語の入力の練習です。<cr>

I wanted to input Japanese text as a false command for rc shell, 
and then I expect shell will return with no such command etc. by 
hiiting Enter key.   However, it's still in raw mode, and I have no 
clue to return back to cooked mode, and recognize the meaning 
of newline.

Actually, I was also confused this nature of Enter key to newline 
conversion, whence my version had a serious bug for conversion 
from kana to kanji after hitting Enter key...

Kenji


[-- Attachment #2.1.2: Type: message/rfc822, Size: 3148 bytes --]

From: "James A. Robinson" <jim.robinson@stanford.edu>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] pipefile
Date: Wed, 02 Aug 2000 08:49:40 -0700
Message-ID: <200008021549.LAA27375@cse.psu.edu>


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2.1.2.1: Type: text/plain; charset="x-unknown", Size: 664 bytes --]

From: "James A. Robinson" <jim.robinson@stanford.edu>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] pipefile
Date: Wed, 02 Aug 2000 08:49:40 -0700
Message-ID: <200008021549.LAA27375@cse.psu.edu>

I think he was thinking of the v2 edition where, with ktrans, you
could hit a ctrl seq and switch into different modes.  I assume that
functionality was always part of ktrans itself, in other words after it's
started it is always running and handles whether or not to do translation.


> > When I input Japanese like below:
> > 
> > term% 日本語の入力の練習です。<cr>
> > 
> > 
> > I cannot now return to rc shell.
> 
> I don't understand.  Do you want just to enter one line of Japanese text?
> The idea was to switch the mode of /dev/cons permanently. I assumed
> your Japanese input methods could provide both ASCII and Japanese text.

^ permalink raw reply	[flat|nested] 185+ messages in thread
* Re: [9fans] pipefile
@ 2000-08-03  0:19 okamoto
  0 siblings, 0 replies; 185+ messages in thread
From: okamoto @ 2000-08-03  0:19 UTC (permalink / raw)
  To: 9fans

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

I'm using my version of ktrans to test this, where we can change
language.  Yes, this is true.  My point is that:

> When I input Japanese like below:
> 
> term% 日本語の入力の練習です。<cr>

I wanted to input Japanese text as a false command for rc shell, 
and then I expect shell will return with no such command etc. by 
hiiting Enter key.   However, it's still in raw mode, and I have no 
clue to return back to cooked mode, and recognize the meaning 
of newline.

Actually, I was also confused this nature of Enter key to newline 
conversion, whence my version had a serious bug for conversion 
from kana to kanji after hitting Enter key...

Kenji


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

From: "James A. Robinson" <jim.robinson@stanford.edu>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] pipefile
Date: Wed, 02 Aug 2000 08:49:40 -0700
Message-ID: <200008021549.LAA27375@cse.psu.edu>


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2.1: Type: text/plain; charset="x-unknown", Size: 664 bytes --]

From: "James A. Robinson" <jim.robinson@stanford.edu>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] pipefile
Date: Wed, 02 Aug 2000 08:49:40 -0700
Message-ID: <200008021549.LAA27375@cse.psu.edu>

I think he was thinking of the v2 edition where, with ktrans, you
could hit a ctrl seq and switch into different modes.  I assume that
functionality was always part of ktrans itself, in other words after it's
started it is always running and handles whether or not to do translation.


> > When I input Japanese like below:
> > 
> > term% 日本語の入力の練習です。<cr>
> > 
> > 
> > I cannot now return to rc shell.
> 
> I don't understand.  Do you want just to enter one line of Japanese text?
> The idea was to switch the mode of /dev/cons permanently. I assumed
> your Japanese input methods could provide both ASCII and Japanese text.

^ permalink raw reply	[flat|nested] 185+ messages in thread
* Re: [9fans] pipefile
@ 2000-08-02 21:19 rob pike
  0 siblings, 0 replies; 185+ messages in thread
From: rob pike @ 2000-08-02 21:19 UTC (permalink / raw)
  To: 9fans

> I think he was thinking of the v2 edition where, with ktrans, you
> could hit a ctrl seq and switch into different modes.  I assume that
> functionality was always part of ktrans itself, in other words after it's
> started it is always running and handles whether or not to do translation.

I thought the problem was not how to implement the translation, but
how to inject it into the input stream.  Thus I wrote pipefile, with
the belief that someone would write the obvious bytestream converter,
with or without modes, that would convert a standard keyboard into
some other style of input.

With pipefile, you can add any translation you want to /dev/cons.
The program you write - the argument to -r - can do anything it
wants, including switching between languages.  Unlike with /dev/kbd,
the mode won't be per window if you start it under rio, but you can
start it in each window instead, if that's really what you want.

/dev/kbd may seem more natural, but the idea that an arbitrary
program can wake up at any time and inject characters into my
input stream is too distasteful for me.  That's why I didn't put
/dev/kbd into rio, hoping something better (or at least safer)
would come along.

Pipefile may not be as convenient, but it's much safer because you
must explicitly create the process; there's nothing like /dev/kbd
hanging around ready to receive random characters.

-rob



^ permalink raw reply	[flat|nested] 185+ messages in thread
* Re: [9fans] pipefile
@ 2000-08-02  7:55 okamoto
  2000-08-03  8:21 ` Boyd Roberts
  0 siblings, 1 reply; 185+ messages in thread
From: okamoto @ 2000-08-02  7:55 UTC (permalink / raw)
  To: 9fans

>As I said in the beginning, this trick is suitable for continuous
>files such as devices

I was confused in my earlier mail, because I had no EARGF definition
on my libc.h.  Now, I got the new update, and it works now what you
intended (probably).

Then, now I'm wondering rightly☺ how I can end the input, and 
return to shell prompt, when I hit return key on rio environment.  
Yes, I have read rio sources, but it's beyond my ability.  My only 
understand on this is to send nil length font length to the frame of
the window of rio....  I know this procedure is simple, and works 
under acme, too.

When I input Japanese like below:

term% 日本語の入力の練習です。<cr>


I cannot now return to rc shell.

Kenji



^ permalink raw reply	[flat|nested] 185+ messages in thread
* Re: [9fans] pipefile
@ 2000-07-31  9:47 okamoto
  0 siblings, 0 replies; 185+ messages in thread
From: okamoto @ 2000-07-31  9:47 UTC (permalink / raw)
  To: 9fans

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


However, I don't know how to off the pipe buffer.

Kenji


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

From: "rob pike" <rob@plan9.bell-labs.com>
To: 9fans@cse.psu.edu
Subject: Re: [9fans] pipefile
Date: Mon, 31 Jul 2000 00:55:29 -0400
Message-ID: <200007310455.AAA06403@cse.psu.edu>

> What you can do, if you want to change the mode of /dev/cons 
> itself before piped to readcmd?  I'm imaging to pipe to the raw 
> mode input of /dev/cons.

It doesn't affect /dev/consctl.  You can set raw mode independently.

-rob

^ permalink raw reply	[flat|nested] 185+ messages in thread
* Re: [9fans] pipefile
@ 2000-07-31  4:55 rob pike
  0 siblings, 0 replies; 185+ messages in thread
From: rob pike @ 2000-07-31  4:55 UTC (permalink / raw)
  To: 9fans

> What you can do, if you want to change the mode of /dev/cons 
> itself before piped to readcmd?  I'm imaging to pipe to the raw 
> mode input of /dev/cons.

It doesn't affect /dev/consctl.  You can set raw mode independently.

-rob



^ permalink raw reply	[flat|nested] 185+ messages in thread
* Re: [9fans] pipefile
@ 2000-07-31  4:40 okamoto
  0 siblings, 0 replies; 185+ messages in thread
From: okamoto @ 2000-07-31  4:40 UTC (permalink / raw)
  To: 9fans

Interesting.

>	</dev/cons readcmd | rc | writecmd >/dev/cons

What you can do, if you want to change the mode of /dev/cons 
itself before piped to readcmd?  I'm imaging to pipe to the raw 
mode input of /dev/cons.

Kenji



^ permalink raw reply	[flat|nested] 185+ messages in thread
* Re: [9fans] pipefile
@ 2000-07-31  1:14 rob pike
  2000-08-02  3:40 ` Skip Tavakkolian
  0 siblings, 1 reply; 185+ messages in thread
From: rob pike @ 2000-07-31  1:14 UTC (permalink / raw)
  To: 9fans

> If you don't mind, could you also say a word as to what made the
> /dev/cons case special?  Who was writing to /dev/cons all of the 
> keyboard input so that it worked? (rio?)

/dev/cons is connected to standard in and standard out, that's all.
I stupidly had file descriptors 0 and 1 wired into the code.
Nobody was writing any keyboard input of any kind to /dev/cons.

What pipefile does is place filters between the file and
any subsequent program that opens it for i/o, by binding a pipe
onto the file and then connecting the filters to the pipe.  The other
end of the pipe is connected to the underlying file.

Normally you have, in effect,

	</dev/cons  rc   >/dev/cons

but after

	pipefile -r 'readcmd' -w 'writecmd' /dev/cons
	rc < /dev/cons >/dev/cons

you have, almost literally,

	</dev/cons readcmd | rc | writecmd >/dev/cons

(The only difference is that it uses one full duplex pipe instead
of two half duplex ones.)

What was special about /dev/cons was that I had this
example in mind when I wrote the program, so what
it actually did was closer to

	</fd/0 readcmd | rc | writecmd >/fd/1

The fix was to open the file explicitly.

Hope that helps.

-rob



^ permalink raw reply	[flat|nested] 185+ messages in thread
* Re: [9fans] pipefile
@ 2000-07-30 23:46 Steve Harris
  0 siblings, 0 replies; 185+ messages in thread
From: Steve Harris @ 2000-07-30 23:46 UTC (permalink / raw)
  To: 9fans

On Sun, 30 Jul 2000 18:17:32 rob pike wrote:

> Here's a version that doesn't implicitly assume /dev/cons.

If you don't mind, could you also say a word as to what made the
/dev/cons case special?  Who was writing to /dev/cons all of the 
keyboard input so that it worked? (rio?)




^ permalink raw reply	[flat|nested] 185+ messages in thread
* Re: [9fans] pipefile
@ 2000-07-30 23:17 rob pike
  0 siblings, 0 replies; 185+ messages in thread
From: rob pike @ 2000-07-30 23:17 UTC (permalink / raw)
  To: 9fans

Here's a version that doesn't implicitly assume /dev/cons.
I dropped the -b option because it was too hard to make work.
It's a lot shorter as a result; perhaps it could even be a shell
script.

-rob

#include <u.h>
#include <libc.h>

#define	TEMP	"/n/temp"

void
usage(void)
{
	fprint(2, "usage: pipefile [-r command] [-w command] file\n");
	exits("usage");
}

void
connect(char *cmd, int fd0, int fd1)
{
	switch(rfork(RFPROC|RFFDG|RFREND|RFNOWAIT)){
	case -1:
		sysfatal("fork %s: %r", cmd);
		break;
	default:
		return;
	case 0:
		if(fd0 != 0)
			dup(fd0, 0);
		if(fd1 != 1)
			dup(fd1, 1);
		execl("/bin/rc", "rc", "-c", cmd, nil);
		sysfatal("exec %s: %r", cmd);
		break;
	}
}

void
main(int argc, char *argv[])
{
	char *file;
	char *rcmd, *wcmd;
	int fd0, fd1, ifd0, ifd1;

	rcmd = wcmd = nil;
	ARGBEGIN{
	case 'r':
		rcmd = EARGF(usage());
		break;
	case 'w':
		wcmd = EARGF(usage());
		break;
	default:
		usage();
	}ARGEND

	if(argc!=1 || (rcmd==nil && wcmd==nil))
		usage();
	if(rcmd == nil)
		rcmd = "/bin/cat";
	if(wcmd == nil)
		wcmd = "/bin/cat";

	file = argv[0];
	ifd0 = open(file, OREAD);
	if(ifd0 < 0)
		sysfatal("open %s: %r", file);
	ifd1 = open(file, OWRITE);
	if(ifd1 < 0)
		sysfatal("open %s: %r", file);

	if(bind("#|", TEMP, MREPL) < 0)
		sysfatal("bind pipe %s: %r", TEMP);
	if(bind(TEMP "/data", file, MREPL) < 0)
		sysfatal("bind %s %s: %r", TEMP "/data", file);

	fd0 = open(TEMP "/data1", OREAD);
	if(fd0 < 0)
		sysfatal("open %s: %r", TEMP "/data1");
	connect(wcmd, fd0, ifd1);
	fd1 = open(TEMP "/data1", OWRITE);
	if(fd1 < 0)
		sysfatal("open %s: %r", TEMP "/data1");
	connect(rcmd, ifd0, fd1);
	unmount(nil, TEMP);
	exits(nil);
}



^ permalink raw reply	[flat|nested] 185+ messages in thread
* Re: [9fans] pipefile
@ 2000-07-30 23:06 rob pike
  0 siblings, 0 replies; 185+ messages in thread
From: rob pike @ 2000-07-30 23:06 UTC (permalink / raw)
  To: 9fans

> I'm trying to understand this, but I can't figure out how the original 
> file is actually read/written by this code.  

You're right.  I was thinking too far ahead and the code assumes you
were dealing with /dev/cons; hence the duping of fd's 0 and 1 in the
calls to connect.  Dumb. 

I'll send a fix in a while.

-rob




^ permalink raw reply	[flat|nested] 185+ messages in thread
* Re: [9fans] pipefile
@ 2000-07-30 22:38 Steve Harris
  0 siblings, 0 replies; 185+ messages in thread
From: Steve Harris @ 2000-07-30 22:38 UTC (permalink / raw)
  To: 9fans

On Sun, 30 Jul 2000 14:54:30 rob pike wrote:

> The command is called pipefile; it interposes a command
> between you and the named file.  ...

I'm trying to understand this, but I can't figure out how the original 
file is actually read/written by this code.  

I think I'm misunderstanding, but it looks to me like the code produces 
a 
"closed loop" of two pipes with the filter command in between, with one 
side 
"data" bound over and replacing the original file (I'm with it so far I 
think).
But I don't see how the other side of the pipe, "data1", is connected at 
all 
with the contents of the original file ( before it had the 
 	bind(TEMP "/data", file, MREPL) 
done over it ). In fact I don't see how you can access the original file 

contents at all after the bind() call above has been done in the 
namespace.

Or do we not care about the original file at all?  Does rio make 
keyboard
input available for reading through /dev/cons even if we've bound 
something 
over the original file with MREPL?


What am I missing?

Here's the section I don't understand:

> 	file = argv[0];
> 	if(bind("#|", TEMP, MREPL) < 0)
> 		sysfatal("bind pipe %s: %r", TEMP);
> 	if(bind(TEMP "/data", file, MREPL) < 0)
> 		sysfatal("bind %s %s: %r", TEMP "/data", file);
> 
> 	if(bcmd != nil){
> 		fd0 = open(TEMP "/data1", ORDWR);
> 		if(fd0 < 0)
> 			sysfatal("open %s: %r", TEMP "/data1");
> 		connect(bcmd, fd0, fd0);
> 		close(fd0);
> 	}else{
> 		fd0 = open(TEMP "/data1", OREAD);
> 		if(fd0 < 0)
> 			sysfatal("open %s: %r", TEMP "/data1");
> 		connect(wcmd, fd0, 1);
> 		fd1 = open(TEMP "/data1", OWRITE);
> 		if(fd1 < 0)
> 			sysfatal("open %s: %r", TEMP "/data1");
> 		connect(rcmd, 0, fd1);
> 		close(fd0);
> 		close(fd1);
> 	}
> 	unmount(nil, TEMP);
> 	exits(nil);
> }
> 






^ permalink raw reply	[flat|nested] 185+ messages in thread
* [9fans] pipefile
@ 2000-07-30 19:54 rob pike
  0 siblings, 0 replies; 185+ messages in thread
From: rob pike @ 2000-07-30 19:54 UTC (permalink / raw)
  To: 9fans

I had an idea while trying to kill groundhogs today.
The command is called pipefile; it interposes a command
between you and the named file.  Options -r and -w
specify a command to interpose when reading or writing;
-b does both, but in that case the command must handle
bidirectional input; most standard commands such as
cat won't work.
Try this:

	pipefile -w 'tr a-z A-Z' /dev/cons
	rc -i < /dev/cons > /dev/cons >[2] /dev/cons

for a shell reminiscent of olden times.  The origin of the
idea was a way to support Asian input. Consider

	pipefile -r 'tr a-z A-Z' /dev/cons
	rio < /dev/cons > /dev/cons >[2] /dev/cons

I leave the rest to the interested Asian reader.

The command leaves the file in an odd state, and can only
work well on continuous files such as devices or with very
special commands interposed, but I offer it as an interesting
idea.

-rob


#include <u.h>
#include <libc.h>

#define	TEMP	"/n/temp"

void
usage(void)
{
	fprint(2, "usage: pipefile [-r command] [-w command] [-b command] file\n");
	exits("usage");
}

void
connect(char *cmd, int fd0, int fd1)
{
	switch(rfork(RFPROC|RFFDG|RFREND|RFNOWAIT)){
	case -1:
		sysfatal("fork %s: %r", cmd);
		break;
	default:
		return;
	case 0:
		if(fd0 != 0)
			dup(fd0, 0);
		if(fd1 != 1)
			dup(fd1, 1);
		execl("/bin/rc", "rc", "-c", cmd, nil);
		sysfatal("exec %s: %r", cmd);
		break;
	}
}

void
main(int argc, char *argv[])
{
	char *file;
	char *rcmd, *wcmd, *bcmd;
	int fd0, fd1;

	rcmd = wcmd = bcmd = nil;
	ARGBEGIN{
	case 'r':
		if(bcmd != nil)
			usage();
		rcmd = EARGF(usage());
		break;
	case 'w':
		if(bcmd != nil)
			usage();
		wcmd = EARGF(usage());
		break;
	case 'b':
		if(rcmd!=nil || wcmd!=nil)
			usage();
		bcmd = EARGF(usage());
		break;
	default:
		usage();
	}ARGEND

	if(argc!=1 || (rcmd==nil && wcmd==nil && bcmd==nil))
		usage();
	if(rcmd==nil && wcmd!=nil)
		rcmd = "/bin/cat";
	if(wcmd==nil && rcmd!=nil)
		wcmd = "/bin/cat";

	file = argv[0];
	if(bind("#|", TEMP, MREPL) < 0)
		sysfatal("bind pipe %s: %r", TEMP);
	if(bind(TEMP "/data", file, MREPL) < 0)
		sysfatal("bind %s %s: %r", TEMP "/data", file);

	if(bcmd != nil){
		fd0 = open(TEMP "/data1", ORDWR);
		if(fd0 < 0)
			sysfatal("open %s: %r", TEMP "/data1");
		connect(bcmd, fd0, fd0);
		close(fd0);
	}else{
		fd0 = open(TEMP "/data1", OREAD);
		if(fd0 < 0)
			sysfatal("open %s: %r", TEMP "/data1");
		connect(wcmd, fd0, 1);
		fd1 = open(TEMP "/data1", OWRITE);
		if(fd1 < 0)
			sysfatal("open %s: %r", TEMP "/data1");
		connect(rcmd, 0, fd1);
		close(fd0);
		close(fd1);
	}
	unmount(nil, TEMP);
	exits(nil);
}



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

end of thread, other threads:[~2002-06-29  2:23 UTC | newest]

Thread overview: 185+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-08-18 15:34 [9fans] Re: Solaris thread scheaduling rob pike
     [not found] ` <rob@plan9.bell-labs.com>
2000-08-02 14:48   ` [9fans] pipefile rob pike
2000-08-02 15:49     ` James A. Robinson
2000-08-18 20:25   ` [9fans] Re: Solaris thread scheaduling Tom Duff
2000-09-06 21:59   ` [9fans] Reliable Cray Y-MP C90 Supercomputer rob pike
2000-09-06 22:02     ` James A. Robinson
2000-09-06 22:14       ` Boyd Roberts
2000-09-06 22:11     ` Boyd Roberts
2000-09-07 22:18   ` [9fans] new versions of graphics programs? Tom Duff
2000-11-01 22:23   ` [9fans] /n/smtp rob pike
2000-11-01 22:38     ` Scott Schwartz
2000-11-24  0:41   ` [9fans] Crazy idea... or a new project? rob pike
2000-11-24  0:48     ` Boyd Roberts
2000-11-24 22:13     ` Scott Schwartz
2000-11-24 22:24       ` Boyd Roberts
2001-02-06 17:11   ` [9fans] azerty [french] keyboard support rob pike
2001-02-06 19:10     ` Scott Schwartz
2001-02-06 19:23     ` Dan Cross
2001-02-07 15:23   ` [9fans] 9p2k, fsync rob pike
2001-02-07 18:42     ` Scott Schwartz
2001-02-08  1:19     ` Dan Cross
2001-02-08  9:43       ` Douglas A. Gwyn
2001-02-14 13:51   ` [9fans] isatty rob pike
2001-02-14 16:42     ` Scott Schwartz
2001-03-26 14:12   ` [9fans] sam mod for delete-forward rob pike
2001-03-26 15:37     ` Douglas A. Gwyn
2001-03-27  8:25       ` Boyd Roberts
2001-03-27 14:01         ` Sam
2001-03-27 16:51           ` Dan Cross
2001-03-28  8:37             ` Douglas A. Gwyn
2001-03-29  8:26               ` Boyd Roberts
2001-03-26 15:42     ` Scott Schwartz
2001-05-10 14:59   ` [9fans] snprint(), getfields() specification rob pike
2001-05-10 16:42     ` Scott Schwartz
2001-05-10 18:13     ` Steve Kilbane
2001-05-10 21:38       ` Boyd Roberts
2001-05-11  6:51         ` Steve Kilbane
2001-05-19 14:14   ` Re[4]: [9fans] home, end ^h^j^k^l rob pike
2001-05-19 14:26     ` Re[6]: " Matt H
2001-05-19 22:45       ` [9fans] ls -m Scott Schwartz
2001-05-19 22:50         ` Boyd Roberts
2001-05-19 15:35     ` Re[4]: [9fans] home, end ^h^j^k^l James A. Robinson
2001-05-19 20:36     ` Boyd Roberts
2001-05-19 23:30     ` Richard Elberger
2001-05-20  2:37     ` Boyd Roberts
2001-05-20  7:03     ` Lucio De Re
2001-05-20 11:16     ` paurea
2001-05-20 13:11       ` Boyd Roberts
2001-05-20 13:04     ` Boyd Roberts
2001-05-23  8:24     ` Randolph Fritz
2001-05-23  8:46       ` Re[6]: " Matt H
2001-05-23  9:04         ` Boyd Roberts
2001-05-20  0:16   ` [9fans] ls -m rob pike
2001-05-20  0:31     ` Boyd Roberts
2001-05-20  1:38     ` [9fans] mouse vs key Scott Schwartz
2001-05-20  6:29       ` Dan Cross
2001-05-20  8:09       ` Matt H
2001-05-20 11:35         ` Re[2]: [9fans] mouse vs key - nethack matt
2001-05-20 13:13           ` Boyd Roberts
2001-05-20 12:50         ` [9fans] mouse vs key Boyd Roberts
2001-05-29  4:27   ` [9fans] src vs db rob pike
2001-05-29  4:37     ` Scott Schwartz
2001-07-11 19:22   ` [9fans] sam vs acme rob pike
2001-07-11 20:08     ` James A. Robinson
2001-08-14 12:54   ` [9fans] User Interface rob pike
2001-08-14 15:01     ` James A. Robinson
2001-08-16 13:45     ` phaet0n
2001-08-20  8:57     ` Randolph Fritz
2001-12-02  3:10   ` [9fans] plumb rob pike
2001-12-02  3:31     ` Scott Schwartz
2002-01-30  5:52   ` [9fans] venti rob pike
2002-01-30  6:23     ` George Michaelson
2002-01-30  8:07     ` paurea
2002-01-30 11:17     ` Boyd Roberts
2002-03-01  6:20   ` Fwd: Re: [9fans] samuel (fwd) rob pike
2002-03-01  6:34     ` George Michaelson
2002-03-01 12:04     ` Boyd Roberts
2002-04-27 16:35   ` [9fans] Fourth Release of Plan 9 Now Available rob pike, esq.
2002-04-27 18:24     ` Scott Schwartz
2002-04-27 22:14     ` Laura Creighton
2002-04-29  9:37     ` Andrew
2002-06-28 16:49   ` [9fans] dumb question rob pike, esq.
2002-06-29  2:23     ` Scott Schwartz
  -- strict thread matches above, loose matches on Subject: below --
2002-01-20 20:02 [9fans] Getting started in Plan9 - help Roshan James
2002-01-20 21:01 ` Matt H
2002-01-20 22:02   ` Scott Schwartz
2002-01-22  9:54     ` ozan s yigit
2002-01-23 10:05       ` Bakul Shah
2002-01-21 10:22   ` Boyd Roberts
2002-01-21 10:40     ` John Murdie
2002-01-20 21:03 ` William S.
2002-01-20 21:34 ` William Josephson
2002-01-21  6:53 ` cej
2001-10-25 17:55 [9fans] Virtual memory in BSD and Plan9 Russ Cox
2001-10-25 18:29 ` William Josephson
2001-10-26  8:09   ` [9fans] acme bug/annoyance? Matt
2001-10-26 11:36     ` rob pike
2001-10-26 14:43       ` Scott Schwartz
2001-10-29 10:16   ` [9fans] Virtual memory in BSD and Plan9 John S. Dyson
2001-07-12  8:42 [9fans] architectures forsyth
2001-07-12 13:56 ` Laura Creighton
2001-07-12 16:13 ` Ozan Yigit
2001-07-12 16:33   ` Matt
2001-07-12 18:12     ` Scott Schwartz
2001-07-12 18:16       ` Martin Harriss
2001-07-12 18:43       ` Dan Cross
2001-07-13 14:52         ` Douglas A. Gwyn
2001-07-13 15:13           ` Boyd Roberts
2001-06-26 16:33 [9fans] bitsy question John Packer
2001-06-26 17:10 ` [9fans] " Dan Cross
2001-06-26 19:51   ` John Packer
2001-06-26 20:34     ` Dan Cross
2001-06-29 22:32       ` Boyd Roberts
2001-06-27  1:15     ` [9fans] Two cpu servers? Ish Rattan
2001-06-26 20:09   ` [9fans] Re: bitsy question John Packer
2001-06-26 20:36     ` Dan Cross
2001-06-26 20:18   ` Latchesar Ionkov
2001-06-26 20:28     ` Matt
2001-06-26 22:13       ` Steve Kilbane
     [not found] <matt@proweb.co.uk>
2001-06-12  0:39 ` [9fans] help, i'm in a wet paper bag and I can't get out Matt
2001-06-12  0:55   ` Scott Schwartz
2001-06-12  1:12     ` Boyd Roberts
2001-06-12  1:00   ` Boyd Roberts
2001-06-12  1:30     ` Jonathan Sergent
2001-06-15  8:27     ` Hermann Samso
2001-06-15 11:53       ` Boyd Roberts
2001-06-15 12:18         ` Matt
2001-06-15 14:01         ` Matt
2001-06-15 14:25           ` Boyd Roberts
     [not found] <vikki@proweb.co.uk>
2001-06-10 17:32 ` [9fans] string to list? vikki
2001-06-10 17:47   ` Boyd Roberts
2001-06-10 17:55   ` Boyd Roberts
2001-06-10 18:03   ` Scott Schwartz
2001-06-10 21:48     ` Matt
2001-06-10 22:24       ` Scott Schwartz
2001-06-10 22:30         ` Boyd Roberts
2001-06-09 17:22 [9fans] could those of you who have students check this out for forsyth
2001-06-09 18:50 ` [9fans] Re: the 'science' in computer science andrey mirtchovski
2001-06-09 17:56   ` Boyd Roberts
2001-06-11  8:27     ` pac
2001-06-11 15:19     ` Dan Cross
2001-06-11 21:43       ` Boyd Roberts
     [not found]       ` <0cb501c0f2bf$97cacea0$e8b7c6d4@SOMA>
2001-06-11 22:43         ` paurea
2001-06-12 14:18           ` Dan Cross
2001-06-12 15:50             ` Boyd Roberts
2001-06-12 18:48               ` Dan Cross
2001-06-12  0:09   ` Scott Merrilees
2001-06-12  0:16     ` Boyd Roberts
2001-06-12  0:42       ` Scott Merrilees
2001-06-12  1:08         ` Boyd Roberts
     [not found]   ` <0cc301c0f2c0$78949560$e8b7c6d4@SOMA>
2001-06-12 14:12     ` Dan Cross
2001-06-16 23:34   ` Matt
2001-06-28 21:29     ` Boyd Roberts
2001-06-28 22:03       ` Matt
2001-06-28 23:20         ` George Michaelson
2001-06-29 21:27           ` Boyd Roberts
2001-07-18 15:49           ` Ralph Corderoy
2001-06-29  4:30         ` Lucio De Re
2000-09-07 21:57 [9fans] new versions of graphics programs? rob pike
2000-09-07 22:50 ` Jim Choate
     [not found]   ` <ravage@einstein.ssz.com>
2000-09-07 22:35     ` Tom Duff
2000-09-07 23:24       ` Jim Choate
2000-09-08 15:28         ` please_no_spam_to_
     [not found]           ` <D.M.Pick@qmw.ac.uk>
2000-09-08 16:43             ` Tom Duff
2000-08-03 23:46 [9fans] pipefile okamoto
2000-08-03  4:49 rob pike
2000-08-03  4:15 okamoto
2000-08-03  3:44 okamoto
2000-08-03  7:14 ` Matt
2000-08-03  3:19 okamoto
2000-08-03  0:19 okamoto
2000-08-02 21:19 rob pike
2000-08-02  7:55 okamoto
2000-08-03  8:21 ` Boyd Roberts
2000-07-31  9:47 okamoto
2000-07-31  4:55 rob pike
2000-07-31  4:40 okamoto
2000-07-31  1:14 rob pike
2000-08-02  3:40 ` Skip Tavakkolian
2000-08-03  1:21   ` Skip Tavakkolian
2000-07-30 23:46 Steve Harris
2000-07-30 23:17 rob pike
2000-07-30 23:06 rob pike
2000-07-30 22:38 Steve Harris
2000-07-30 19:54 rob pike

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