zero length means whole file
[tridge/hacksm.git] / hacksm.h
1 #define _XOPEN_SOURCE 500
2 #define _GNU_SOURCE 
3
4 #include <stdio.h>
5 #include <unistd.h>
6 #include <stdlib.h>
7 #include <errno.h>
8 #include <sys/stat.h>
9 #include <fcntl.h>
10 #include <string.h>
11 #include <getopt.h>
12 #include <signal.h>
13 #include <utime.h>
14 #include <stdbool.h>
15 #include <sys/mman.h>
16 #include <sys/time.h>
17 #include <sys/wait.h>
18 #include <time.h>
19 #include <aio.h>
20 #include <dmapi.h>
21 #include <stdint.h>
22
23 #define discard_const(ptr) ((void *)((intptr_t)(ptr)))
24
25 const char *dmapi_event_string(dm_eventtype_t ev);
26 void hsm_recover_session(const char *name, dm_sessid_t *sid);
27 int hsm_store_open(dev_t device, ino_t inode, int flags);
28 int hsm_store_unlink(dev_t device, ino_t inode);
29 void msleep(int t);
30 void hsm_cleanup_tokens(dm_sessid_t sid, dm_response_t response, int retcode);
31 const char *timestring(void);
32
33
34 enum hsm_migrate_state {
35         HSM_STATE_START     = 0,
36         HSM_STATE_MIGRATED  = 1,
37         HSM_STATE_RECALL    = 2};
38
39 struct hsm_attr {
40         char magic[4];
41         time_t migrate_time;
42         uint64_t size;
43         uint64_t device;
44         uint64_t inode;
45         enum hsm_migrate_state state;
46 };
47
48 #define HSM_MAGIC "HSM1"
49 #define HSM_ATTRNAME "hacksm"
50
51 #define HSM_STORE "/hacksm_store"