9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] acme(4) and addr=dot
@ 2010-03-06  3:37 Micah Stetson
  2010-03-06 13:11 ` roger peppe
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Micah Stetson @ 2010-03-06  3:37 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

I think this may apply to all versions of acme, but I'm running into
it on p9p.  First, acme(4) claims that a read on a window's addr file
returns the current address as a pair of character offsets m and n, in
'#m,#n' format or just '#m' if m and n are equal.  It looks like it
really returns m and n as two space-padded integer values.

But that's just a documentation bug.  What's really bothering me is
that I can't seem to get the value of dot.  I've tried this:

% echo -n 'addr=dot' | 9p write acme/70/ctl
% 9p read acme/70/addr
          0           0 %

Window 70's dot is somewhere on line 16.  Thinking maybe the ctl file
had to stay open, I tried this:

% {echo 'addr=dot'; 9p read acme/70/addr >[1=2]} | 9p write acme/70/ctl
          0           0 %

No help.  Am I doing something wrong?

Micah



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

* Re: [9fans] acme(4) and addr=dot
  2010-03-06  3:37 [9fans] acme(4) and addr=dot Micah Stetson
@ 2010-03-06 13:11 ` roger peppe
  2010-03-06 15:13 ` David Leimbach
  2010-03-06 18:41 ` Eoghan Sherry
  2 siblings, 0 replies; 11+ messages in thread
From: roger peppe @ 2010-03-06 13:11 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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

the address is lost as soon as the ctl file is closed
(personally, i think this is not ideal behaviour).

under p9p i use the attached code to retrieve
the current value of acme's dot for a particular
window.

i couldn't figure out a way to do it reliably
in a shell script.

[-- Attachment #2: acmedot.c --]
[-- Type: application/octet-stream, Size: 979 bytes --]

#include <u.h>
#include <libc.h>
#include <fcall.h>
#include <9pclient.h>
#include <auth.h>
#include <thread.h>

void
threadmain(int argc, char **argv)
{
	char *id;
	CFsys *fs;
	CFid *addr, *ctl;
	char buf[100];
	int n;

	id = getenv("winid");
	if(id == nil){
		sysfatal("acmedot: not run inside acme window");
	}
	fs = nsamount("acme", nil);
	if(fs == nil){
		sysfatal("acmedot: %r");
	}

	snprint(buf, sizeof(buf), "acme/%s/addr", id);
	addr = fsopen(fs, buf, OREAD);
	if(addr == nil){
		sysfatal("acmedot: cannot open %s: %r", buf);
	}

	snprint(buf, sizeof(buf), "acme/%s/ctl", id);
	ctl = fsopen(fs, buf, ORDWR);
	if(ctl == nil){
		sysfatal("acmedot: cannot open %s: %r", buf);
	}

	strcpy(buf, "addr=dot");
	if(fswrite(ctl, buf, strlen(buf)) != strlen(buf)){
		sysfatal("acmedot: cannot set addr: %r");
	}

	n = fsread(addr, buf, sizeof(buf));
	if(n < 0){
		sysfatal("acmedot: cannot read addr: %r");
	}
	fsclose(ctl);
	fsclose(addr);
	fsunmount(fs);

	write(1, buf, n);
}

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

* Re: [9fans] acme(4) and addr=dot
  2010-03-06  3:37 [9fans] acme(4) and addr=dot Micah Stetson
  2010-03-06 13:11 ` roger peppe
@ 2010-03-06 15:13 ` David Leimbach
  2010-03-06 15:16   ` erik quanstrom
  2010-03-06 18:34   ` roger peppe
  2010-03-06 18:41 ` Eoghan Sherry
  2 siblings, 2 replies; 11+ messages in thread
From: David Leimbach @ 2010-03-06 15:13 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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

I think you want to create some kind of redirected handle to the ctl file
first, then start a new block in rc.  I believe this is how network
programming in rc can be accomplished in Inferno as well.  Is this not
allowed in p9p?  I've honestly not used the 9p commands too often.

On Fri, Mar 5, 2010 at 7:37 PM, Micah Stetson <micah@stetsonnet.org> wrote:

> I think this may apply to all versions of acme, but I'm running into
> it on p9p.  First, acme(4) claims that a read on a window's addr file
> returns the current address as a pair of character offsets m and n, in
> '#m,#n' format or just '#m' if m and n are equal.  It looks like it
> really returns m and n as two space-padded integer values.
>
> But that's just a documentation bug.  What's really bothering me is
> that I can't seem to get the value of dot.  I've tried this:
>
> % echo -n 'addr=dot' | 9p write acme/70/ctl
> % 9p read acme/70/addr
>          0           0 %
>
> Window 70's dot is somewhere on line 16.  Thinking maybe the ctl file
> had to stay open, I tried this:
>
> % {echo 'addr=dot'; 9p read acme/70/addr >[1=2]} | 9p write acme/70/ctl
>          0           0 %
>
> No help.  Am I doing something wrong?
>
> Micah
>
>

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

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

* Re: [9fans] acme(4) and addr=dot
  2010-03-06 15:13 ` David Leimbach
@ 2010-03-06 15:16   ` erik quanstrom
  2010-03-06 16:21     ` David Leimbach
  2010-03-06 18:34   ` roger peppe
  1 sibling, 1 reply; 11+ messages in thread
From: erik quanstrom @ 2010-03-06 15:16 UTC (permalink / raw)
  To: 9fans

> I think you want to create some kind of redirected handle to the ctl file
> first, then start a new block in rc.  I believe this is how network
> programming in rc can be accomplished in Inferno as well.

inferno doesn't have rc.

- erik



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

* Re: [9fans] acme(4) and addr=dot
  2010-03-06 15:16   ` erik quanstrom
@ 2010-03-06 16:21     ` David Leimbach
  2010-03-06 16:48       ` erik quanstrom
  0 siblings, 1 reply; 11+ messages in thread
From: David Leimbach @ 2010-03-06 16:21 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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

On Sat, Mar 6, 2010 at 7:16 AM, erik quanstrom <quanstro@quanstro.net>wrote:

> > I think you want to create some kind of redirected handle to the ctl file
> > first, then start a new block in rc.  I believe this is how network
> > programming in rc can be accomplished in Inferno as well.
>
> inferno doesn't have rc.
>

Sorry I meant the shell.  I apologize to everyone that that wasn't obvious
to, and I thank you for correcting me publicly, because everyone loves when
they're corrected publicly.

Dave


>
> - erik
>
>

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

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

* Re: [9fans] acme(4) and addr=dot
  2010-03-06 16:21     ` David Leimbach
@ 2010-03-06 16:48       ` erik quanstrom
  2010-03-06 19:52         ` David Leimbach
  0 siblings, 1 reply; 11+ messages in thread
From: erik quanstrom @ 2010-03-06 16:48 UTC (permalink / raw)
  To: 9fans

> > > I think you want to create some kind of redirected handle to the ctl file
> > > first, then start a new block in rc.  I believe this is how network
> > > programming in rc can be accomplished in Inferno as well.
> >
> > inferno doesn't have rc.
>
> Sorry I meant the shell.  I apologize to everyone that that wasn't obvious
> to, and I thank you for correcting me publicly, because everyone loves when
> they're corrected publicly.

i apoligize if you were offended.  it wasn't my intention.

a technical error salient to the topic at hand was made.
i personally think that it is easy to get confused about inferno's
shell.  therefore, i thought a correction helpful and
appropriate.

the post wasn't personal at all; i'm pretty surprised at the
reaction.  i think that to be a good and helpful community
we can't let technical differences become personal differences.

cheers.

- erik



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

* Re: [9fans] acme(4) and addr=dot
  2010-03-06 15:13 ` David Leimbach
  2010-03-06 15:16   ` erik quanstrom
@ 2010-03-06 18:34   ` roger peppe
  1 sibling, 0 replies; 11+ messages in thread
From: roger peppe @ 2010-03-06 18:34 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On 6 March 2010 15:13, David Leimbach <leimy2k@gmail.com> wrote:
> I think you want to create some kind of redirected handle to the ctl file
> first, then start a new block in rc.  I believe this is how network
> programming in rc can be accomplished in Inferno as well.  Is this not
> allowed in p9p?  I've honestly not used the 9p commands too often.

the nearest you can get to it in p9p is something like:

{
  echo -n 'addr=dot'
  9p read acme/70/addr
} | 9p write acme/70/ctl

but there's no way of guaranteeing that the read
takes place after the write - well, as a hack you can
put a sleep in there, but that's not great...



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

* Re: [9fans] acme(4) and addr=dot
  2010-03-06  3:37 [9fans] acme(4) and addr=dot Micah Stetson
  2010-03-06 13:11 ` roger peppe
  2010-03-06 15:13 ` David Leimbach
@ 2010-03-06 18:41 ` Eoghan Sherry
  2010-03-06 18:54   ` Micah Stetson
  2010-03-06 18:55   ` ron minnich
  2 siblings, 2 replies; 11+ messages in thread
From: Eoghan Sherry @ 2010-03-06 18:41 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> % {echo 'addr=dot'; 9p read acme/70/addr >[1=2]} | 9p write acme/70/ctl
>          0           0 %
>
> No help.  Am I doing something wrong?

Addr is reset to 0,0 once opened. So, you need to perform these
operations in order: open addr; write ctl; then read addr.

There's a nice way to do this if you can give rc access to the acme
files (try 9pfuse(4) with FUSE).

;9pfuse unix!`{namespace}^/acme mnt
;<mnt/acme/1/addr{
	echo 'addr=dot'>>mnt/1/ctl;
	cat;
}
         93         234 ;

By the way, your question motivated me to give 9pfuse a try. Also,
it lead to my realization that, in rc, you can put the redirections
in front of the command. Hooray!

Eoghan



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

* Re: [9fans] acme(4) and addr=dot
  2010-03-06 18:41 ` Eoghan Sherry
@ 2010-03-06 18:54   ` Micah Stetson
  2010-03-06 18:55   ` ron minnich
  1 sibling, 0 replies; 11+ messages in thread
From: Micah Stetson @ 2010-03-06 18:54 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> Addr is reset to 0,0 once opened. So, you need to perform these
> operations in order: open addr; write ctl; then read addr.

Thanks, all.

Micah



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

* Re: [9fans] acme(4) and addr=dot
  2010-03-06 18:41 ` Eoghan Sherry
  2010-03-06 18:54   ` Micah Stetson
@ 2010-03-06 18:55   ` ron minnich
  1 sibling, 0 replies; 11+ messages in thread
From: ron minnich @ 2010-03-06 18:55 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Since fuse is being mentioned here ....

I needed to do a fuse module recently. The standard Linux fuse library
is quite badly designed. Turns out Russ's fuse library is about as
good as you can get given the limitations of the kernel interface for
fuse. I really like it in fact. It made my library development dead
simple.

So if you're going to do anything with fuse, use the p9p version. It's
great. I did beat on Russ's code a bit to make it work without
requiring p9p libraries (long story ...). It was a trivial set of
changes which anyone can easily do.

ron



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

* Re: [9fans] acme(4) and addr=dot
  2010-03-06 16:48       ` erik quanstrom
@ 2010-03-06 19:52         ` David Leimbach
  0 siblings, 0 replies; 11+ messages in thread
From: David Leimbach @ 2010-03-06 19:52 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

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

On Sat, Mar 6, 2010 at 8:48 AM, erik quanstrom <quanstro@quanstro.net>wrote:

> > > > I think you want to create some kind of redirected handle to the ctl
> file
> > > > first, then start a new block in rc.  I believe this is how network
> > > > programming in rc can be accomplished in Inferno as well.
> > >
> > > inferno doesn't have rc.
> >
> > Sorry I meant the shell.  I apologize to everyone that that wasn't
> obvious
> > to, and I thank you for correcting me publicly, because everyone loves
> when
> > they're corrected publicly.
>
> i apoligize if you were offended.  it wasn't my intention.
>
>
I was saying that sort of tongue in cheek :-)  Sorry I omitted the smiley.
 No offense taken.


> a technical error salient to the topic at hand was made.
> i personally think that it is easy to get confused about inferno's
> shell.  therefore, i thought a correction helpful and
> appropriate.
>
> the post wasn't personal at all; i'm pretty surprised at the
> reaction.  i think that to be a good and helpful community
> we can't let technical differences become personal differences.
>

Sorry, it wasn't meant to come off as true offense :-)


>
> cheers.
>
> - erik
>
>

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

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

end of thread, other threads:[~2010-03-06 19:52 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-03-06  3:37 [9fans] acme(4) and addr=dot Micah Stetson
2010-03-06 13:11 ` roger peppe
2010-03-06 15:13 ` David Leimbach
2010-03-06 15:16   ` erik quanstrom
2010-03-06 16:21     ` David Leimbach
2010-03-06 16:48       ` erik quanstrom
2010-03-06 19:52         ` David Leimbach
2010-03-06 18:34   ` roger peppe
2010-03-06 18:41 ` Eoghan Sherry
2010-03-06 18:54   ` Micah Stetson
2010-03-06 18:55   ` ron 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).