From b3ca1a78eb780e427a85dd1bbe1c649f998dee65 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sun, 28 May 2023 09:32:21 +0200 Subject: feat(tvix/store): add mount command to entrypoint and fuse mod `tvix-store mount PATH` will mount the tvix-store to the given path. Change-Id: Icb82a6b3cb8a22eec856c375a28ae5580403833f Reviewed-on: https://cl.tvl.fyi/c/depot/+/8665 Reviewed-by: tazjin Tested-by: BuildkiteCI Autosubmit: flokli --- tvix/store/src/bin/tvix-store.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'tvix/store/src/bin/tvix-store.rs') diff --git a/tvix/store/src/bin/tvix-store.rs b/tvix/store/src/bin/tvix-store.rs index 8c278c433997..ce2701157110 100644 --- a/tvix/store/src/bin/tvix-store.rs +++ b/tvix/store/src/bin/tvix-store.rs @@ -25,6 +25,7 @@ use tvix_store::proto::GRPCBlobServiceWrapper; use tvix_store::proto::GRPCDirectoryServiceWrapper; use tvix_store::proto::GRPCPathInfoServiceWrapper; use tvix_store::TvixStoreIO; +use tvix_store::FUSE; #[cfg(feature = "reflection")] use tvix_store::proto::FILE_DESCRIPTOR_SET; @@ -59,6 +60,12 @@ enum Commands { #[clap(value_name = "PATH")] paths: Vec, }, + /// Mounts a tvix-store at the given mountpoint + #[cfg(feature = "fuse")] + Mount { + #[clap(value_name = "PATH")] + dest: PathBuf, + }, } #[tokio::main] @@ -172,6 +179,25 @@ async fn main() -> Result<(), Box> { try_join_all(tasks).await?; } + #[cfg(feature = "fuse")] + Commands::Mount { dest } => { + let blob_service = GRPCBlobService::from_client( + BlobServiceClient::connect("http://[::1]:8000").await?, + ); + let directory_service = GRPCDirectoryService::from_client( + DirectoryServiceClient::connect("http://[::1]:8000").await?, + ); + let path_info_service_client = + PathInfoServiceClient::connect("http://[::1]:8000").await?; + let path_info_service = + GRPCPathInfoService::from_client(path_info_service_client.clone()); + + tokio::task::spawn_blocking(move || { + let f = FUSE::new(path_info_service, directory_service, blob_service); + fuser::mount2(f, &dest, &[]) + }) + .await?? + } }; Ok(()) } -- cgit 1.4.1