MOS Source Code
Loading...
Searching...
No Matches
userfs.c File Reference
#include "mos/filesystem/userfs/userfs.h"
#include "mos/filesystem/dentry.h"
#include "mos/filesystem/vfs_types.h"
#include "mos/filesystem/vfs_utils.h"
#include "mos/misc/profiling.h"
#include "mos/syslog/printk.h"
#include "proto/filesystem.pb.h"
#include "proto/filesystem.services.h"
#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/proto/fs_server.h>
#include <mos_stdio.h>
#include <mos_stdlib.h>
#include <mos_string.h>
#include <pb.h>
#include <pb_decode.h>
#include <pb_encode.h>
+ Include dependency graph for userfs.c:

Go to the source code of this file.

Macros

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

Functions

inode_ti_from_pbfull (const mosrpc_fs_inode_info *stat, superblock_t *sb, void *private)
 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 phyframe_tuserfs_inode_cache_fill_cache (inode_cache_t *cache, off_t pgoff)
 
long userfs_inode_cache_flush_page (inode_cache_t *cache, off_t pgoff, phyframe_t *page)
 
long userfs_sync_inode (inode_t *inode)
 
dentry_tuserfs_fsop_mount (filesystem_t *fs, const char *device, const char *options)
 

Variables

static const inode_ops_t userfs_iops
 
static const file_ops_t userfs_fops
 
static const inode_cache_ops_t userfs_inode_cache_ops
 
static 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, retval->rpc_server_name __VA_OPT__(, __VA_ARGS__)); \
})
#define statement_expr(type,...)
Definition mos_global.h:92
#define container_of(ptr, type, member)
Definition mos_global.h:50

Definition at line 34 of file userfs.c.

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 )

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 41 of file userfs.c.

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 62 of file userfs.c.

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 87 of file userfs.c.

+ 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 100 of file userfs.c.

◆ 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 111 of file userfs.c.

+ 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 146 of file userfs.c.

+ 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 182 of file userfs.c.

+ 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 224 of file userfs.c.

◆ 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 238 of file userfs.c.

+ 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 280 of file userfs.c.

+ 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 316 of file userfs.c.

◆ userfs_iop_rmdir()

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

Definition at line 329 of file userfs.c.

◆ userfs_iop_symlink()

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

Definition at line 340 of file userfs.c.

◆ userfs_iop_unlink()

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

Definition at line 352 of file userfs.c.

+ 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 400 of file userfs.c.

◆ userfs_inode_cache_fill_cache()

static phyframe_t * userfs_inode_cache_fill_cache ( inode_cache_t * cache,
off_t pgoff )
static

Definition at line 419 of file userfs.c.

+ Here is the call graph for this function:

◆ userfs_inode_cache_flush_page()

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

Definition at line 462 of file userfs.c.

+ Here is the call graph for this function:

◆ userfs_sync_inode()

long userfs_sync_inode ( inode_t * inode)

Definition at line 509 of file userfs.c.

+ Here is the call graph for this function:

◆ userfs_fsop_mount()

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

Definition at line 542 of file userfs.c.

Referenced by userfs_manager_register_filesystem().

+ Here is the call graph for this function:

Variable Documentation

◆ userfs_iops

static const inode_ops_t userfs_iops
static
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.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
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 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 void userfs_iop_iterate_dir(dentry_t *dentry, vfs_listdir_state_t *state, dentry_iterator_op add_record)
Definition userfs.c:111
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
static bool userfs_iop_hardlink(dentry_t *d, inode_t *i, dentry_t *new_d)
Definition userfs.c:100

Definition at line 29 of file userfs.c.

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

◆ userfs_fops

static const file_ops_t userfs_fops
static
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.c:400
ssize_t vfs_generic_write(const file_t *file, const void *buf, size_t size, off_t offset)
Definition vfs_utils.c:105
ssize_t vfs_generic_read(const file_t *file, void *buf, size_t size, off_t offset)
Definition vfs_utils.c:95

Definition at line 30 of file userfs.c.

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

◆ userfs_inode_cache_ops

static const inode_cache_ops_t userfs_inode_cache_ops
static
Initial value:
= {
.page_write_begin = simple_page_write_begin,
.page_write_end = simple_page_write_end,
}
static phyframe_t * userfs_inode_cache_fill_cache(inode_cache_t *cache, off_t pgoff)
Definition userfs.c:419
long userfs_inode_cache_flush_page(inode_cache_t *cache, off_t pgoff, phyframe_t *page)
Definition userfs.c:462
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
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

Definition at line 31 of file userfs.c.

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

◆ userfs_sb_ops

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

Definition at line 32 of file userfs.c.

Referenced by userfs_fsop_mount().