* [9fans] Plan9ports lib9p question: serving to a plain 'ol tcp socket
@ 2005-05-24 3:56 Ronald G. Minnich
2005-05-24 12:53 ` Eric Van Hensbergen
2005-05-24 14:43 ` Russ Cox
0 siblings, 2 replies; 5+ messages in thread
From: Ronald G. Minnich @ 2005-05-24 3:56 UTC (permalink / raw)
To: 9fans
I am starting to look at this but wonder if someone has beat me to it.
I need to make a simple, single-threaded 9p server that will sit on a
normal Unix TCP socket in an accept/serve loop . It seems like the bits
are there to do this in lib9p, but I'm still untangling a few things; I
don't need the /tmp/ns.whatever Unix domain socket stuff, for example, but
all the other superstructure there is really nice. Anybody done this. I
can't use newsham's python server as I am sitting on a nice, bare node and
python is not really an option. I was simply hacking u9fs until a minute
or two ago, and I feel like I'm re-inventing something I'm sure someone
has already done -- must be somebody there who has beat me to this, I
figure.
Thanks
ron
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [9fans] Plan9ports lib9p question: serving to a plain 'ol tcp socket
2005-05-24 3:56 [9fans] Plan9ports lib9p question: serving to a plain 'ol tcp socket Ronald G. Minnich
@ 2005-05-24 12:53 ` Eric Van Hensbergen
2005-05-24 14:43 ` Russ Cox
1 sibling, 0 replies; 5+ messages in thread
From: Eric Van Hensbergen @ 2005-05-24 12:53 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
[-- Attachment #1: Type: text/plain, Size: 1303 bytes --]
On 5/23/05, Ronald G. Minnich <rminnich@lanl.gov> wrote:
> I am starting to look at this but wonder if someone has beat me to it.
>
> I need to make a simple, single-threaded 9p server that will sit on a
> normal Unix TCP socket in an accept/serve loop . It seems like the bits
> are there to do this in lib9p, but I'm still untangling a few things; I
> don't need the /tmp/ns.whatever Unix domain socket stuff, for example, but
> all the other superstructure there is really nice. Anybody done this. I
> can't use newsham's python server as I am sitting on a nice, bare node and
> python is not really an option. I was simply hacking u9fs until a minute
> or two ago, and I feel like I'm re-inventing something I'm sure someone
> has already done -- must be somebody there who has beat me to this, I
> figure.
>
You should be able to use the plan9ports infrastructure just fine,
even if its more than you need. I'm going to attach a really simple
devcons style driver I wrote using plan9ports as an example. Almost
all of the code can be thought of as a template. Search for Qtime and
Qcons to get the parts that really do anything.
One of these days I'll get around to writing a synthetic file systems
SDK to help make stuff like this more straightforward.
-eric
[-- Attachment #2: devcons.tar --]
[-- Type: application/x-tar, Size: 20480 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [9fans] Plan9ports lib9p question: serving to a plain 'ol tcp socket
2005-05-24 3:56 [9fans] Plan9ports lib9p question: serving to a plain 'ol tcp socket Ronald G. Minnich
2005-05-24 12:53 ` Eric Van Hensbergen
@ 2005-05-24 14:43 ` Russ Cox
2005-05-24 15:01 ` Ronald G. Minnich
2005-05-24 20:20 ` Ronald G. Minnich
1 sibling, 2 replies; 5+ messages in thread
From: Russ Cox @ 2005-05-24 14:43 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
[-- Attachment #1: Type: text/plain, Size: 455 bytes --]
Attached is a replacement for /usr/local/plan9/src/lib9/post9p.c
(note that it says /lib9/ not /lib9p/!). If you put that in, then you
should be able to just call threadpostmountsrv with a service
of 'tcp!*!12345' or whatever you want.
If you do this, then the service loop will be single-threaded
(as lib9p service loops always are) and the library will handle
feeding it messages from potentially many different active
connections.
Russ
[-- Attachment #2.1: Type: text/plain, Size: 334 bytes --]
from postmaster@ethel:
The following attachment had content that we can't
prove to be harmless. To avoid possible automatic
execution, we changed the content headers.
The original header was:
Content-Type: text/x-csrc; name="post9p.c"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="post9p.c"
[-- Attachment #2.2: post9p.c.suspect --]
[-- Type: application/octet-stream, Size: 732 bytes --]
#include <u.h>
#include <libc.h>
int
post9pservice(int fd, char *name)
{
int i;
char *ns, *s;
Waitmsg *w;
if(strchr(name, '!')) /* assume is already network address */
s = strdup(name);
else{
if((ns = getns()) == nil)
return -1;
s = smprint("unix!%s/%s", ns, name);
free(ns);
}
if(s == nil)
return -1;
switch(fork()){
case -1:
return -1;
case 0:
dup(fd, 0);
dup(fd, 1);
for(i=3; i<20; i++)
close(i);
execlp("9pserve", "9pserve", "-u", s, (char*)0);
fprint(2, "exec 9pserve: %r\n");
_exits("exec");
default:
w = wait();
if(w == nil)
return -1;
close(fd);
free(s);
if(w->msg && w->msg[0]){
free(w);
werrstr("9pserve failed");
return -1;
}
free(w);
return 0;
}
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [9fans] Plan9ports lib9p question: serving to a plain 'ol tcp socket
2005-05-24 14:43 ` Russ Cox
@ 2005-05-24 15:01 ` Ronald G. Minnich
2005-05-24 20:20 ` Ronald G. Minnich
1 sibling, 0 replies; 5+ messages in thread
From: Ronald G. Minnich @ 2005-05-24 15:01 UTC (permalink / raw)
To: Russ Cox, Fans of the OS Plan 9 from Bell Labs
On Tue, 24 May 2005, Russ Cox wrote:
> Attached is a replacement for /usr/local/plan9/src/lib9/post9p.c
> (note that it says /lib9/ not /lib9p/!).
yeah, my fingers keep typing lib9p when I mean lib9.
>If you put that in, then you should be able to just call
>threadpostmountsrv with a service of 'tcp!*!12345' or whatever you want.
Perfect. I was going to try this today, now I can be lazy and just use
your code.
Thanks
ron
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [9fans] Plan9ports lib9p question: serving to a plain 'ol tcp socket
2005-05-24 14:43 ` Russ Cox
2005-05-24 15:01 ` Ronald G. Minnich
@ 2005-05-24 20:20 ` Ronald G. Minnich
1 sibling, 0 replies; 5+ messages in thread
From: Ronald G. Minnich @ 2005-05-24 20:20 UTC (permalink / raw)
To: Russ Cox, Fans of the OS Plan 9 from Bell Labs
russ, that code works wonderfully, thanks!
ron
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-05-24 20:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-24 3:56 [9fans] Plan9ports lib9p question: serving to a plain 'ol tcp socket Ronald G. Minnich
2005-05-24 12:53 ` Eric Van Hensbergen
2005-05-24 14:43 ` Russ Cox
2005-05-24 15:01 ` Ronald G. Minnich
2005-05-24 20:20 ` Ronald G. 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).