added python installer
[tridge/junkcode.git] / lock64.c
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <fcntl.h>
4 #include <unistd.h>
5 #include <string.h>
6 #include <fcntl.h>
7 #include <errno.h>
8 #include <sys/mman.h>
9 #include <sys/stat.h>
10
11
12 #define fcntl fcntl64
13 #undef F_SETLKW 
14 #undef F_SETLK
15 #define F_SETLK 13
16 #define F_SETLKW 14
17
18
19 int fcntl64(int fd, int cmd, struct flock * lock)
20 {
21         return syscall(221, fd, cmd, lock);
22 }
23
24 int main(int argc, char *argv[])
25 {
26         struct flock fl;
27         int fd, ret;
28
29         printf("sizeof(fl.l_start)=%d\n", sizeof(fl.l_start));
30         fd = open("lock64.dat", O_RDWR|O_CREAT);
31
32         fl.l_type = F_RDLCK;
33         fl.l_whence = SEEK_SET;
34         fl.l_start = 16;
35         fl.l_len = 1;
36         fl.l_pid = 0;
37
38         ret = fcntl(fd, F_SETLKW, &fl);
39
40         printf("ret=%d pid=%d\n", ret, getpid());
41
42         sleep(30);
43         return 0;
44 }