1// SPDX-License-Identifier: GPL-3.0-or-later
2
3#pragma once
4
5#include "mos/filesystem/vfs_types.h"
6#include "proto/filesystem.pb.h"
7
8#include <librpc/rpc_client.h>
9
10typedef struct
11{
12 filesystem_t fs; ///< The filesystem, "userfs.<name>".
13 const char *rpc_server_name; ///< The name of the RPC server.
14 rpc_server_stub_t *rpc_server; ///< The RPC server stub, if connected.
15} userfs_t;
16
17/**
18 * @brief Ensure that the userfs is connected to the server.
19 *
20 * @param userfs The userfs to connect.
21 */
22void userfs_ensure_connected(userfs_t *userfs);
23
24/**
25 * @brief Convert a protobuf inode to a kernel inode.
26 *
27 * @param pbi The protobuf inode.
28 * @param sb The superblock.
29 * @param private The private data for the inode.
30 * @return inode_t* An allocated kernel inode.
31 */
32inode_t *i_from_pbfull(const mosrpc_fs_inode_info *pbi, superblock_t *sb, void *private);
33
34/**
35 * @brief Convert a kernel inode to a protobuf inode.
36 *
37 * @param i The kernel inode.
38 * @param pbi The protobuf inode, which must be allocated.
39 * @return pb_inode* The protobuf inode, returned for convenience.
40 */
41mosrpc_fs_inode_info *i_to_pb_full(const inode_t *i, mosrpc_fs_inode_info *pbi);
42
43dentry_t *userfs_fsop_mount(filesystem_t *fs, const char *device, const char *options);
44