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