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

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

Issue 1716893002: [fusl] Remove LFS64 macro (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: apptest rebase Created 4 years, 10 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/getrlimit.c ('k') | fusl/src/misc/nftw.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include <unistd.h> 1 #include <unistd.h>
2 #include <fcntl.h> 2 #include <fcntl.h>
3 #include <errno.h> 3 #include <errno.h>
4 #include "libc.h" 4 #include "libc.h"
5 5
6 int lockf(int fd, int op, off_t size) { 6 int lockf(int fd, int op, off_t size) {
7 struct flock l = { 7 struct flock l = {
8 .l_type = F_WRLCK, .l_whence = SEEK_CUR, .l_len = size, 8 .l_type = F_WRLCK, .l_whence = SEEK_CUR, .l_len = size,
9 }; 9 };
10 switch (op) { 10 switch (op) {
11 case F_TEST: 11 case F_TEST:
12 l.l_type = F_RDLCK; 12 l.l_type = F_RDLCK;
13 if (fcntl(fd, F_GETLK, &l) < 0) 13 if (fcntl(fd, F_GETLK, &l) < 0)
14 return -1; 14 return -1;
15 if (l.l_type == F_UNLCK || l.l_pid == getpid()) 15 if (l.l_type == F_UNLCK || l.l_pid == getpid())
16 return 0; 16 return 0;
17 errno = EACCES; 17 errno = EACCES;
18 return -1; 18 return -1;
19 case F_ULOCK: 19 case F_ULOCK:
20 l.l_type = F_UNLCK; 20 l.l_type = F_UNLCK;
21 case F_TLOCK: 21 case F_TLOCK:
22 return fcntl(fd, F_SETLK, &l); 22 return fcntl(fd, F_SETLK, &l);
23 case F_LOCK: 23 case F_LOCK:
24 return fcntl(fd, F_SETLKW, &l); 24 return fcntl(fd, F_SETLKW, &l);
25 } 25 }
26 errno = EINVAL; 26 errno = EINVAL;
27 return -1; 27 return -1;
28 } 28 }
29
30 LFS64(lockf);
OLDNEW
« no previous file with comments | « fusl/src/misc/getrlimit.c ('k') | fusl/src/misc/nftw.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698