From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Wed, 11 Jun 2008 14:49:04 +0200 From: Enrico Weigelt To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Message-ID: <20080611124904.GA32143@nibiru.local> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="ibTvN161/egqYuK8" Content-Disposition: inline User-Agent: Mutt/1.4.1i Subject: [9fans] [PATCH] p9p: 9pserve proxy support Topicbox-Message-UUID: ba817f2c-ead3-11e9-9d60-3106f5b1d025 --ibTvN161/egqYuK8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Hi folks, here's a patch against p9p for an "proxy mode" in 9pserve, like Russ suggested. It just adds an new "-c" option which tells 9pserve to dial to an address as it's input connection (instead of taking stdio). This way, 9pserve can eg. be used as a proxy between a unix socket and TCP, making p9p servers available via TCP. 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 ---------------------------------------------------------------------- --ibTvN161/egqYuK8 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="9pserve-pipe.diff" 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()); --ibTvN161/egqYuK8--