9488aa4c04
Also fix the MINIX3 libc flock(3) implementation. Change-Id: Ia80280029968786d7f029940ec02e942057701bd
36 lines
760 B
C
36 lines
760 B
C
/* Library routines
|
|
*
|
|
* Porting to Minix 2.0.0
|
|
* Author: Giovanni Falzoni <gfalzoni@pointest.com>
|
|
*/
|
|
|
|
#include <sys/cdefs.h>
|
|
#include "namespace.h"
|
|
#include <lib.h>
|
|
|
|
#include <sys/types.h>
|
|
#include <fcntl.h>
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
#include <unistd.h>
|
|
|
|
/*
|
|
* Name: int flock(int fd, int mode);
|
|
* Function: Implements the flock function in Minix.
|
|
*/
|
|
int flock(int fd, int mode)
|
|
{
|
|
struct flock lck;
|
|
|
|
memset((void *) &lck, 0, sizeof(struct flock));
|
|
switch (mode & ~LOCK_NB) {
|
|
case LOCK_SH: lck.l_type = F_RDLCK; break;
|
|
case LOCK_EX: lck.l_type = F_WRLCK; break;
|
|
case LOCK_UN: lck.l_type = F_UNLCK; break;
|
|
default: errno = EINVAL; return -1;
|
|
}
|
|
return fcntl(fd, mode & LOCK_NB ? F_SETLK : F_SETLKW, &lck);
|
|
}
|
|
|
|
/** flock.c **/
|