plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

tpost.c (564B)


      1 #include <u.h>
      2 #include <libc.h>
      3 #include <fcall.h>
      4 #include <thread.h>
      5 #include <9p.h>
      6 
      7 static void
      8 launchsrv(void *v)
      9 {
     10 	srv(v);
     11 }
     12 
     13 void
     14 threadpostmountsrv(Srv *s, char *name, char *mtpt, int flag)
     15 {
     16 	int fd[2];
     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 	}
     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");
     29 	if(s->foreground)
     30 		srv(s);
     31 	else
     32 		proccreate(launchsrv, s, 32*1024);
     33 }