aboutsummaryrefslogtreecommitdiff
path: root/src/lib9pclient/openfd.c
diff options
context:
space:
mode:
authorrsc <devnull@localhost>2005-01-04 21:22:40 +0000
committerrsc <devnull@localhost>2005-01-04 21:22:40 +0000
commit46f79934b79ef526ed42bbe5a565e6b5d884d24a (patch)
treed1e663f7d3b2b328f03aeb34fdb3f4006aa97ec0 /src/lib9pclient/openfd.c
parent5ba841dffa1f6cda712ebcff27c55c9d0a672c67 (diff)
downloadplan9port-46f79934b79ef526ed42bbe5a565e6b5d884d24a.tar.gz
plan9port-46f79934b79ef526ed42bbe5a565e6b5d884d24a.tar.bz2
plan9port-46f79934b79ef526ed42bbe5a565e6b5d884d24a.zip
lib9pclient is the new libfs
Diffstat (limited to 'src/lib9pclient/openfd.c')
-rw-r--r--src/lib9pclient/openfd.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/lib9pclient/openfd.c b/src/lib9pclient/openfd.c
new file mode 100644
index 00000000..ef26e5c4
--- /dev/null
+++ b/src/lib9pclient/openfd.c
@@ -0,0 +1,26 @@
+#include <u.h>
+#include <libc.h>
+#include <fcall.h>
+#include <9pclient.h>
+#include "fsimpl.h"
+
+int
+fsopenfd(CFsys *fs, char *name, int mode)
+{
+ CFid *fid;
+ Fcall tx, rx;
+
+ if((fid = _fswalk(fs->root, name)) == nil)
+ return -1;
+ tx.type = Topenfd;
+ tx.fid = fid->fid;
+ tx.mode = mode&~OCEXEC;
+ if(_fsrpc(fs, &tx, &rx, 0) < 0){
+ fsclose(fid);
+ return -1;
+ }
+ _fsputfid(fid);
+ if(mode&OCEXEC && rx.unixfd>=0)
+ fcntl(rx.unixfd, F_SETFL, FD_CLOEXEC);
+ return rx.unixfd;
+}