Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: fusl/src/misc/lockf.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fusl/src/misc/issetugid.c ('k') | fusl/src/misc/login_tty.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include <unistd.h>
2 #include <fcntl.h>
3 #include <errno.h>
4 #include "libc.h"
5
6 int 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
33 LFS64(lockf);
OLDNEW
« no previous file with comments | « fusl/src/misc/issetugid.c ('k') | fusl/src/misc/login_tty.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698