rsc | 2277c5d | 2004-03-21 04:33:13 +0000 | [diff] [blame] | 1 | #include <u.h> |
| 2 | #include <libc.h> |
| 3 | #include <fcall.h> |
| 4 | #include <thread.h> |
| 5 | #include <9p.h> |
rsc | 2aa7d30 | 2005-02-11 17:00:06 +0000 | [diff] [blame] | 6 | |
| 7 | static void |
| 8 | launchsrv(void *v) |
| 9 | { |
| 10 | srv(v); |
| 11 | } |
rsc | 2277c5d | 2004-03-21 04:33:13 +0000 | [diff] [blame] | 12 | |
| 13 | void |
| 14 | threadpostmountsrv(Srv *s, char *name, char *mtpt, int flag) |
| 15 | { |
rsc | 2aa7d30 | 2005-02-11 17:00:06 +0000 | [diff] [blame] | 16 | int fd[2]; |
rsc | 2aa7d30 | 2005-02-11 17:00:06 +0000 | [diff] [blame] | 17 | |
| 18 | if(!s->nopipe){ |
| 19 | if(pipe(fd) < 0) |
| 20 | sysfatal("pipe: %r"); |
| 21 | s->infd = s->outfd = fd[1]; |
| 22 | s->srvfd = fd[0]; |
| 23 | } |
Russ Cox | 118dfa9 | 2008-05-05 23:07:54 -0400 | [diff] [blame] | 24 | if(name || mtpt){ |
| 25 | if(post9pservice(s->srvfd, name, mtpt) < 0) |
| 26 | sysfatal("post9pservice %s: %r", name); |
| 27 | }else if(!s->nopipe) |
| 28 | sysfatal("no one to serve"); |
Russ Cox | 56dc04c | 2008-07-04 12:24:14 -0400 | [diff] [blame] | 29 | if(s->foreground) |
| 30 | srv(s); |
| 31 | else |
| 32 | proccreate(launchsrv, s, 32*1024); |
rsc | 2277c5d | 2004-03-21 04:33:13 +0000 | [diff] [blame] | 33 | } |