diff options
author | cinap_lenrek <cinap_lenrek@felloff.net> | 2021-05-01 19:58:58 +0200 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@felloff.net> | 2021-05-01 19:58:58 +0200 |
commit | ee289c241577a3553bfd73211cd81e137ab4fe40 (patch) | |
tree | 8f40ebfb2769de543c133120c5dbc468beddc9eb /sys/man | |
parent | 57c21ae441d1b6af38ce310ffec87340488ed84b (diff) |
lib9p: remove Srv.srvfd, make postsrv() and threadpostsrv() return the mountable file descriptor, update documentation
Now that we have these new functions,
we can also make them return an error
instead of calling sysfatal() like
postmountsrv().
Remove the confusing Srv.srvfd, as it
is only temporarily used and return
it from postsrv() instead.
Diffstat (limited to 'sys/man')
-rw-r--r-- | sys/man/2/9p | 77 |
1 files changed, 40 insertions, 37 deletions
diff --git a/sys/man/2/9p b/sys/man/2/9p index d68fbaa2c..4fb831d09 100644 --- a/sys/man/2/9p +++ b/sys/man/2/9p @@ -63,7 +63,6 @@ typedef struct Srv { int infd; int outfd; - int srvfd; void (*forker)(void (*fn)(void*), void *arg, int flags); } Srv; @@ -73,12 +72,12 @@ typedef struct Srv { .ft L .ta \w'\fLvoid* 'u void srv(Srv *s) -void postsrv(Srv *s, char *name); +int postsrv(Srv *s, char *name); void postmountsrv(Srv *s, char *name, char *mtpt, int flag) void postsharesrv(Srv *s, char *name, char *mtpt, char *desc) void listensrv(Srv *s, char *addr) void threadsrv(Srv *s) -void threadpostsrv(Srv *s, char *name); +int threadpostsrv(Srv *s, char *name); void threadpostmountsrv(Srv *s, char *name, char *mtpt, int flag) void threadpostsharesrv(Srv *s, char *name, char *mtpt, char *desc) void threadlistensrv(Srv *s, char *addr) @@ -193,38 +192,32 @@ or (see .IR thread (2)). .PP -.I Postmountsrv + +.I Postsrv and -.I threadpostmountsrv +.I threadpostsrv are wrappers that create a separate process in which to run .IR srv . They do the following: .IP Initialize -.IB s -> forker -to eigther -.I srvforker -or -.I threadsrvforker -unless already initialized to a non-nil value. -.IP -Initialize .IB s -> infd and .IB s -> outfd -to be one end of a freshly allocated pipe, -with -.IB s -> srvfd -initialized as the other end. +to be one end of a freshly allocated pipe. .IP If .B name -is non-nil, post the file descriptor -.IB s -> srvfd -under the name -.BI /srv/ name -using a call to -.IR postsrv . +is non-nil, post the other end file descriptor under the name +.BI /srv/ name . +.IP +Initialize +.IB s -> forker +to eigther +.I srvforker +or +.I threadsrvforker +unless already initialized to a non-nil value. .IP Fork a child process via .IB s -> forker @@ -248,27 +241,37 @@ flag. This way, the service loop will share the original file descriptor table with previously created child processes of the caller. .IP -The child process then calls -.IB close( s -> srvfd ) -and then -.IB srv( s ) \fR; -it will exit once -.I srv -returns. +The child process then closes the other end file descriptor +and calls +.IR srv . .IP -If +The parent process returns from the function with the +mountable file descriptor +.IR sfd . +On error, +.I postsrv +and +.I threadpostsrv +return a file descriptor of +.BR -1 +with error string set. +.PP +.I Postmountsrv +and +.I threadpostmntsrv +call +.I postsrv +with +.I name +and then if .I mtpt is non-nil, call -.BI amount( s -> srvfd, +.BI amount( sfd , .IB mtpt , .IB flag , \fB"")\fR; -otherwise, close -.IB s -> srvfd \fR. -.IP -The parent returns to the caller. -.LP +otherwise, close the file descriptor. If any error occurs during this process, the entire process is terminated by calling .I sysfatal |