1
+ #include "riscv.h"
2
+ #include "virtio.h"
3
+
4
+ #define FUSE_REC_ALIGN (x ) \
5
+ (((x) + sizeof(uint64_t) - 1) & ~(sizeof(uint64_t) - 1))
6
+ #define FUSE_DIRENT_ALIGN (x ) FUSE_REC_ALIGN(x)
7
+
8
+ struct fuse_in_header {
9
+ uint32_t len ;
10
+ uint32_t opcode ;
11
+ uint64_t unique ;
12
+ uint64_t nodeid ;
13
+ uint32_t uid ;
14
+ uint32_t gid ;
15
+ uint32_t pid ;
16
+ uint32_t padding ;
17
+ };
18
+
19
+ struct fuse_out_header {
20
+ uint32_t len ;
21
+ int32_t error ;
22
+ uint64_t unique ;
23
+ };
24
+
25
+ struct vfs_req_header {
26
+ struct fuse_in_header in ;
27
+ };
28
+
29
+ struct vfs_resp_header {
30
+ struct fuse_out_header out ;
31
+ };
32
+
33
+ struct fuse_init_in {
34
+ /* FUSE major version supported by the guest (typically 7) */
35
+ uint32_t major ;
36
+ /* FUSE minor version supported by the guest (e.g., 31, 26) */
37
+ uint32_t minor ;
38
+ uint32_t max_readahead ; /* Maximum readahead size supported by the guest */
39
+ uint32_t flags ; /* Flags requested by the guest */
40
+ };
41
+
42
+ struct fuse_init_out {
43
+ uint32_t major ; /* FUSE major version supported by the device */
44
+ uint32_t minor ; /* FUSE minor version supported by the device */
45
+ uint32_t max_readahead ; /* Maximum readahead size accepted by the device */
46
+ /* Flags supported by the device (negotiated with the guest) */
47
+ uint32_t flags ;
48
+ uint16_t max_background ; /* Maximum number of background requests */
49
+ uint16_t congestion_threshold ;
50
+ uint32_t max_write ; /* Maximum write size the device can handle */
51
+ uint32_t time_gran ; /* Time granularity (in nanoseconds) */
52
+ uint32_t unused [11 ]; /* Reserved */
53
+ };
54
+
55
+ struct fuse_getattr_in {
56
+ /* bitmask for valid fields (e.g. FUSE_GETATTR_FH) */
57
+ uint32_t getattr_flags ;
58
+ uint32_t padding ; /* unused, reserved for alignment */
59
+ uint64_t fh ; /* optional: file handle (used when getattr_flags has */
60
+ };
61
+
62
+ struct fuse_attr {
63
+ uint64_t ino ; /* inode number */
64
+ uint64_t size ; /* file size in bytes */
65
+ uint64_t blocks ; /* number of 512B blocks allocated */
66
+ uint64_t atime ; /* last access time (UNIX time) */
67
+ uint64_t mtime ; /* last modification time */
68
+ uint64_t ctime ; /* last status change time */
69
+ uint32_t atimensec ; /* nanoseconds part */
70
+ uint32_t mtimensec ;
71
+ uint32_t ctimensec ;
72
+ uint32_t mode ; /* file mode (e.g. S_IFDIR | 0755) */
73
+ uint32_t nlink ; /* number of hard links */
74
+ uint32_t uid ; /* owner uid */
75
+ uint32_t gid ; /* owner gid */
76
+ uint32_t rdev ; /* device ID (if special file) */
77
+ uint32_t blksize ; /* block size */
78
+ uint32_t flags ; /* reserved */
79
+ };
80
+
81
+ struct fuse_attr_out {
82
+ uint64_t attr_valid ; /* seconds the attributes are valid */
83
+ uint32_t attr_valid_nsec ; /* nanoseconds part of attr_valid */
84
+ uint32_t dummy ; /* padding for alignment */
85
+ struct fuse_attr attr ; /* actual attributes */
86
+ };
87
+
88
+ struct fuse_open_in {
89
+ uint32_t flags ;
90
+ uint32_t open_flags ;
91
+ };
92
+
93
+ struct fuse_open_out {
94
+ uint64_t fh ;
95
+ uint32_t open_flags ;
96
+ int32_t backing_id ;
97
+ };
98
+
99
+ struct fuse_read_in {
100
+ uint64_t fh ;
101
+ uint64_t offset ;
102
+ uint32_t size ;
103
+ uint32_t read_flags ;
104
+ uint64_t lock_owner ;
105
+ uint32_t flags ;
106
+ uint32_t padding ;
107
+ };
108
+
109
+ struct fuse_entry_out {
110
+ uint64_t nodeid ; /* inode number */
111
+ uint64_t generation ; /* inode generation */
112
+ uint64_t entry_valid ; /* cache timeout (sec) */
113
+ uint64_t attr_valid ; /* attr cache timeout (sec) */
114
+ uint32_t entry_valid_nsec ; /* cache timeout (nsec) */
115
+ uint32_t attr_valid_nsec ; /* attr cache timeout (nsec) */
116
+ struct fuse_attr attr ; /* file attributes */
117
+ };
118
+
119
+ struct fuse_dirent {
120
+ uint64_t ino ; /* inode number */
121
+ uint64_t off ; /* offset to next entry */
122
+ uint32_t namelen ; /* length of the entry name */
123
+ uint32_t type ; /* file type (DT_REG, DT_DIR, etc.) */
124
+ char name []; /* name (not null-terminated) */
125
+ };
126
+
127
+ struct fuse_direntplus {
128
+ struct fuse_entry_out entry_out ;
129
+ struct fuse_dirent dirent ;
130
+ };
131
+
132
+ struct fuse_lookup_in {
133
+ uint64_t parent ; /* inode of parent dir */
134
+ };
135
+
136
+ struct fuse_forget_in {
137
+ uint64_t nlookup ;
138
+ };
139
+
140
+ struct fuse_create_in {
141
+ uint32_t flags ;
142
+ uint32_t mode ;
143
+ uint32_t umask ;
144
+ uint32_t open_flags ;
145
+ };
146
+
147
+ struct fuse_release_in {
148
+ uint64_t fh ;
149
+ uint32_t flags ;
150
+ uint32_t release_flags ;
151
+ uint64_t lock_owner ;
152
+ };
153
+
154
+ struct fuse_flush_in {
155
+ uint64_t fh ;
156
+ uint32_t unused ;
157
+ uint32_t padding ;
158
+ uint64_t lock_owner ;
159
+ };
0 commit comments