Warning: Attempt to read property "date" on null in /usr/local/www/websvn.planix.org/blame.php on line 247

Warning: Attempt to read property "msg" on null in /usr/local/www/websvn.planix.org/blame.php on line 247
WebSVN – planix.SVN – Blame – /os/branches/planix-v0/sys/src/libc/9sys/access.c – Rev 2

Subversion Repositories planix.SVN

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 - 1
#include <u.h>
2
#include <libc.h>
3
 
4
int
5
access(char *name, int mode)
6
{
7
	int fd;
8
	Dir *db;
9
	static char omode[] = {
10
		0,
11
		OEXEC,
12
		OWRITE,
13
		ORDWR,
14
		OREAD,
15
		OEXEC,	/* only approximate */
16
		ORDWR,
17
		ORDWR	/* only approximate */
18
	};
19
 
20
	if(mode == AEXIST){
21
		db = dirstat(name);
22
		free(db);
23
		if(db != nil)
24
			return 0;
25
		return -1;
26
	}
27
	fd = open(name, omode[mode&7]);
28
	if(fd >= 0){
29
		close(fd);
30
		return 0;
31
	}
32
	return -1;
33
}