summaryrefslogtreecommitdiff
path: root/sys/src/lib9p/srv.c
diff options
context:
space:
mode:
authoraiju <aiju@phicode.de>2011-07-27 10:46:34 +0200
committeraiju <aiju@phicode.de>2011-07-27 10:46:34 +0200
commitabe6ead0ffc3167871d39d62502afe36e9a5d2c9 (patch)
treef6d5f26e5249b9629966f48280b95d106806ca84 /sys/src/lib9p/srv.c
parentc08f86254ef0cce80eb9a532c25c50bf20bcc126 (diff)
lib9p: added functions for devshr
Diffstat (limited to 'sys/src/lib9p/srv.c')
-rw-r--r--sys/src/lib9p/srv.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/sys/src/lib9p/srv.c b/sys/src/lib9p/srv.c
index 82e2240b4..bbe025b46 100644
--- a/sys/src/lib9p/srv.c
+++ b/sys/src/lib9p/srv.c
@@ -851,3 +851,29 @@ postfd(char *name, int pfd)
return 0;
}
+int
+sharefd(char *name, char *desc, char *flags, int pfd)
+{
+ int fd;
+ char buf[80];
+
+ snprint(buf, sizeof buf, "#σc/%s", name);
+ if(chatty9p)
+ fprint(2, "sharefd %s\n", buf);
+ fd = create(buf, OWRITE, 0600);
+ if(fd < 0){
+ if(chatty9p)
+ fprint(2, "create fails: %r\n");
+ return -1;
+ }
+ if(fprint(fd, "%s %d %s\n", flags, pfd, desc) < 0){
+ if(chatty9p)
+ fprint(2, "write fails: %r\n");
+ close(fd);
+ return -1;
+ }
+ close(fd);
+ if(chatty9p)
+ fprint(2, "sharefd successful\n");
+ return 0;
+}