3 * Porting to Minix 2.0.0
4 * Author: Giovanni Falzoni <gfalzoni@pointest.com>
11 #include <sys/types.h>
18 * Name: int flock(int fd, int mode);
19 * Function: Implements the flock function in Minix.
21 int flock(int fd
, int mode
)
25 memset((void *) &lck
, 0, sizeof(struct flock
));
26 switch (mode
& ~LOCK_NB
) {
27 case LOCK_SH
: lck
.l_type
= F_RDLCK
; break;
28 case LOCK_EX
: lck
.l_type
= F_WRLCK
; break;
29 case LOCK_UN
: lck
.l_type
= F_UNLCK
; break;
30 default: errno
= EINVAL
; return -1;
32 return fcntl(fd
, mode
& LOCK_NB
? F_SETLK
: F_SETLKW
, &lck
);