The Pedigree Project 0.1
file-resize-contract-test/contract.h
1#ifndef FILE_RESIZE_CONTRACT_H
2#define FILE_RESIZE_CONTRACT_H
3
4#include <errno.h>
5#include <stdint.h>
6#include <stdio.h>
7
8#include <sys/types.h>
9
10#define CHECK(condition) \
11 do { \
12 if (!(condition)) { \
13 fprintf(stderr, "%s:%d: %s (errno=%d)\n", __FILE__, __LINE__, #condition, errno); \
14 failed = 1; \
15 goto out; \
16 } \
17 } while (0)
18
19enum { FR_MEMFD, FR_RAMFS, FR_EXT2 };
20struct fr_file {
21 int fd;
22 int backend;
23 char path[128];
24};
25
26extern size_t fr_page;
27int fr_create(struct fr_file* file, int backend);
28int fr_open_alias(const struct fr_file* file);
29void fr_close(struct fr_file* file);
30unsigned char fr_pattern(size_t offset);
31int fr_matches(const volatile unsigned char* bytes, size_t offset, size_t length, int zero);
32int fr_contents(int fd, size_t offset, size_t length, int zero);
33int fr_size(int fd, size_t size);
34int fr_resident(void* address, size_t pages, unsigned bits, const char* stage);
35int fr_send(int fd, char byte);
36int fr_receive(int fd, char byte);
37int fr_reap(pid_t child, int milliseconds);
38int fr_fault(void* address);
39int fr_shared(int backend);
40int fr_private(int backend);
41int fr_seals(void);
42
43#endif