blob: 210b16849df20ae241a8a6332af511415c29a6e6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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;
}
|