source: tags/syscall-add-simple-foo/minix/lib/other/flock.c@ 15

Last change on this file since 15 was 9, checked in by Mattia Monga, 13 years ago

Minix 3.1.2a

File size: 698 bytes
Line 
1
2/* Library routines
3 *
4 * Porting to Minix 2.0.0
5 * Author: Giovanni Falzoni <gfalzoni@pointest.com>
6 *
7 * $Id: flock.c,v 1.1 2005/10/31 14:31:05 beng Exp $
8 */
9#include <sys/types.h>
10#include <fcntl.h>
11#include <string.h>
12#include <errno.h>
13#include <unistd.h>
14
15/*
16 * Name: int flock(int fd, int mode);
17 * Function: Implements the flock function in Minix.
18 */
19int flock(int fd, int mode)
20{
21 struct flock lck;
22 register int retcode;
23
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;
30}
31
32/** flock.c **/
Note: See TracBrowser for help on using the repository browser.