The Pedigree Project 0.1
xattr-contract-test/contract.h
1#ifndef XATTR_CONTRACT_H
2#define XATTR_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 { XA_MEMFD, XA_RAMFS, XA_EXT2 };
20enum { XA_PATH, XA_LINK, XA_FD };
21struct xa_file {
22 int fd;
23 int backend;
24 int directory;
25 char path[192];
26};
27
28extern size_t xa_page;
29extern size_t xa_block;
30int64_t xa_now(void);
31int xa_reap(pid_t child, int milliseconds);
32int xa_send(int fd, char byte);
33int xa_receive(int fd, char expected);
34int xa_read_all(int fd, void* buffer, size_t length);
35int xa_write_all(int fd, const void* buffer, size_t length);
36int xa_create(struct xa_file* file, int backend, int directory);
37int xa_open_alias(const struct xa_file* file);
38void xa_close(struct xa_file* file);
39int xa_set(const struct xa_file* file, int how, const char* name, const void* value, size_t size,
40 int flags);
41ssize_t xa_get(const struct xa_file* file, int how, const char* name, void* value, size_t size);
42ssize_t xa_list(const struct xa_file* file, int how, char* names, size_t size);
43int xa_remove(const struct xa_file* file, int how, const char* name);
44int xa_value(const struct xa_file* file, int how, const char* name, const void* value, size_t size);
45int xa_names(const struct xa_file* file, int how, const char* const* names, size_t count);
46int xa_unprivileged(uid_t uid, gid_t gid, const gid_t* groups, size_t count);
47int xa_values(void);
48int xa_admission(void);
49int xa_permissions(void);
50int xa_lifetime(void);
51int xa_concurrency(void);
52int xa_events(void);
53int xa_ext2(void);
54int xa_persistence(const char* base, const char* token, int write_stage);
55
56#endif