diff options
author | rsc <devnull@localhost> | 2006-01-27 04:08:41 +0000 |
---|---|---|
committer | rsc <devnull@localhost> | 2006-01-27 04:08:41 +0000 |
commit | 86122474029f9aa85a6d036d23e8a4fa60d5ed4b (patch) | |
tree | d7680c7dabd565e3f6e4795cc96accbbf6f56be5 | |
parent | 56e3c29015da2147dbb308b4957fffceebcda657 (diff) | |
download | plan9port-86122474029f9aa85a6d036d23e8a4fa60d5ed4b.tar.gz plan9port-86122474029f9aa85a6d036d23e8a4fa60d5ed4b.tar.bz2 plan9port-86122474029f9aa85a6d036d23e8a4fa60d5ed4b.zip |
more
-rw-r--r-- | src/lib9pclient/close.c | 13 | ||||
-rw-r--r-- | src/lib9pclient/create.c | 22 | ||||
-rw-r--r-- | src/lib9pclient/mkfile | 1 | ||||
-rw-r--r-- | src/lib9pclient/remove.c | 19 |
4 files changed, 54 insertions, 1 deletions
diff --git a/src/lib9pclient/close.c b/src/lib9pclient/close.c index 98c6cfb2..9303b17d 100644 --- a/src/lib9pclient/close.c +++ b/src/lib9pclient/close.c @@ -27,3 +27,16 @@ fsclose(CFid *fid) /* maybe someday there will be a ref count */ fidclunk(fid); } + +int +fsfremove(CFid *fid) +{ + int n; + Fcall tx, rx; + + tx.type = Tremove; + tx.fid = fid->fid; + n = _fsrpc(fid->fs, &tx, &rx, 0); + _fsputfid(fid); + return n; +} diff --git a/src/lib9pclient/create.c b/src/lib9pclient/create.c index cbb4a3ac..934655ab 100644 --- a/src/lib9pclient/create.c +++ b/src/lib9pclient/create.c @@ -9,17 +9,37 @@ fscreate(CFsys *fs, char *name, int mode, ulong perm) { CFid *fid; Fcall tx, rx; + char *p, *dir, *elem; + + p = strrchr(name, '/'); + if(p == nil){ + dir = ""; + elem = name; + }else{ + dir = name; + *p = 0; + elem = p+1; + } - if((fid = _fswalk(fs->root, name)) == nil) +fprint(2, "create %s %s\n", dir, elem); + if((fid = _fswalk(fs->root, dir)) == nil){ + if(p) + *p = '/'; return nil; + } tx.type = Tcreate; + tx.name = elem; tx.fid = fid->fid; tx.mode = mode; tx.perm = perm; if(_fsrpc(fs, &tx, &rx, 0) < 0){ + if(p) + *p = '/'; fsclose(fid); return nil; } + if(p) + *p = '/'; fid->mode = mode; return fid; } diff --git a/src/lib9pclient/mkfile b/src/lib9pclient/mkfile index cbba9534..5f1eb78c 100644 --- a/src/lib9pclient/mkfile +++ b/src/lib9pclient/mkfile @@ -12,6 +12,7 @@ OFILES=\ open.$O\ openfd.$O\ read.$O\ + remove.$O\ seek.$O\ stat.$O\ walk.$O\ diff --git a/src/lib9pclient/remove.c b/src/lib9pclient/remove.c new file mode 100644 index 00000000..1eb77cdc --- /dev/null +++ b/src/lib9pclient/remove.c @@ -0,0 +1,19 @@ +/* Copyright (C) 2003 Russ Cox, Massachusetts Institute of Technology */ +/* See COPYRIGHT */ + +#include <u.h> +#include <libc.h> +#include <fcall.h> +#include <9pclient.h> +#include "fsimpl.h" + +int +fsremove(CFsys *fs, char *name) +{ + CFid *fid; + + if((fid = _fswalk(fs->root, name)) == nil) + return -1; + return fsfremove(fid); +} + |