custom message type for VM_QUERY_EXIT
[minix3.git] / lib / libc / sys-minix / flock.c
blob9163598eb6c394ae49a80aa0f0430f26e210118f
1 /* Library routines
3 * Porting to Minix 2.0.0
4 * Author: Giovanni Falzoni <gfalzoni@pointest.com>
5 */
7 #include <sys/cdefs.h>
8 #include "namespace.h"
9 #include <lib.h>
11 #include <sys/types.h>
12 #include <fcntl.h>
13 #include <string.h>
14 #include <errno.h>
15 #include <unistd.h>
18 * Name: int flock(int fd, int mode);
19 * Function: Implements the flock function in Minix.
21 int flock(int fd, int mode)
23 struct flock lck;
24 register int retcode;
26 memset((void *) &lck, 0, sizeof(struct flock));
27 lck.l_type = mode & ~LOCK_NB;
28 lck.l_pid = getpid();
29 if ((retcode = fcntl(fd, mode & LOCK_NB ? F_SETLK : F_SETLKW, &lck)) < 0 && errno == EAGAIN)
30 errno = EWOULDBLOCK;
31 return retcode;
34 /** flock.c **/