19#include <mos/proto/fs_server.h>
27MOS_RPC_USERFS_CLIENT(fs_client)
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__)); \
120 const int result = fs_client_readdir(userfs->
rpc_server, &req, &resp);
125 pr_warn(
"userfs_iop_iterate_dir: failed to readdir %s: %d",
dentry_name(dentry), result);
157 const int result = fs_client_lookup(userfs->
rpc_server, &req, &resp);
196 const int result = fs_client_make_dir(userfs->
rpc_server, &req, &resp);
252 const int result = fs_client_create_file(userfs->
rpc_server, &req, &resp);
257 pr_warn(
"userfs_iop_newfile: failed to create file %s: %d",
dentry_name(dentry), result);
289 const int result = fs_client_readlink(userfs->
rpc_server, &req, &resp);
294 pr_warn(
"userfs_iop_readlink: failed to readlink %s: %d",
dentry_name(dentry), result);
364 const int result = fs_client_unlink(userfs->
rpc_server, &req, &resp);
430 const int result = fs_client_get_page(userfs->
rpc_server, &req, &resp);
435 pr_warn(
"userfs_inode_cache_fill_cache: failed to getpage: %d", result);
441 pr_dwarn(userfs,
"userfs_inode_cache_fill_cache: failed to getpage: %s", resp.
result.
error);
449 pr_warn(
"userfs_inode_cache_fill_cache: failed to allocate page");
459 return ERR_PTR(-EIO);
477 const int result = fs_client_put_page(userfs->
rpc_server, &req, &resp);
482 pr_warn(
"userfs_inode_cache_flush_page: failed to putpage: %d", result);
489 pr_dwarn(userfs,
"userfs_inode_cache_flush_page: failed to putpage: %s", resp.
result.
error);
519 const int result = fs_client_sync_inode(userfs->
rpc_server, &req, &resp);
524 pr_warn(
"userfs_sync_inode: failed to sync inode %llu: %d", inode->
ino, result);
547 .fs_name = (
char *) fs->
name,
548 .device = (
char *) device,
549 .options = (
char *) options,
555 const int result = fs_client_mount(userfs->
rpc_server, &req, &resp);
560 pr_warn(
"userfs_fsop_mount: failed to mount %s: %d", fs->
name, result);
562 return ERR_PTR(-EIO);
569 return ERR_PTR(-EIO);
#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
void dentry_attach(dentry_t *d, inode_t *inode)
Attach an inode to a dentry.
__BEGIN_DECLS phyframe_t * mm_get_free_page(void)
#define phyframe_va(frame)
#define pmm_ref_one(thing)
inode_t * inode_create(superblock_t *sb, u64 ino, file_type_t type)
static vmap_global_mstat_t stat[_MEM_MAX_TYPES]
#define PB_BYTES_ARRAY_T_ALLOCSIZE(n)
void pb_release(const pb_msgdesc_t *fields, void *dest_struct)
static void * memcpy(void *s1, const void *s2, size_t n)
static size_t strlen(const char *s)
#define pr_dwarn(feat, fmt,...)
#define profile_leave(p,...)
MOSAPI rpc_server_stub_t * rpc_client_create(const char *server_name)
Create a new RPC client stub for the given server.
superblock_t * superblock
const inode_cache_ops_t * ops
superblock_t * superblock
const file_ops_t * file_ops
mosrpc_fs_inode_ref i_ref
mosrpc_fs_inode_info i_info
mosrpc_fs_inode_ref i_ref
mosrpc_fs_inode_ref i_ref
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
mosrpc_fs_inode_ref i_ref
struct _mosrpc_fs_pb_dirent * entries
mosrpc_fs_inode_ref i_ref
mosrpc_fs_inode_info i_info
mosrpc_fs_inode_ref i_ref
mosrpc_fs_inode_ref i_ref
const superblock_ops_t * ops
const char * rpc_server_name
The name of the RPC server.
rpc_server_stub_t * rpc_server
The RPC server stub, if connected.
static bool userfs_iop_symlink(inode_t *dir, dentry_t *dentry, const char *symname)
static bool userfs_iop_rename(inode_t *old_dir, dentry_t *old_dentry, inode_t *new_dir, dentry_t *new_dentry)
void userfs_ensure_connected(userfs_t *userfs)
Ensure that the userfs is connected to the server.
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.
static const inode_ops_t userfs_iops
inode_t * i_from_pbfull(const mosrpc_fs_inode_info *stat, superblock_t *sb, void *private)
Convert a protobuf inode to a kernel inode.
mosrpc_fs_inode_ref i_to_pb_ref(const inode_t *i)
static bool userfs_iop_mkdir(inode_t *dir, dentry_t *dentry, file_perm_t perm)
static bool userfs_iop_rmdir(inode_t *dir, dentry_t *dentry)
static size_t userfs_iop_readlink(dentry_t *dentry, char *buffer, size_t buflen)
static const superblock_ops_t userfs_sb_ops
static bool userfs_iop_mknode(inode_t *dir, dentry_t *dentry, file_type_t type, file_perm_t perm, dev_t dev)
static phyframe_t * userfs_inode_cache_fill_cache(inode_cache_t *cache, off_t pgoff)
#define userfs_get(_fs, _fmt,...)
long userfs_sync_inode(inode_t *inode)
static const inode_cache_ops_t userfs_inode_cache_ops
static void userfs_iop_iterate_dir(dentry_t *dentry, vfs_listdir_state_t *state, dentry_iterator_op add_record)
static const file_ops_t userfs_fops
static bool userfs_iop_unlink(inode_t *dir, dentry_t *dentry)
static bool userfs_iop_newfile(inode_t *dir, dentry_t *dentry, file_type_t type, file_perm_t perm)
static bool userfs_iop_lookup(inode_t *dir, dentry_t *dentry)
dentry_t * userfs_fsop_mount(filesystem_t *fs, const char *device, const char *options)
long userfs_inode_cache_flush_page(inode_cache_t *cache, off_t pgoff, phyframe_t *page)
static bool userfs_fop_open(inode_t *inode, file_t *file, bool created)
static bool userfs_iop_hardlink(dentry_t *d, inode_t *i, dentry_t *new_d)
slab_t * superblock_cache
void dentry_iterator_op(vfs_listdir_state_t *state, u64 ino, const char *name, size_t name_len, file_type_t type)
#define dentry_name(dentry)
bool simple_page_write_begin(inode_cache_t *icache, off_t offset, size_t size, phyframe_t **page, void **private)
ssize_t vfs_generic_write(const file_t *file, const void *buf, size_t size, off_t offset)
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.
void simple_page_write_end(inode_cache_t *icache, off_t offset, size_t size, phyframe_t *page, void *private)
ssize_t vfs_generic_read(const file_t *file, void *buf, size_t size, off_t offset)