add
This commit is contained in:
parent
8612247402
commit
1ac60148eb
2 changed files with 37 additions and 0 deletions
36
src/lib9pclient/access.c
Executable file
36
src/lib9pclient/access.c
Executable file
|
|
@ -0,0 +1,36 @@
|
||||||
|
#include <u.h>
|
||||||
|
#include <libc.h>
|
||||||
|
#include <fcall.h>
|
||||||
|
#include <9pclient.h>
|
||||||
|
#include "fsimpl.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
fsaccess(CFsys *fsys, char *name, int mode)
|
||||||
|
{
|
||||||
|
CFid *fid;
|
||||||
|
Dir *db;
|
||||||
|
static char omode[] = {
|
||||||
|
0,
|
||||||
|
OEXEC,
|
||||||
|
OWRITE,
|
||||||
|
ORDWR,
|
||||||
|
OREAD,
|
||||||
|
OEXEC, /* only approximate */
|
||||||
|
ORDWR,
|
||||||
|
ORDWR /* only approximate */
|
||||||
|
};
|
||||||
|
|
||||||
|
if(mode == AEXIST){
|
||||||
|
db = fsdirstat(fsys, name);
|
||||||
|
free(db);
|
||||||
|
if(db != nil)
|
||||||
|
return 0;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
fid = fsopen(fsys, name, omode[mode&7]);
|
||||||
|
if(fid != nil){
|
||||||
|
fsclose(fid);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
LIB=lib9pclient.a
|
LIB=lib9pclient.a
|
||||||
|
|
||||||
OFILES=\
|
OFILES=\
|
||||||
|
access.$O\
|
||||||
auth.$O\
|
auth.$O\
|
||||||
close.$O\
|
close.$O\
|
||||||
create.$O\
|
create.$O\
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue