MOS Source Code
Loading...
Searching...
No Matches
userfs.cpp File Reference
#include "mos/filesystem/userfs/userfs.hpp"
#include "mos/filesystem/dentry.hpp"
#include "mos/filesystem/vfs_types.hpp"
#include "mos/filesystem/vfs_utils.hpp"
#include "mos/misc/profiling.hpp"
#include "mos/syslog/printk.hpp"
#include "proto/filesystem.pb.h"
#include "proto/filesystem.services.h"
#include <algorithm>
#include <librpc/macro_magic.h>
#include <librpc/rpc.h>
#include <librpc/rpc_client.h>
#include <librpc/rpc_server.h>
#include <mos/filesystem/fs_types.h>
#include <mos_stdio.hpp>
#include <mos_stdlib.hpp>
#include <mos_string.hpp>
#include <pb.h>
#include <pb_decode.h>
#include <pb_encode.h>
+ Include dependency graph for userfs.cpp:

Go to the source code of this file.

Classes

struct  AutoCleanup
 

Macros

#define userfs_get(_fs, _fmt, ...)
 

Functions

inode_ti_from_pbfull (const mosrpc_fs_inode_info *stat, superblock_t *sb, void *private_data)
 Convert a protobuf inode to a kernel inode.
 
mosrpc_fs_inode_infoi_to_pb_full (const inode_t *i, mosrpc_fs_inode_info *pbi)
 Convert a kernel inode to a protobuf inode.
 
mosrpc_fs_inode_ref i_to_pb_ref (const inode_t *i)
 
void userfs_ensure_connected (userfs_t *userfs)
 Ensure that the userfs is connected to the server.
 
static bool userfs_iop_hardlink (dentry_t *d, inode_t *i, dentry_t *new_d)
 
static void userfs_iop_iterate_dir (dentry_t *dentry, vfs_listdir_state_t *state, dentry_iterator_op add_record)
 
static bool userfs_iop_lookup (inode_t *dir, dentry_t *dentry)
 
static bool userfs_iop_mkdir (inode_t *dir, dentry_t *dentry, file_perm_t perm)
 
static bool userfs_iop_mknode (inode_t *dir, dentry_t *dentry, file_type_t type, file_perm_t perm, dev_t dev)
 
static bool userfs_iop_newfile (inode_t *dir, dentry_t *dentry, file_type_t type, file_perm_t perm)
 
static size_t userfs_iop_readlink (dentry_t *dentry, char *buffer, size_t buflen)
 
static bool userfs_iop_rename (inode_t *old_dir, dentry_t *old_dentry, inode_t *new_dir, dentry_t *new_dentry)
 
static bool userfs_iop_rmdir (inode_t *dir, dentry_t *dentry)
 
static bool userfs_iop_symlink (inode_t *dir, dentry_t *dentry, const char *symname)
 
static bool userfs_iop_unlink (inode_t *dir, dentry_t *dentry)
 
static bool userfs_fop_open (inode_t *inode, file_t *file, bool created)
 
static PtrResult< phyframe_tuserfs_inode_cache_fill_cache (inode_cache_t *cache, uint64_t pgoff)
 
long userfs_inode_cache_flush_page (inode_cache_t *cache, uint64_t pgoff, phyframe_t *page)
 
long userfs_sync_inode (inode_t *inode)
 
PtrResult< dentry_tuserfs_fsop_mount (filesystem_t *fs, const char *device, const char *options)
 

Variables

const inode_ops_t userfs_iops
 
const file_ops_t userfs_fops
 
const inode_cache_ops_t userfs_inode_cache_ops
 
const superblock_ops_t userfs_sb_ops
 

Macro Definition Documentation

◆ userfs_get

#define userfs_get ( _fs,
_fmt,
... )
Value:
retval = container_of(_fs, userfs_t, fs); \
userfs_ensure_connected(retval); \
pr_dinfo2(userfs, "calling '%s' (rpc_server '%s'): " _fmt, _fs->name.c_str(), retval->rpc_server_name.c_str() __VA_OPT__(, __VA_ARGS__)); \
})
#define statement_expr(type,...)
Definition mos_global.h:102
#define container_of(ptr, type, member)
Definition types.hpp:31

Definition at line 34 of file userfs.cpp.

Referenced by userfs_fsop_mount(), userfs_inode_cache_fill_cache(), userfs_inode_cache_flush_page(), userfs_iop_hardlink(), userfs_iop_iterate_dir(), userfs_iop_lookup(), userfs_iop_mkdir(), userfs_iop_mknode(), userfs_iop_newfile(), userfs_iop_readlink(), userfs_iop_rename(), userfs_iop_rmdir(), userfs_iop_symlink(), userfs_iop_unlink(), and userfs_sync_inode().

Function Documentation

◆ i_from_pbfull()

inode_t * i_from_pbfull ( const mosrpc_fs_inode_info * pbi,
superblock_t * sb,
void * private_data )

Convert a protobuf inode to a kernel inode.

Parameters
pbiThe protobuf inode.
sbThe superblock.
privateThe private data for the inode.
Returns
inode_t* An allocated kernel inode.

Definition at line 59 of file userfs.cpp.

Referenced by userfs_fsop_mount(), userfs_iop_lookup(), userfs_iop_mkdir(), and userfs_iop_newfile().

+ Here is the call graph for this function:

◆ i_to_pb_full()

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.

Parameters
iThe kernel inode.
pbiThe protobuf inode, which must be allocated.
Returns
pb_inode* The protobuf inode, returned for convenience.

Definition at line 80 of file userfs.cpp.

Referenced by userfs_sync_inode().

◆ i_to_pb_ref()

◆ userfs_ensure_connected()

void userfs_ensure_connected ( userfs_t * userfs)

Ensure that the userfs is connected to the server.

Parameters
userfsThe userfs to connect.

Definition at line 105 of file userfs.cpp.

+ Here is the call graph for this function:

◆ userfs_iop_hardlink()

static bool userfs_iop_hardlink ( dentry_t * d,
inode_t * i,
dentry_t * new_d )
static

Definition at line 118 of file userfs.cpp.

+ Here is the call graph for this function:

◆ userfs_iop_iterate_dir()

static void userfs_iop_iterate_dir ( dentry_t * dentry,
vfs_listdir_state_t * state,
dentry_iterator_op add_record )
static

Definition at line 130 of file userfs.cpp.

+ Here is the call graph for this function:

◆ userfs_iop_lookup()

static bool userfs_iop_lookup ( inode_t * dir,
dentry_t * dentry )
static

Definition at line 164 of file userfs.cpp.

+ Here is the call graph for this function:

◆ userfs_iop_mkdir()

static bool userfs_iop_mkdir ( inode_t * dir,
dentry_t * dentry,
file_perm_t perm )
static

Definition at line 201 of file userfs.cpp.

+ Here is the call graph for this function:

◆ userfs_iop_mknode()

static bool userfs_iop_mknode ( inode_t * dir,
dentry_t * dentry,
file_type_t type,
file_perm_t perm,
dev_t dev )
static

Definition at line 240 of file userfs.cpp.

+ Here is the call graph for this function:

◆ userfs_iop_newfile()

static bool userfs_iop_newfile ( inode_t * dir,
dentry_t * dentry,
file_type_t type,
file_perm_t perm )
static

Definition at line 255 of file userfs.cpp.

+ Here is the call graph for this function:

◆ userfs_iop_readlink()

static size_t userfs_iop_readlink ( dentry_t * dentry,
char * buffer,
size_t buflen )
static

Definition at line 295 of file userfs.cpp.

+ Here is the call graph for this function:

◆ userfs_iop_rename()

static bool userfs_iop_rename ( inode_t * old_dir,
dentry_t * old_dentry,
inode_t * new_dir,
dentry_t * new_dentry )
static

Definition at line 331 of file userfs.cpp.

+ Here is the call graph for this function:

◆ userfs_iop_rmdir()

static bool userfs_iop_rmdir ( inode_t * dir,
dentry_t * dentry )
static

Definition at line 346 of file userfs.cpp.

+ Here is the call graph for this function:

◆ userfs_iop_symlink()

static bool userfs_iop_symlink ( inode_t * dir,
dentry_t * dentry,
const char * symname )
static

Definition at line 358 of file userfs.cpp.

+ Here is the call graph for this function:

◆ userfs_iop_unlink()

static bool userfs_iop_unlink ( inode_t * dir,
dentry_t * dentry )
static

Definition at line 371 of file userfs.cpp.

+ Here is the call graph for this function:

◆ userfs_fop_open()

static bool userfs_fop_open ( inode_t * inode,
file_t * file,
bool created )
static

Definition at line 417 of file userfs.cpp.

◆ userfs_inode_cache_fill_cache()

static PtrResult< phyframe_t > userfs_inode_cache_fill_cache ( inode_cache_t * cache,
uint64_t pgoff )
static

Definition at line 436 of file userfs.cpp.

+ Here is the call graph for this function:

◆ userfs_inode_cache_flush_page()

long userfs_inode_cache_flush_page ( inode_cache_t * cache,
uint64_t pgoff,
phyframe_t * page )

Definition at line 478 of file userfs.cpp.

+ Here is the call graph for this function:

◆ userfs_sync_inode()

long userfs_sync_inode ( inode_t * inode)

Definition at line 522 of file userfs.cpp.

+ Here is the call graph for this function:

◆ userfs_fsop_mount()

PtrResult< dentry_t > userfs_fsop_mount ( filesystem_t * fs,
const char * device,
const char * options )

Definition at line 555 of file userfs.cpp.

Referenced by userfs_manager_register_filesystem().

+ Here is the call graph for this function:

Variable Documentation

◆ userfs_iops

const inode_ops_t userfs_iops
Initial value:
= {
.hardlink = userfs_iop_hardlink,
.iterate_dir = userfs_iop_iterate_dir,
.lookup = userfs_iop_lookup,
.mkdir = userfs_iop_mkdir,
.mknode = userfs_iop_mknode,
.newfile = userfs_iop_newfile,
.readlink = userfs_iop_readlink,
.rename = userfs_iop_rename,
.rmdir = userfs_iop_rmdir,
.symlink = userfs_iop_symlink,
.unlink = userfs_iop_unlink,
}
static bool userfs_iop_symlink(inode_t *dir, dentry_t *dentry, const char *symname)
Definition userfs.cpp:358
static bool userfs_iop_rename(inode_t *old_dir, dentry_t *old_dentry, inode_t *new_dir, dentry_t *new_dentry)
Definition userfs.cpp:331
static bool userfs_iop_mkdir(inode_t *dir, dentry_t *dentry, file_perm_t perm)
Definition userfs.cpp:201
static bool userfs_iop_rmdir(inode_t *dir, dentry_t *dentry)
Definition userfs.cpp:346
static size_t userfs_iop_readlink(dentry_t *dentry, char *buffer, size_t buflen)
Definition userfs.cpp:295
static bool userfs_iop_mknode(inode_t *dir, dentry_t *dentry, file_type_t type, file_perm_t perm, dev_t dev)
Definition userfs.cpp:240
static void userfs_iop_iterate_dir(dentry_t *dentry, vfs_listdir_state_t *state, dentry_iterator_op add_record)
Definition userfs.cpp:130
static bool userfs_iop_unlink(inode_t *dir, dentry_t *dentry)
Definition userfs.cpp:371
static bool userfs_iop_newfile(inode_t *dir, dentry_t *dentry, file_type_t type, file_perm_t perm)
Definition userfs.cpp:255
static bool userfs_iop_lookup(inode_t *dir, dentry_t *dentry)
Definition userfs.cpp:164
static bool userfs_iop_hardlink(dentry_t *d, inode_t *i, dentry_t *new_d)
Definition userfs.cpp:118

Definition at line 403 of file userfs.cpp.

Referenced by i_from_pbfull(), userfs_iop_lookup(), userfs_iop_mkdir(), and userfs_iop_newfile().

◆ userfs_fops

const file_ops_t userfs_fops
Initial value:
= {
.open = userfs_fop_open,
.release = NULL,
.seek = NULL,
.mmap = NULL,
.munmap = NULL,
}
#define NULL
Definition pb_syshdr.h:46
static bool userfs_fop_open(inode_t *inode, file_t *file, bool created)
Definition userfs.cpp:417
ssize_t vfs_generic_write(const file_t *file, const void *buf, size_t size, off_t offset)
ssize_t vfs_generic_read(const file_t *file, void *buf, size_t size, off_t offset)
Definition vfs_utils.cpp:93

Definition at line 426 of file userfs.cpp.

Referenced by i_from_pbfull(), userfs_iop_lookup(), userfs_iop_mkdir(), and userfs_iop_newfile().

◆ userfs_inode_cache_ops

const inode_cache_ops_t userfs_inode_cache_ops
Initial value:
= {
.page_write_begin = simple_page_write_begin,
.page_write_end = simple_page_write_end,
}
long userfs_inode_cache_flush_page(inode_cache_t *cache, uint64_t pgoff, phyframe_t *page)
Definition userfs.cpp:478
static PtrResult< phyframe_t > userfs_inode_cache_fill_cache(inode_cache_t *cache, uint64_t pgoff)
Definition userfs.cpp:436
bool simple_page_write_begin(inode_cache_t *icache, off_t offset, size_t size, phyframe_t **page, void **private_)
Definition vfs_utils.cpp:62
void simple_page_write_end(inode_cache_t *icache, off_t offset, size_t size, phyframe_t *page, void *private_)
Definition vfs_utils.cpp:74

Definition at line 515 of file userfs.cpp.

Referenced by userfs_iop_lookup(), userfs_iop_mkdir(), and userfs_iop_newfile().

◆ userfs_sb_ops

const superblock_ops_t userfs_sb_ops
Initial value:
= {
.drop_inode = NULL,
.sync_inode = userfs_sync_inode,
}
long userfs_sync_inode(inode_t *inode)
Definition userfs.cpp:522

Definition at line 550 of file userfs.cpp.

Referenced by userfs_fsop_mount().