diff options
author | rsc <devnull@localhost> | 2005-01-04 21:22:40 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2005-01-04 21:22:40 +0000 |
commit | 46f79934b79ef526ed42bbe5a565e6b5d884d24a (patch) | |
tree | d1e663f7d3b2b328f03aeb34fdb3f4006aa97ec0 /src/lib9pclient/ns.c | |
parent | 5ba841dffa1f6cda712ebcff27c55c9d0a672c67 (diff) | |
download | plan9port-46f79934b79ef526ed42bbe5a565e6b5d884d24a.tar.gz plan9port-46f79934b79ef526ed42bbe5a565e6b5d884d24a.tar.bz2 plan9port-46f79934b79ef526ed42bbe5a565e6b5d884d24a.zip |
lib9pclient is the new libfs
Diffstat (limited to 'src/lib9pclient/ns.c')
-rw-r--r-- | src/lib9pclient/ns.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/src/lib9pclient/ns.c b/src/lib9pclient/ns.c new file mode 100644 index 00000000..9c86547e --- /dev/null +++ b/src/lib9pclient/ns.c @@ -0,0 +1,40 @@ +#include <u.h> +#include <libc.h> +#include <fcall.h> +#include <9pclient.h> +#include <ctype.h> + +CFsys* +nsmount(char *name, char *aname) +{ + char *addr, *ns; + int fd; + CFsys *fs; + + ns = getns(); + if(ns == nil) + return nil; + + addr = smprint("unix!%s/%s", ns, name); + free(ns); + if(addr == nil) + return nil; + + fd = dial(addr, 0, 0, 0); + if(fd < 0){ + werrstr("dial %s: %r", addr); + free(addr); + return nil; + } + free(addr); + + fcntl(fd, F_SETFL, FD_CLOEXEC); + + fs = fsmount(fd, aname); + if(fs == nil){ + close(fd); + return nil; + } + + return fs; +} |