Uninitialized vector entry?
[minix3.git] / lib / other / flock.c
blob5535a6dd85ecaac8f064cb008e82073544ffb3a6
2 /* Library routines
4 * Porting to Minix 2.0.0
5 * Author: Giovanni Falzoni <gfalzoni@pointest.com>
7 * $Id$
8 */
9 #include <sys/types.h>
10 #include <fcntl.h>
11 #include <string.h>
12 #include <errno.h>
13 #include <unistd.h>
16 * Name: int flock(int fd, int mode);
17 * Function: Implements the flock function in Minix.
19 int flock(int fd, int mode)
21 struct flock lck;
22 register int retcode;
24 memset((void *) &lck, 0, sizeof(struct flock));
25 lck.l_type = mode & ~LOCK_NB;
26 lck.l_pid = getpid();
27 if ((retcode = fcntl(fd, mode & LOCK_NB ? F_SETLK : F_SETLKW, &lck)) < 0 && errno == EAGAIN)
28 errno = EWOULDBLOCK;
29 return retcode;
32 /** flock.c **/