9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] mounting stdin using 9pfuse
@ 2008-10-03 19:18 Roman V. Shaposhnik
  2008-10-05 15:35 ` sqweek
  2008-10-06 16:31 ` Russ Cox
  0 siblings, 2 replies; 7+ messages in thread
From: Roman V. Shaposhnik @ 2008-10-03 19:18 UTC (permalink / raw)
  To: 9fans

Guys,

it appears that I'm missing something fundamental in how
9pfuse (the one written by Russ) works when it is given
"-" as an address. The source looks like it should be
simply using stdin for R/W instead of dialing out the
connection first, but it doesn't really seem to work.
Here's the simplest way of reproducing what I'm
seeing:

$ cat connector.c
#include <stdlib.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <error.h>
#include <errno.h>

void socket012(int fd)
{
   int i;
   for (i=0; i<3; i++) {
        close(i);
        dup2(fd, i);
   }
   close(fd);
}

int main()
{
    int fd[2];

    if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNIX, fd) < 0)
        error(-1, errno, "socketpair failed");

    if (fork()) {
        socket012(fd[0]);
        execlp("9pfuse", "9pfuse", "-", "/tmp/fuse", (char*)0);
    } else {
        socket012(fd[1]);
        execlp("ramfs", "ramfs", "-i", (char*)0);
    }
}
$ cc connector.c
$ ./a.out

Now, in a different terminal I do this:

# ls /tmp/fuse
ls: cannot access /tmp/fuse: Permission denied

Also apparently the processes are there (although
a zombie ramfs looks suspicious -- the second ramfs
is fully functional):

$ ps -alef | egrep "9p|ramfs"
0 S roman    22661 18264  0  78   0 -  2575 wait   12:13 pts/4   00:00:00 9pfuse -D - /tmp/fuse
1 S roman    22663 22661  0  78   0 - 12906 stext  12:13 ?        00:00:00 9pfuse -D - /tmp/fuse
1 S roman    22666     1  0  79   0 -  2725 -      12:13 pts/4   00:00:00 ramfs -i
0 Z roman    22662 22661  0  78   0 -     0 exit   12:13 pts/4    00:00:00 [ramfs] <defunct>

Now, if I enable -D in 9pfuse (by dup2'ing only 0 instead of
0,1 and 2) here's the output I get:
<- Tversion tag 0 msize 8192 version '9P2000.u'
-> Rversion tag 65535 msize 8192 version '9P2000'
<- Tattach tag 0 fid 0 afid -1 uname roman aname
-> Rattach tag 0 qid (0000000000000000 0 d)
FUSE -> len 16 unique 0x1 uid 0 gid 0 pid 0 Init major 7 minor 8
FUSE <- unique 0x1 (Init) major 7 minor 5 max_write 4096

And it stops there no matter what I do from then on.

Well, I'm baffled. Any help would be tremendously appreciated.

Thanks,
Roman.




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

* Re: [9fans] mounting stdin using 9pfuse
  2008-10-03 19:18 [9fans] mounting stdin using 9pfuse Roman V. Shaposhnik
@ 2008-10-05 15:35 ` sqweek
  2008-10-06  3:46   ` Roman V. Shaposhnik
  2008-10-06 16:31 ` Russ Cox
  1 sibling, 1 reply; 7+ messages in thread
From: sqweek @ 2008-10-05 15:35 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Sat, Oct 4, 2008 at 3:18 AM, Roman V. Shaposhnik <rvs@sun.com> wrote:
> it appears that I'm missing something fundamental in how
> 9pfuse (the one written by Russ) works when it is given
> "-" as an address.

 Seems to work here on linux after:
 #include <error.h>
 #include <errno.h>
+#include <unistd.h>

 void socket012(int fd)
 {
   int i;
-  for (i=0; i<3; i++) {
+ for (i=0; i<2; i++) {
        close(i);
        dup2(fd, i);

    if (fork()) {
        socket012(fd[0]);
-       execlp("9pfuse", "9pfuse", "-", "/tmp/fuse", (char*)0);
+       execlp("9pfuse", "9pfuse", "-D", "-", "/tmp/fuse", (char*)0);
    } else {
        socket012(fd[1]);

 ls -l caused a failed assertion in ramfs, but it was going. Can't
justify why the diff works, but before adding -D and changing 3 -> 2 I
didn't have any success. Would love to look into it further but in the
interest of not destroying my work schedule this week I'm going to get
some damn sleep. Good luck.
-sqweek



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

* Re: [9fans] mounting stdin using 9pfuse
  2008-10-05 15:35 ` sqweek
@ 2008-10-06  3:46   ` Roman V. Shaposhnik
  2008-10-06  4:56     ` sqweek
  0 siblings, 1 reply; 7+ messages in thread
From: Roman V. Shaposhnik @ 2008-10-06  3:46 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

Hi!

Thanks for replying. You're the only one so far, which makes
me wonder whether there's a more appropriate place for
plan9port discussions.

On Sun, 2008-10-05 at 23:35 +0800, sqweek wrote:
> On Sat, Oct 4, 2008 at 3:18 AM, Roman V. Shaposhnik <rvs@sun.com> wrote:
> > it appears that I'm missing something fundamental in how
> > 9pfuse (the one written by Russ) works when it is given
> > "-" as an address.
>
>  Seems to work here on linux after:
>  #include <error.h>
>  #include <errno.h>
> +#include <unistd.h>
>
>  void socket012(int fd)
>  {
>    int i;
> -  for (i=0; i<3; i++) {
> + for (i=0; i<2; i++) {
>         close(i);
>         dup2(fd, i);
>
>     if (fork()) {
>         socket012(fd[0]);
> -       execlp("9pfuse", "9pfuse", "-", "/tmp/fuse", (char*)0);
> +       execlp("9pfuse", "9pfuse", "-D", "-", "/tmp/fuse", (char*)0);
>     } else {
>         socket012(fd[1]);
>
>  ls -l caused a failed assertion in ramfs, but it was going.

Yeah, that tripped me too. In fact, I'm wondering whether ramfs works
as advertised at all. I wasn't able to make it work on:
   $ uname -a
   Linux goose 2.6.22.17-0.1-default #1 SMP 2008/02/10 20:01:04 UTC x86_64 x86_64 x86_64 GNU/Linux

> Can't justify why the diff works, but before adding -D and changing 3 -> 2 I
> didn't have any success.

It seems to be flaky on my end. It looks like a race condition but
I haven't investigated further yet.

>  Would love to look into it further but in the
> interest of not destroying my work schedule this week I'm going to get
> some damn sleep. Good luck.

I hear you...

Thanks,
Roman.




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

* Re: [9fans] mounting stdin using 9pfuse
  2008-10-06  3:46   ` Roman V. Shaposhnik
@ 2008-10-06  4:56     ` sqweek
  0 siblings, 0 replies; 7+ messages in thread
From: sqweek @ 2008-10-06  4:56 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Mon, Oct 6, 2008 at 11:46 AM, Roman V. Shaposhnik <rvs@sun.com> wrote:
> Thanks for replying. You're the only one so far, which makes
> me wonder whether there's a more appropriate place for
> plan9port discussions.

 Not that I'm aware of. I think we're just seeing the effect of a
small community who are a) spread thinly (consider the breadth of plan
9 + inferno + p9p + 9vx + thnx + v9fs + ...) and b) often busy with
other commitments.
-sqweek



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

* Re: [9fans] mounting stdin using 9pfuse
  2008-10-03 19:18 [9fans] mounting stdin using 9pfuse Roman V. Shaposhnik
  2008-10-05 15:35 ` sqweek
@ 2008-10-06 16:31 ` Russ Cox
  2008-10-07  3:47   ` Roman V. Shaposhnik
  1 sibling, 1 reply; 7+ messages in thread
From: Russ Cox @ 2008-10-06 16:31 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> it appears that I'm missing something fundamental in how
> 9pfuse (the one written by Russ) works when it is given
> "-" as an address. The source looks like it should be
> simply using stdin for R/W instead of dialing out the
> connection first, but it doesn't really seem to work.
> Here's the simplest way of reproducing what I'm
> seeing:

I don't know why your example doesn't work, but ramfs
simply may not work with 9pfuse.  I would try doing something
a little more complicated, like dial tcp!sources.cs.bell-labs.com!9fs
and then run 9pfuse - with that on standard input.

9fans is a fine list to ask about plan9port.

Russ


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

* Re: [9fans] mounting stdin using 9pfuse
  2008-10-06 16:31 ` Russ Cox
@ 2008-10-07  3:47   ` Roman V. Shaposhnik
  2008-10-07  7:48     ` sqweek
  0 siblings, 1 reply; 7+ messages in thread
From: Roman V. Shaposhnik @ 2008-10-07  3:47 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Mon, 2008-10-06 at 09:31 -0700, Russ Cox wrote:
> > it appears that I'm missing something fundamental in how
> > 9pfuse (the one written by Russ) works when it is given
> > "-" as an address. The source looks like it should be
> > simply using stdin for R/W instead of dialing out the
> > connection first, but it doesn't really seem to work.
> > Here's the simplest way of reproducing what I'm
> > seeing:
>
> I don't know why your example doesn't work, but ramfs
> simply may not work with 9pfuse.

Any particular reason for that? I'm asking simply because
ramfs appears to be quite broken on my system. In fact,
I can't make it work at all. Has it bitrotted?

> I would try doing something
> a little more complicated, like dial tcp!sources.cs.bell-labs.com!9fs
> and then run 9pfuse - with that on standard input.

That, actually, seems to work fine. Although I'm about
to give it more stress testing. Here's a question thought:
by default 9pserve only listens on an AF_UNIX socket what
would be the best way to connect it to the AF_INET one?

Thanks,
Roman.




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

* Re: [9fans] mounting stdin using 9pfuse
  2008-10-07  3:47   ` Roman V. Shaposhnik
@ 2008-10-07  7:48     ` sqweek
  0 siblings, 0 replies; 7+ messages in thread
From: sqweek @ 2008-10-07  7:48 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

On Tue, Oct 7, 2008 at 11:47 AM, Roman V. Shaposhnik <rvs@sun.com> wrote:
> Here's a question thought:
> by default 9pserve only listens on an AF_UNIX socket what
> would be the best way to connect it to the AF_INET one?

 Enrico did some work on this, see
http://9fans.net/archive/2008/06/150 ... which doesn't include the
patch he attached:

Index: src/cmd/9pserve.c
===================================================================
--- src/cmd/9pserve.c	(revision 707)
+++ src/cmd/9pserve.c	(working copy)
@@ -136,7 +136,7 @@
 void
 usage(void)
 {
-	fprint(2, "usage: 9pserve [-lnv] [-A aname afid] [-M msize] address\n");
+	fprint(2, "usage: 9pserve [-c pipe] [-lnv] [-A aname afid] [-M
msize] address\n");
 	fprint(2, "\treads/writes 9P messages on stdin/stdout\n");
 	threadexitsall("usage");
 }
@@ -157,6 +157,19 @@
 	ARGBEGIN{
 	default:
 		usage();
+	case 'c':
+	{
+		char* pipename = EARGF(usage());
+		printf("pipename=\"%s\"\n", pipename);
+
+                if((fd = dial(pipename, nil, nil, nil)) < 0)
+            	    sysfatal("dial %s: %r");
+		dup(fd, 0);
+		dup(fd, 1);
+		if(fd > 1)
+		    close(fd);
+	}
+	break;
 	case 'A':
 		attached = 1;
 		xaname = EARGF(usage());

 And this is the discussion he referred to:

http://9fans.net/archive/2008/05/354
http://9fans.net/archive/2008/06/3
http://9fans.net/archive/2008/06/5
http://9fans.net/archive/2008/06/9
http://9fans.net/archive/2008/06/11
http://9fans.net/archive/2008/06/12
http://9fans.net/archive/2008/06/45
http://9fans.net/archive/2008/06/53

 (Sometimes 9fans.net's lack of threading is a pain).
-sqweek



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

end of thread, other threads:[~2008-10-07  7:48 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-03 19:18 [9fans] mounting stdin using 9pfuse Roman V. Shaposhnik
2008-10-05 15:35 ` sqweek
2008-10-06  3:46   ` Roman V. Shaposhnik
2008-10-06  4:56     ` sqweek
2008-10-06 16:31 ` Russ Cox
2008-10-07  3:47   ` Roman V. Shaposhnik
2008-10-07  7:48     ` sqweek

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