The Pedigree Project 0.1
file-lock-contract-test/contract.h
1#ifndef FILE_LOCK_CONTRACT_H
2#define FILE_LOCK_CONTRACT_H
3#include <errno.h>
4#include <fcntl.h>
5#include <stdint.h>
6#include <stdio.h>
7#include <time.h>
8
9#include <sys/types.h>
10
11#define CHECK(condition) \
12 do { \
13 if (!(condition)) { \
14 fprintf(stderr, "%s:%d: %s (errno=%d)\n", __FILE__, __LINE__, #condition, errno); \
15 failed = 1; \
16 goto out; \
17 } \
18 } while (0)
19#define LOCK_APP "/applications/file-lock-contract-test"
20enum { FL_FLOCK, FL_CLASSIC, FL_OFD };
21
22int64_t fl_now(void);
23void fl_pause(int milliseconds);
24int fl_wait(volatile int* flag, int milliseconds);
25int fl_reap(pid_t child, int milliseconds);
26int fl_byte(int socket, char expected);
27int fl_send_fd(int socket, int fd);
28int fl_receive_fd(int socket);
29int fl_file(char path[128], const char* directory);
30int fl_record(int fd, int command, short type, short whence, off_t start, off_t length);
31int fl_lock(int fd, int kind, short type, int blocking);
32int fl_query(int fd, int command, off_t start, off_t length, short type, off_t expected_start,
33 off_t expected_length, pid_t owner);
34int file_lock_flock(void);
35int file_lock_records(void);
36int file_lock_lifetime(void);
37int file_lock_blocking(void);
38int file_lock_creation(void);
39int file_lock_exec(int argc, char** argv);
40#endif