-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbridge.h
105 lines (78 loc) · 3.3 KB
/
bridge.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#ifndef _BRIDGE_H_
#define _BRIDGE_H_
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
/*--------------------------------------------------------------------*/
struct file_info {
uint64_t handle;
uint32_t flags;
bool direct_io;
};
struct file_attributes {
uint64_t size;
uint32_t mode;
uint32_t uid;
uint32_t gid;
};
/*----------------------------------------------------------------------------*/
/* Returns values of the form 0 (success), -ENOENT, -EACCES, etc.
*
* The "file_info" struct will arrive with whatever values were
* set inside of the fuse "fuse_file_info" struct. After the
* callback has completed, the members of *info will be loaded
* back into the fuse struct. */
typedef int (*python_open_ptr)(const char *path, struct file_info *info);
/* Returns values of the form 0 (success), -ENOENT, -EACCES, etc.
*
* The 'entries' record should be pointed to a 2-D array (created
* by Python). The Python function that supplies this should use
* bridge.c's zalloc() function to allocate all memory. */
typedef int (*python_readdir_ptr)(const char *path, char ***entries);
/* Returns values of the form 0 (success), -ENOENT (no file), or -EACCES
* (invalid permission mask for file). */
typedef int (*python_access_ptr)(const char *path, uint32_t mask);
/* Returns values of the form 0 (success), -ENOENT, -EACCES, etc.
*
* The 'attributes' struct will arrive pre-loaded with whatever
* values FUSE uses as a default. After the callback the equivalent
* FUSE struct will be re-populated. */
typedef int (*python_getattr_ptr)(const char *path,
struct file_attributes *attr);
/* Returns values of the form 0 (success), -ENOENT, -EACCES, etc.
*
* The "file_info" struct will arrive with whatever values were
* set inside of the fuse "fuse_file_info" struct. After the
* callback has completed, the members of *info will be loaded
* back into the fuse struct. */
typedef int (*python_read_ptr)(const char *path, char *outbuf, uint64_t size,
uint64_t offset, struct file_info *info);
/* Returns values of the form 0 (success), -ENOENT, -EACCES, etc.
*
* The "file_info" struct will arrive with whatever values were
* set inside of the fuse "fuse_file_info" struct. After the
* callback has completed, the members of *info will be loaded
* back into the fuse struct. */
typedef int (*python_write_ptr)(const char *path, const char *inbuf,
uint64_t size, uint64_t offset,
struct file_info *info);
/* Returns values of the form 0 (success), -ENOENT, -EACCES, etc. */
typedef int (*python_truncate_ptr)(const char *path, uint64_t size);
/*--------------------------------------------------------------------*/
struct callbacks {
python_open_ptr open;
python_readdir_ptr readdir;
python_getattr_ptr getattr;
python_access_ptr access;
python_read_ptr read;
python_write_ptr write;
python_truncate_ptr truncate;
};
/*--------------------------------------------------------------------*/
extern struct callbacks python_callbacks;
int bridge_main(int argc, char *argv[]);
void *zalloc(size_t size);
void zfree(void *ptr);
/*--------------------------------------------------------------------*/
int debug_write(char *string);
#endif