MOS Source Code
Loading...
Searching...
No Matches
userfs.c
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-3.0-or-later
2// userspace filesystems
3
5
10#include "mos/syslog/printk.h"
11#include "proto/filesystem.pb.h"
13
14#include <librpc/macro_magic.h>
15#include <librpc/rpc.h>
16#include <librpc/rpc_client.h>
17#include <librpc/rpc_server.h>
19#include <mos/proto/fs_server.h>
20#include <mos_stdio.h>
21#include <mos_stdlib.h>
22#include <mos_string.h>
23#include <pb.h>
24#include <pb_decode.h>
25#include <pb_encode.h>
26
27MOS_RPC_USERFS_CLIENT(fs_client)
28
33
34#define userfs_get(_fs, _fmt, ...) \
35 statement_expr(userfs_t *, { \
36 retval = container_of(_fs, userfs_t, fs); \
37 userfs_ensure_connected(retval); \
38 pr_dinfo2(userfs, "calling '%s' (rpc_server '%s'): " _fmt, _fs->name, retval->rpc_server_name __VA_OPT__(, __VA_ARGS__)); \
39 })
40
42{
43 // enum pb_file_type_t -> enum file_type_t is safe here because they have the same values
44 inode_t *i = inode_create(sb, stat->ino, (file_type_t) stat->type);
45 i->created = stat->created;
46 i->modified = stat->modified;
47 i->accessed = stat->accessed;
48 i->size = stat->size;
49 i->uid = stat->uid;
50 i->gid = stat->gid;
51 i->perm = stat->perm;
52 i->nlinks = stat->nlinks;
53 i->suid = stat->suid;
54 i->sgid = stat->sgid;
55 i->sticky = stat->sticky;
56 i->private_data = private;
57 i->ops = &userfs_iops;
59 return i;
60}
61
63{
64 pbi->ino = i->ino;
65 pbi->type = i->type;
66 pbi->created = i->created;
67 pbi->modified = i->modified;
68 pbi->accessed = i->accessed;
69 pbi->size = i->size;
70 pbi->uid = i->uid;
71 pbi->gid = i->gid;
72 pbi->perm = i->perm;
73 pbi->nlinks = i->nlinks;
74 pbi->suid = i->suid;
75 pbi->sgid = i->sgid;
76 pbi->sticky = i->sticky;
77 // pbi->private_data = (ptr_t) i->private;
78 return pbi;
79}
80
82{
83 mosrpc_fs_inode_ref ref = { .data = (ptr_t) i->private_data }; // for userfs, private_data is the inode reference used by the server
84 return ref;
85}
86
88{
89 if (likely(userfs->rpc_server))
90 return;
91
93 if (unlikely(!userfs->rpc_server))
94 {
95 pr_warn("userfs_ensure_connected: failed to connect to %s", userfs->rpc_server_name);
96 return;
97 }
98}
99
100static bool userfs_iop_hardlink(dentry_t *d, inode_t *i, dentry_t *new_d)
101{
102 MOS_UNUSED(i);
103 MOS_UNUSED(new_d);
104
105 userfs_t *userfs = userfs_get(d->superblock->fs, "hardlink: %s", dentry_name(d));
106 MOS_UNUSED(userfs);
107
108 return false;
109}
110
112{
113 userfs_t *userfs = userfs_get(dentry->superblock->fs, "iterate_dir: %s", dentry_name(dentry));
114
115 mosrpc_fs_readdir_request req = { 0 };
116 mosrpc_fs_readdir_response resp = { 0 };
117 req.i_ref = i_to_pb_ref(dentry->inode);
118
119 const pf_point_t ev = profile_enter();
120 const int result = fs_client_readdir(userfs->rpc_server, &req, &resp);
121 profile_leave(ev, "userfs.'%s'.readdir", userfs->rpc_server_name);
122
123 if (result != RPC_RESULT_OK)
124 {
125 pr_warn("userfs_iop_iterate_dir: failed to readdir %s: %d", dentry_name(dentry), result);
126 goto bail_out;
127 }
128
129 if (!resp.entries_count)
130 {
131 pr_dwarn(userfs, "userfs_iop_iterate_dir: failed to readdir %s: %s", dentry_name(dentry), resp.result.error);
132 goto bail_out;
133 }
134
135 for (size_t i = 0; i < resp.entries_count; i++)
136 {
137 const mosrpc_fs_pb_dirent *pbde = &resp.entries[i];
138 MOS_ASSERT(pbde->name);
139 add_record(state, pbde->ino, pbde->name, strlen(pbde->name), (file_type_t) pbde->type);
140 }
141
142bail_out:
144}
145
146static bool userfs_iop_lookup(inode_t *dir, dentry_t *dentry)
147{
148 userfs_t *userfs = userfs_get(dir->superblock->fs, "lookup: %s", dentry_name(dentry));
149
150 bool ret = false;
151 mosrpc_fs_lookup_request req = { 0 };
152 req.i_ref = i_to_pb_ref(dir);
153 req.name = (char *) dentry_name(dentry);
154
155 mosrpc_fs_lookup_response resp = { 0 };
156 const pf_point_t ev = profile_enter();
157 const int result = fs_client_lookup(userfs->rpc_server, &req, &resp);
158 profile_leave(ev, "userfs.'%s'.lookup", userfs->rpc_server_name);
159
160 if (result != RPC_RESULT_OK)
161 {
162 pr_warn("userfs_iop_lookup: failed to lookup %s: %d", dentry_name(dentry), result);
163 goto leave;
164 }
165
166 if (!resp.result.success)
167 goto leave; // ENOENT is not a big deal
168
169 inode_t *i = i_from_pbfull(&resp.i_info, dir->superblock, (void *) resp.i_ref.data);
170 dentry_attach(dentry, i);
171 dentry->superblock = i->superblock = dir->superblock;
172 i->ops = &userfs_iops;
174 i->file_ops = &userfs_fops;
175 ret = true;
176
177leave:
179 return ret;
180}
181
182static bool userfs_iop_mkdir(inode_t *dir, dentry_t *dentry, file_perm_t perm)
183{
184 MOS_UNUSED(dir);
185 MOS_UNUSED(dentry);
186 MOS_UNUSED(perm);
187
188 userfs_t *userfs = userfs_get(dir->superblock->fs, "mkdir: %s", dentry_name(dentry));
189
190 bool ret = false;
191
192 mosrpc_fs_make_dir_request req = { .name = (char *) dentry_name(dentry), .perm = perm, .i_ref = i_to_pb_ref(dir) };
193 mosrpc_fs_make_dir_response resp = { 0 };
194
195 const pf_point_t pp = profile_enter();
196 const int result = fs_client_make_dir(userfs->rpc_server, &req, &resp);
197 profile_leave(pp, "userfs.'%s'.make_dir", userfs->rpc_server_name);
198
199 if (result != RPC_RESULT_OK)
200 {
201 pr_warn("userfs_iop_mkdir: failed to mkdir %s: %d", dentry_name(dentry), result);
202 goto bail_out;
203 }
204
205 if (!resp.result.success)
206 {
207 pr_dwarn(userfs, "userfs_iop_mkdir: failed to mkdir %s: %s", dentry_name(dentry), resp.result.error);
208 goto bail_out;
209 }
210
211 inode_t *i = i_from_pbfull(&resp.i_info, dir->superblock, (void *) resp.i_ref.data);
212 dentry_attach(dentry, i);
213 dentry->superblock = i->superblock = dir->superblock;
214 i->ops = &userfs_iops;
216 i->file_ops = &userfs_fops;
217 ret = true;
218
219bail_out:
221 return ret;
222}
223
224static bool userfs_iop_mknode(inode_t *dir, dentry_t *dentry, file_type_t type, file_perm_t perm, dev_t dev)
225{
226 MOS_UNUSED(dir);
227 MOS_UNUSED(dentry);
228 MOS_UNUSED(type);
229 MOS_UNUSED(perm);
230 MOS_UNUSED(dev);
231
232 userfs_t *userfs = userfs_get(dir->superblock->fs, "mknode: %s", dentry_name(dentry));
233 MOS_UNUSED(userfs);
234
235 return false;
236}
237
238static bool userfs_iop_newfile(inode_t *dir, dentry_t *dentry, file_type_t type, file_perm_t perm)
239{
240 userfs_t *userfs = userfs_get(dir->superblock->fs, "newfile: %s", dentry_name(dentry));
241
242 bool ret = false;
244 req.i_ref = i_to_pb_ref(dir);
245 req.name = (char *) dentry_name(dentry);
246 req.type = type;
247 req.perm = perm;
248
250
251 const pf_point_t pp = profile_enter();
252 const int result = fs_client_create_file(userfs->rpc_server, &req, &resp);
253 profile_leave(pp, "userfs.'%s'.create_file", userfs->rpc_server_name);
254
255 if (result != RPC_RESULT_OK)
256 {
257 pr_warn("userfs_iop_newfile: failed to create file %s: %d", dentry_name(dentry), result);
258 goto bail_out;
259 }
260
261 if (!resp.result.success)
262 {
263 pr_dwarn(userfs, "userfs_iop_newfile: failed to create file %s: %s", dentry_name(dentry), resp.result.error);
264 goto bail_out;
265 }
266
267 inode_t *i = i_from_pbfull(&resp.i_info, dir->superblock, (void *) resp.i_ref.data);
268 dentry_attach(dentry, i);
269 dentry->superblock = i->superblock = dir->superblock;
270 i->ops = &userfs_iops;
272 i->file_ops = &userfs_fops;
273 ret = true;
274
275bail_out:
277 return ret;
278}
279
280static size_t userfs_iop_readlink(dentry_t *dentry, char *buffer, size_t buflen)
281{
282 userfs_t *userfs = userfs_get(dentry->superblock->fs, "readlink: %s", dentry_name(dentry));
283
284 mosrpc_fs_readlink_request req = { 0 };
285 mosrpc_fs_readlink_response resp = { 0 };
286 req.i_ref = i_to_pb_ref(dentry->inode);
287
288 const pf_point_t pp = profile_enter();
289 const int result = fs_client_readlink(userfs->rpc_server, &req, &resp);
290 profile_leave(pp, "userfs.'%s'.readlink", userfs->rpc_server_name);
291
292 if (result != RPC_RESULT_OK)
293 {
294 pr_warn("userfs_iop_readlink: failed to readlink %s: %d", dentry_name(dentry), result);
295 goto bail_out;
296 }
297
298 if (!resp.result.success)
299 {
300 pr_dwarn(userfs, "userfs_iop_readlink: failed to readlink %s: %s", dentry_name(dentry), resp.result.error);
301 goto bail_out;
302 }
303
304 size_t len = strlen(resp.target);
305 if (len > buflen)
306 len = buflen;
307
308 memcpy(buffer, resp.target, len);
309 return len;
310
311bail_out:
313 return -EIO;
314}
315
316static bool userfs_iop_rename(inode_t *old_dir, dentry_t *old_dentry, inode_t *new_dir, dentry_t *new_dentry)
317{
318 MOS_UNUSED(old_dir);
319 MOS_UNUSED(old_dentry);
320 MOS_UNUSED(new_dir);
321 MOS_UNUSED(new_dentry);
322
323 userfs_t *userfs = userfs_get(old_dir->superblock->fs, "rename: %s -> %s", dentry_name(old_dentry), dentry_name(new_dentry));
324 MOS_UNUSED(userfs);
325
326 return false;
327}
328
329static bool userfs_iop_rmdir(inode_t *dir, dentry_t *dentry)
330{
331 MOS_UNUSED(dir);
332 MOS_UNUSED(dentry);
333
334 userfs_t *userfs = userfs_get(dir->superblock->fs, "rmdir: %s", dentry_name(dentry));
335 MOS_UNUSED(userfs);
336
337 return false;
338}
339
340static bool userfs_iop_symlink(inode_t *dir, dentry_t *dentry, const char *symname)
341{
342 MOS_UNUSED(dir);
343 MOS_UNUSED(dentry);
344 MOS_UNUSED(symname);
345
346 userfs_t *userfs = userfs_get(dir->superblock->fs, "symlink: %s", dentry_name(dentry));
347 MOS_UNUSED(userfs);
348
349 return false;
350}
351
352static bool userfs_iop_unlink(inode_t *dir, dentry_t *dentry)
353{
354 userfs_t *userfs = userfs_get(dir->superblock->fs, "unlink: %s", dentry_name(dentry));
355
357 mosrpc_fs_unlink_response resp = { 0 };
358
359 req.i_ref = i_to_pb_ref(dir);
360 req.dentry.inode_id = dentry->inode->ino;
361 req.dentry.name = (char *) dentry_name(dentry);
362
363 const pf_point_t pp = profile_enter();
364 const int result = fs_client_unlink(userfs->rpc_server, &req, &resp);
365 profile_leave(pp, "userfs.'%s'.unlink", userfs->rpc_server_name);
366
367 if (result != RPC_RESULT_OK)
368 {
369 pr_warn("userfs_iop_unlink: failed to unlink %s: %d", dentry_name(dentry), result);
370 goto bail_out;
371 }
372
373 if (!resp.result.success)
374 {
375 pr_dwarn(userfs, "userfs_iop_unlink: failed to unlink %s: %s", dentry_name(dentry), resp.result.error);
376 goto bail_out;
377 }
378
379 return true;
380
381bail_out:
383 return false;
384}
385
386static const inode_ops_t userfs_iops = {
387 .hardlink = userfs_iop_hardlink,
388 .iterate_dir = userfs_iop_iterate_dir,
389 .lookup = userfs_iop_lookup,
390 .mkdir = userfs_iop_mkdir,
391 .mknode = userfs_iop_mknode,
392 .newfile = userfs_iop_newfile,
393 .readlink = userfs_iop_readlink,
394 .rename = userfs_iop_rename,
395 .rmdir = userfs_iop_rmdir,
396 .symlink = userfs_iop_symlink,
397 .unlink = userfs_iop_unlink,
398};
399
400static bool userfs_fop_open(inode_t *inode, file_t *file, bool created)
401{
402 MOS_UNUSED(inode);
403 MOS_UNUSED(file);
404 MOS_UNUSED(created);
405
406 return true;
407}
408
409static const file_ops_t userfs_fops = {
410 .open = userfs_fop_open,
411 .read = vfs_generic_read,
412 .write = vfs_generic_write,
413 .release = NULL,
414 .seek = NULL,
415 .mmap = NULL,
416 .munmap = NULL,
417};
418
420{
421 userfs_t *userfs = userfs_get(cache->owner->superblock->fs, "fill_cache", );
422
423 mosrpc_fs_getpage_request req = { 0 };
424 req.i_ref = i_to_pb_ref(cache->owner);
425 req.pgoff = pgoff;
426
427 mosrpc_fs_getpage_response resp = { 0 };
428
429 const pf_point_t pp = profile_enter();
430 const int result = fs_client_get_page(userfs->rpc_server, &req, &resp);
431 profile_leave(pp, "userfs.'%s'.getpage", userfs->rpc_server_name);
432
433 if (result != RPC_RESULT_OK)
434 {
435 pr_warn("userfs_inode_cache_fill_cache: failed to getpage: %d", result);
436 goto bail_out;
437 }
438
439 if (!resp.result.success)
440 {
441 pr_dwarn(userfs, "userfs_inode_cache_fill_cache: failed to getpage: %s", resp.result.error);
442 goto bail_out;
443 }
444
445 // allocate a page
447 if (!page)
448 {
449 pr_warn("userfs_inode_cache_fill_cache: failed to allocate page");
450 goto bail_out;
451 }
452
453 // copy the data from the server
454 memcpy((void *) phyframe_va(page), resp.data->bytes, MIN(resp.data->size, MOS_PAGE_SIZE));
455 return page;
456
457bail_out:
459 return ERR_PTR(-EIO);
460}
461
463{
464 userfs_t *userfs = userfs_get(cache->owner->superblock->fs, "flush_page", );
465
466 long ret = 0;
467 mosrpc_fs_putpage_request req = { 0 };
468 req.i_ref = i_to_pb_ref(cache->owner);
469 req.pgoff = pgoff;
471 req.data->size = MOS_PAGE_SIZE;
472 memcpy(req.data->bytes, (void *) phyframe_va(page), MOS_PAGE_SIZE);
473
474 mosrpc_fs_putpage_response resp = { 0 };
475
476 const pf_point_t pp = profile_enter();
477 const int result = fs_client_put_page(userfs->rpc_server, &req, &resp);
478 profile_leave(pp, "userfs.'%s'.putpage", userfs->rpc_server_name);
479
480 if (result != RPC_RESULT_OK)
481 {
482 pr_warn("userfs_inode_cache_flush_page: failed to putpage: %d", result);
483 ret = -EIO;
484 goto bail_out;
485 }
486
487 if (!resp.result.success)
488 {
489 pr_dwarn(userfs, "userfs_inode_cache_flush_page: failed to putpage: %s", resp.result.error);
490 ret = -EIO;
491 goto bail_out;
492 }
493
494 ret = 0;
495
496bail_out:
499 return ret;
500}
501
503 .fill_cache = userfs_inode_cache_fill_cache,
504 .page_write_begin = simple_page_write_begin,
505 .page_write_end = simple_page_write_end,
506 .flush_page = userfs_inode_cache_flush_page,
507};
508
510{
511 userfs_t *userfs = userfs_get(inode->superblock->fs, "sync_inode: %llu", inode->ino);
512
514 req.i_ref = i_to_pb_ref(inode);
515 req.i_info = *i_to_pb_full(inode, &req.i_info);
516
518 const pf_point_t pp = profile_enter();
519 const int result = fs_client_sync_inode(userfs->rpc_server, &req, &resp);
520 profile_leave(pp, "userfs.'%s'.sync_inode", userfs->rpc_server_name);
521
522 if (result != RPC_RESULT_OK)
523 {
524 pr_warn("userfs_sync_inode: failed to sync inode %llu: %d", inode->ino, result);
525 return -EIO;
526 }
527
528 if (!resp.result.success)
529 {
530 pr_dwarn(userfs, "userfs_sync_inode: failed to sync inode %llu: %s", inode->ino, resp.result.error);
531 return -EIO;
532 }
533
534 return 0;
535}
536
537static const superblock_ops_t userfs_sb_ops = {
538 .drop_inode = NULL,
539 .sync_inode = userfs_sync_inode,
540};
541
542dentry_t *userfs_fsop_mount(filesystem_t *fs, const char *device, const char *options)
543{
544 userfs_t *userfs = userfs_get(fs, "mount: %s", fs->name);
545
546 const mosrpc_fs_mount_request req = {
547 .fs_name = (char *) fs->name,
548 .device = (char *) device,
549 .options = (char *) options,
550 };
551
552 mosrpc_fs_mount_response resp = { 0 };
553
554 const pf_point_t pp = profile_enter();
555 const int result = fs_client_mount(userfs->rpc_server, &req, &resp);
556 profile_leave(pp, "userfs.'%s'.mount", userfs->rpc_server_name);
557
558 if (result != RPC_RESULT_OK)
559 {
560 pr_warn("userfs_fsop_mount: failed to mount %s: %d", fs->name, result);
562 return ERR_PTR(-EIO);
563 }
564
565 if (!resp.result.success)
566 {
567 pr_warn("userfs_fsop_mount: failed to mount %s: %s", fs->name, resp.result.error);
569 return ERR_PTR(-EIO);
570 }
571
572 superblock_t *sb = kmalloc(superblock_cache);
573 sb->ops = &userfs_sb_ops;
574
575 inode_t *i = i_from_pbfull(&resp.root_info, sb, (void *) resp.root_ref.data);
576
577 sb->fs = fs;
579 sb->root->superblock = i->superblock = sb;
580 dentry_attach(sb->root, i);
581 return sb->root;
582}
#define MOS_ASSERT(cond)
Definition assert.h:14
#define MOS_PAGE_SIZE
Definition autoconf.h:6
#define mosrpc_fs_create_file_response_fields
#define mosrpc_fs_readlink_response_fields
#define mosrpc_fs_putpage_response_fields
#define mosrpc_fs_putpage_request_fields
#define mosrpc_fs_unlink_response_fields
#define mosrpc_fs_mount_response_fields
#define mosrpc_fs_getpage_response_fields
#define mosrpc_fs_lookup_response_fields
#define mosrpc_fs_make_dir_response_fields
#define mosrpc_fs_readdir_response_fields
u16 file_perm_t
Definition fs_types.h:52
file_type_t
Definition fs_types.h:14
void dentry_attach(dentry_t *d, inode_t *inode)
Attach an inode to a dentry.
Definition dentry.c:305
#define MIN(a, b)
Definition mos_stdlib.h:30
__BEGIN_DECLS phyframe_t * mm_get_free_page(void)
Definition mm.c:46
#define phyframe_va(frame)
Definition mm.h:79
#define pmm_ref_one(thing)
Definition pmm.h:146
inode_t * inode_create(superblock_t *sb, u64 ino, file_type_t type)
Definition inode.c:65
static vmap_global_mstat_t stat[_MEM_MAX_TYPES]
Definition mmstat.c:23
#define likely(x)
Definition mos_global.h:39
#define MOS_UNUSED(x)
Definition mos_global.h:64
#define unlikely(x)
Definition mos_global.h:40
#define PB_BYTES_ARRAY_T_ALLOCSIZE(n)
Definition pb.h:377
void pb_release(const pb_msgdesc_t *fields, void *dest_struct)
Definition pb_decode.c:1336
static void * memcpy(void *s1, const void *s2, size_t n)
Definition pb_syshdr.h:90
#define NULL
Definition pb_syshdr.h:46
static size_t strlen(const char *s)
Definition pb_syshdr.h:80
#define pr_warn(fmt,...)
Definition printk.h:38
#define pr_dwarn(feat, fmt,...)
Definition printk.h:30
#define profile_enter()
Definition profiling.h:33
u64 pf_point_t
Definition profiling.h:8
#define profile_leave(p,...)
Definition profiling.h:35
@ RPC_RESULT_OK
Definition rpc.h:26
MOSAPI rpc_server_stub_t * rpc_client_create(const char *server_name)
Create a new RPC client stub for the given server.
Definition rpc_client.c:65
superblock_t * superblock
Definition vfs_types.h:119
inode_t * inode
Definition vfs_types.h:117
const char * name
Definition vfs_types.h:183
inode_t * owner
Definition vfs_types.h:150
const inode_cache_ops_t * ops
Definition vfs_types.h:152
superblock_t * superblock
Definition vfs_types.h:171
uid_t uid
Definition vfs_types.h:161
u64 modified
Definition vfs_types.h:169
u64 accessed
Definition vfs_types.h:167
u64 created
Definition vfs_types.h:168
file_perm_t perm
Definition vfs_types.h:159
const inode_ops_t * ops
Definition vfs_types.h:172
bool sgid
Definition vfs_types.h:165
size_t size
Definition vfs_types.h:160
file_type_t type
Definition vfs_types.h:158
const file_ops_t * file_ops
Definition vfs_types.h:173
bool suid
Definition vfs_types.h:164
inode_cache_t cache
Definition vfs_types.h:175
bool sticky
Definition vfs_types.h:163
gid_t gid
Definition vfs_types.h:162
u64 ino
Definition vfs_types.h:157
void * private_data
Definition vfs_types.h:174
ssize_t nlinks
Definition vfs_types.h:166
mosrpc_fs_inode_info i_info
mosrpc_fs_inode_ref i_ref
pb_bytes_array_t * data
mosrpc_fs_inode_ref i_ref
mosrpc_fs_inode_info i_info
mosrpc_fs_inode_ref i_ref
mosrpc_fs_inode_info i_info
mosrpc_fs_inode_ref i_ref
mosrpc_fs_inode_info root_info
mosrpc_fs_inode_ref root_ref
mosrpc_fs_inode_ref i_ref
pb_bytes_array_t * data
mosrpc_fs_inode_ref i_ref
struct _mosrpc_fs_pb_dirent * entries
mosrpc_fs_inode_info i_info
mosrpc_fs_inode_ref i_ref
char * error
Definition mosrpc.pb.h:15
dentry_t * root
Definition vfs_types.h:107
const superblock_ops_t * ops
Definition vfs_types.h:109
filesystem_t * fs
Definition vfs_types.h:108
const char * rpc_server_name
The name of the RPC server.
Definition userfs.h:13
rpc_server_stub_t * rpc_server
The RPC server stub, if connected.
Definition userfs.h:14
static char buffer[2048]
Definition test_printf.c:7
ssize_t off_t
Definition types.h:84
unsigned long ptr_t
Definition types.h:25
static bool userfs_iop_symlink(inode_t *dir, dentry_t *dentry, const char *symname)
Definition userfs.c:340
static bool userfs_iop_rename(inode_t *old_dir, dentry_t *old_dentry, inode_t *new_dir, dentry_t *new_dentry)
Definition userfs.c:316
void userfs_ensure_connected(userfs_t *userfs)
Ensure that the userfs is connected to the server.
Definition userfs.c:87
mosrpc_fs_inode_info * i_to_pb_full(const inode_t *i, mosrpc_fs_inode_info *pbi)
Convert a kernel inode to a protobuf inode.
Definition userfs.c:62
static const inode_ops_t userfs_iops
Definition userfs.c:29
inode_t * i_from_pbfull(const mosrpc_fs_inode_info *stat, superblock_t *sb, void *private)
Convert a protobuf inode to a kernel inode.
Definition userfs.c:41
mosrpc_fs_inode_ref i_to_pb_ref(const inode_t *i)
Definition userfs.c:81
static bool userfs_iop_mkdir(inode_t *dir, dentry_t *dentry, file_perm_t perm)
Definition userfs.c:182
static bool userfs_iop_rmdir(inode_t *dir, dentry_t *dentry)
Definition userfs.c:329
static size_t userfs_iop_readlink(dentry_t *dentry, char *buffer, size_t buflen)
Definition userfs.c:280
static const superblock_ops_t userfs_sb_ops
Definition userfs.c:32
static bool userfs_iop_mknode(inode_t *dir, dentry_t *dentry, file_type_t type, file_perm_t perm, dev_t dev)
Definition userfs.c:224
static phyframe_t * userfs_inode_cache_fill_cache(inode_cache_t *cache, off_t pgoff)
Definition userfs.c:419
#define userfs_get(_fs, _fmt,...)
Definition userfs.c:34
long userfs_sync_inode(inode_t *inode)
Definition userfs.c:509
static const inode_cache_ops_t userfs_inode_cache_ops
Definition userfs.c:31
static void userfs_iop_iterate_dir(dentry_t *dentry, vfs_listdir_state_t *state, dentry_iterator_op add_record)
Definition userfs.c:111
static const file_ops_t userfs_fops
Definition userfs.c:30
static bool userfs_iop_unlink(inode_t *dir, dentry_t *dentry)
Definition userfs.c:352
static bool userfs_iop_newfile(inode_t *dir, dentry_t *dentry, file_type_t type, file_perm_t perm)
Definition userfs.c:238
static bool userfs_iop_lookup(inode_t *dir, dentry_t *dentry)
Definition userfs.c:146
dentry_t * userfs_fsop_mount(filesystem_t *fs, const char *device, const char *options)
Definition userfs.c:542
long userfs_inode_cache_flush_page(inode_cache_t *cache, off_t pgoff, phyframe_t *page)
Definition userfs.c:462
static bool userfs_fop_open(inode_t *inode, file_t *file, bool created)
Definition userfs.c:400
static bool userfs_iop_hardlink(dentry_t *d, inode_t *i, dentry_t *new_d)
Definition userfs.c:100
slab_t * superblock_cache
Definition vfs.c:38
void dentry_iterator_op(vfs_listdir_state_t *state, u64 ino, const char *name, size_t name_len, file_type_t type)
Definition vfs_types.h:60
#define dentry_name(dentry)
Definition vfs_types.h:125
bool simple_page_write_begin(inode_cache_t *icache, off_t offset, size_t size, phyframe_t **page, void **private)
Definition vfs_utils.c:65
ssize_t vfs_generic_write(const file_t *file, const void *buf, size_t size, off_t offset)
Definition vfs_utils.c:105
dentry_t * dentry_get_from_parent(superblock_t *sb, dentry_t *parent, const char *name)
Create a new dentry with the given name and parent.
Definition vfs_utils.c:40
void simple_page_write_end(inode_cache_t *icache, off_t offset, size_t size, phyframe_t *page, void *private)
Definition vfs_utils.c:76
ssize_t vfs_generic_read(const file_t *file, void *buf, size_t size, off_t offset)
Definition vfs_utils.c:95