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 "proto/filesystem.pb.h"
#include "proto/filesystem.service.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

Functions

template<typename... TPrint>
userfs_tuserfs_get (filesystem_t *fs, TPrint... print)
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, FsBaseFile *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

Function Documentation

◆ userfs_get()

◆ 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 61 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 82 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 107 of file userfs.cpp.

Referenced by userfs_get().

Here is the call graph for this function:

◆ userfs_iop_hardlink()

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

Definition at line 120 of file userfs.cpp.

Here is the call graph for this function:

◆ userfs_iop_iterate_dir()

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

Definition at line 132 of file userfs.cpp.

Here is the call graph for this function:

◆ userfs_iop_lookup()

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

Definition at line 166 of file userfs.cpp.

Here is the call graph for this function:

◆ userfs_iop_mkdir()

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

Definition at line 203 of file userfs.cpp.

Here is the call graph for this function:

◆ userfs_iop_mknode()

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 242 of file userfs.cpp.

Here is the call graph for this function:

◆ userfs_iop_newfile()

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

Definition at line 257 of file userfs.cpp.

Here is the call graph for this function:

◆ userfs_iop_readlink()

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

Definition at line 297 of file userfs.cpp.

Here is the call graph for this function:

◆ userfs_iop_rename()

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

Definition at line 333 of file userfs.cpp.

Here is the call graph for this function:

◆ userfs_iop_rmdir()

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

Definition at line 348 of file userfs.cpp.

Here is the call graph for this function:

◆ userfs_iop_symlink()

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

Definition at line 360 of file userfs.cpp.

Here is the call graph for this function:

◆ userfs_iop_unlink()

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

Definition at line 373 of file userfs.cpp.

Here is the call graph for this function:

◆ userfs_fop_open()

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

Definition at line 419 of file userfs.cpp.

◆ userfs_inode_cache_fill_cache()

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

Definition at line 438 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 480 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 524 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 557 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:360
static bool userfs_iop_rename(inode_t *old_dir, dentry_t *old_dentry, inode_t *new_dir, dentry_t *new_dentry)
Definition userfs.cpp:333
static bool userfs_iop_mkdir(inode_t *dir, dentry_t *dentry, file_perm_t perm)
Definition userfs.cpp:203
static bool userfs_iop_rmdir(inode_t *dir, dentry_t *dentry)
Definition userfs.cpp:348
static size_t userfs_iop_readlink(dentry_t *dentry, char *buffer, size_t buflen)
Definition userfs.cpp:297
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:242
static void userfs_iop_iterate_dir(dentry_t *dentry, vfs_listdir_state_t *state, dentry_iterator_op add_record)
Definition userfs.cpp:132
static bool userfs_iop_unlink(inode_t *dir, dentry_t *dentry)
Definition userfs.cpp:373
static bool userfs_iop_newfile(inode_t *dir, dentry_t *dentry, file_type_t type, file_perm_t perm)
Definition userfs.cpp:257
static bool userfs_iop_lookup(inode_t *dir, dentry_t *dentry)
Definition userfs.cpp:166
static bool userfs_iop_hardlink(dentry_t *d, inode_t *i, dentry_t *new_d)
Definition userfs.cpp:120

Definition at line 405 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, FsBaseFile *file, bool created)
Definition userfs.cpp:419
ssize_t vfs_generic_read(const FsBaseFile *file, void *buf, size_t size, off_t offset)
Definition vfs_utils.cpp:93
ssize_t vfs_generic_write(const FsBaseFile *file, const void *buf, size_t size, off_t offset)

Definition at line 428 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:480
static PtrResult< phyframe_t > userfs_inode_cache_fill_cache(inode_cache_t *cache, uint64_t pgoff)
Definition userfs.cpp:438
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 517 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:524

Definition at line 552 of file userfs.cpp.

Referenced by userfs_fsop_mount().