aboutsummaryrefslogtreecommitdiff
path: root/src/lib9p/tpost.c
blob: 17848551304bb14ae1b797f55481e74de71d0e30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <u.h>
#include <libc.h>
#include <fcall.h>
#include <thread.h>
#include <9p.h>

static void
launchsrv(void *v)
{
	srv(v);
}

void
threadpostmountsrv(Srv *s, char *name, char *mtpt, int flag)
{
	int fd[2];

	if(!s->nopipe){
		if(pipe(fd) < 0)
			sysfatal("pipe: %r");
		s->infd = s->outfd = fd[1];
		s->srvfd = fd[0];
	}
	if(name || mtpt){
		if(post9pservice(s->srvfd, name, mtpt) < 0)
			sysfatal("post9pservice %s: %r", name);
	}else if(!s->nopipe)
		sysfatal("no one to serve");
	if(s->foreground)
		srv(s);
	else
		proccreate(launchsrv, s, 32*1024);
}