The Pedigree Project 0.1
fanotify-handle-contract-test/contract.h
1#ifndef FANOTIFY_HANDLE_CONTRACT_H
2#define FANOTIFY_HANDLE_CONTRACT_H
3
4#include <errno.h>
5#include <fcntl.h>
6#include <stdint.h>
7#include <stdio.h>
8
9#include <sys/fanotify.h>
10#include <sys/types.h>
11
12#define FH_APP "/applications/fanotify-handle-contract-test"
13#define FH_QUEUE_LIMIT 256
14#define CHECK(condition) \
15 do { \
16 if (!(condition)) { \
17 fprintf(stderr, "%s:%d: %s (errno=%d)\n", __FILE__, __LINE__, #condition, errno); \
18 failed = 1; \
19 goto out; \
20 } \
21 } while (0)
22
23struct fh_handle {
24 unsigned handle_bytes;
25 int handle_type;
26 unsigned char bytes[128];
27};
28struct fh_file {
29 int fd, mount_id;
30 char path[192];
31 struct fh_handle handle;
32};
33struct fh_record {
34 uint64_t mask;
35 int pid;
36 unsigned char fsid[8];
37 struct fh_handle handle;
38};
39
40extern size_t fh_page;
41int64_t fh_now(void);
42void fh_pause(int milliseconds);
43int fh_wait(volatile int* flag, int milliseconds);
44int fh_reap(pid_t child, int milliseconds);
45int fh_send(int fd, char byte);
46int fh_receive(int fd, char byte);
47int fh_read_all(int fd, void* buffer, size_t length);
48int fh_write_all(int fd, const void* buffer, size_t length);
49int fh_send_fd(int socket, int fd);
50int fh_receive_fd(int socket);
51int fh_readable(int fd, int milliseconds);
52int fh_export(int fd, struct fh_handle* handle, int* mount_id);
53int fh_equal(const struct fh_handle* first, const struct fh_handle* second);
54int fh_create(struct fh_file* file);
55void fh_close(struct fh_file* file);
56int fh_group(int nonblock);
57int fh_mark(int group, const struct fh_file* file, unsigned flags, uint64_t mask);
58int fh_modify(const struct fh_file* file);
59size_t fh_record_size(const struct fh_handle* handle);
60int fh_parse(const void* bytes, size_t length, struct fh_record* record);
61int fh_take(int group, const struct fh_handle* shape, struct fh_record* record);
62int fh_event(int group, const struct fh_file* file, uint64_t mask, pid_t pid);
63int fh_drain(int group);
64int fh_handles(void);
65int fh_admission(void);
66int fh_events(void);
67int fh_queue(void);
68int fh_lifetime(void);
69int fh_waits(void);
70int fh_exec(int argc, char** argv);
71int fh_persistence(const char* base, const char* token, int write_stage);
72
73#endif