source: asp3_tinet_ecnl_arm/trunk/musl-1.1.18/src/misc/lockf.c@ 352

Last change on this file since 352 was 352, checked in by coas-nagasima, 6 years ago

arm向けASP3版ECNLを追加

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/x-csrc;charset=UTF-8
File size: 578 bytes
Line 
1#include <unistd.h>
2#include <fcntl.h>
3#include <errno.h>
4#include "libc.h"
5
6int lockf(int fd, int op, off_t size)
7{
8 struct flock l = {
9 .l_type = F_WRLCK,
10 .l_whence = SEEK_CUR,
11 .l_len = size,
12 };
13 switch (op) {
14 case F_TEST:
15 l.l_type = F_RDLCK;
16 if (fcntl(fd, F_GETLK, &l) < 0)
17 return -1;
18 if (l.l_type == F_UNLCK || l.l_pid == getpid())
19 return 0;
20 errno = EACCES;
21 return -1;
22 case F_ULOCK:
23 l.l_type = F_UNLCK;
24 case F_TLOCK:
25 return fcntl(fd, F_SETLK, &l);
26 case F_LOCK:
27 return fcntl(fd, F_SETLKW, &l);
28 }
29 errno = EINVAL;
30 return -1;
31}
32
33LFS64(lockf);
Note: See TracBrowser for help on using the repository browser.