From: Russ Cox <russcox@gmail.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>
Subject: Re: [9fans] Plan9ports lib9p question: serving to a plain 'ol tcp socket
Date: Tue, 24 May 2005 10:43:38 -0400 [thread overview]
Message-ID: <ee9e417a050524074364004d7e@mail.gmail.com> (raw)
In-Reply-To: <Pine.LNX.4.58.0505232152020.7716@enigma.lanl.gov>
[-- 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;
}
}
next prev parent reply other threads:[~2005-05-24 14:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-05-24 3:56 Ronald G. Minnich
2005-05-24 12:53 ` Eric Van Hensbergen
2005-05-24 14:43 ` Russ Cox [this message]
2005-05-24 15:01 ` Ronald G. Minnich
2005-05-24 20:20 ` Ronald G. Minnich
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ee9e417a050524074364004d7e@mail.gmail.com \
--to=russcox@gmail.com \
--cc=9fans@cse.psu.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).