more
This commit is contained in:
parent
56e3c29015
commit
8612247402
4 changed files with 54 additions and 1 deletions
|
|
@ -27,3 +27,16 @@ fsclose(CFid *fid)
|
||||||
/* maybe someday there will be a ref count */
|
/* maybe someday there will be a ref count */
|
||||||
fidclunk(fid);
|
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;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,17 +9,37 @@ fscreate(CFsys *fs, char *name, int mode, ulong perm)
|
||||||
{
|
{
|
||||||
CFid *fid;
|
CFid *fid;
|
||||||
Fcall tx, rx;
|
Fcall tx, rx;
|
||||||
|
char *p, *dir, *elem;
|
||||||
|
|
||||||
if((fid = _fswalk(fs->root, name)) == nil)
|
p = strrchr(name, '/');
|
||||||
|
if(p == nil){
|
||||||
|
dir = "";
|
||||||
|
elem = name;
|
||||||
|
}else{
|
||||||
|
dir = name;
|
||||||
|
*p = 0;
|
||||||
|
elem = p+1;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprint(2, "create %s %s\n", dir, elem);
|
||||||
|
if((fid = _fswalk(fs->root, dir)) == nil){
|
||||||
|
if(p)
|
||||||
|
*p = '/';
|
||||||
return nil;
|
return nil;
|
||||||
|
}
|
||||||
tx.type = Tcreate;
|
tx.type = Tcreate;
|
||||||
|
tx.name = elem;
|
||||||
tx.fid = fid->fid;
|
tx.fid = fid->fid;
|
||||||
tx.mode = mode;
|
tx.mode = mode;
|
||||||
tx.perm = perm;
|
tx.perm = perm;
|
||||||
if(_fsrpc(fs, &tx, &rx, 0) < 0){
|
if(_fsrpc(fs, &tx, &rx, 0) < 0){
|
||||||
|
if(p)
|
||||||
|
*p = '/';
|
||||||
fsclose(fid);
|
fsclose(fid);
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
if(p)
|
||||||
|
*p = '/';
|
||||||
fid->mode = mode;
|
fid->mode = mode;
|
||||||
return fid;
|
return fid;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,7 @@ OFILES=\
|
||||||
open.$O\
|
open.$O\
|
||||||
openfd.$O\
|
openfd.$O\
|
||||||
read.$O\
|
read.$O\
|
||||||
|
remove.$O\
|
||||||
seek.$O\
|
seek.$O\
|
||||||
stat.$O\
|
stat.$O\
|
||||||
walk.$O\
|
walk.$O\
|
||||||
|
|
|
||||||
19
src/lib9pclient/remove.c
Normal file
19
src/lib9pclient/remove.c
Normal file
|
|
@ -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);
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue