1
#define _GNU_SOURCE /* for Linux O_DIRECT */
14
p9create(char *path, int mode, ulong perm)
16
int fd, cexec, umode, rclose, lock, rdwr;
22
rclose = mode&ORCLOSE;
23
mode &= ~(ORCLOSE|OCEXEC|OLOCK);
25
/* XXX should get mode mask right? */
29
werrstr("bad mode in directory create");
32
if(mkdir(path, perm&0777) < 0)
34
fd = open(path, O_RDONLY);
36
umode = (mode&3)|O_CREAT|O_TRUNC;
51
werrstr("unsupported mode in create");
54
fd = open(path, umode, perm);
59
fl.l_type = (rdwr==OREAD) ? F_RDLCK : F_WRLCK;
60
fl.l_whence = SEEK_SET;
63
if(fcntl(fd, F_SETLK, &fl) < 0){
70
fcntl(fd, F_SETFL, FD_CLOEXEC);