Skip to content
Draft

Fuse #261

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 111 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,23 @@ members = [
"bridge_adapters",
"slosh_test",
"slosh_test_lib",
"slosh-fuse",
]

# slosh-fuse requires libfuse (Linux only), exclude from default builds
default-members = [
"slosh",
"slosh_lib",
"compiler",
"vm",
"builtins",
"compile_state",
"shell",
"bridge_macros",
"bridge_types",
"bridge_adapters",
"slosh_test",
"slosh_test_lib",
]

exclude = ["legacy"]
Expand All @@ -33,6 +50,7 @@ debug = true
version = "0.11.1"

[workspace.dependencies]
slosh_lib = { path = "slosh_lib" }
bridge_adapters = { path = "bridge_adapters" }
bridge_macros = { path = "bridge_macros" }
bridge_types = { path = "bridge_types" }
Expand Down
3 changes: 3 additions & 0 deletions builtins/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,9 @@ fn str_empty(vm: &mut SloshVm, registers: &[Value]) -> VMResult<Value> {
Ok(Value::False)
}
}
Value::Nil => {
Ok(Value::True)
}
_ => Err(VMError::new_vm(format!(
"str-empty?: takes a string, got a {}",
string.display_type(vm)
Expand Down
18 changes: 16 additions & 2 deletions shell/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ pub struct Config {
pub command: Option<String>,
pub script: Option<String>,
pub args: Vec<String>,
pub fuse_daemon: bool,
pub fuse_daemon_foreground: bool,
}

pub const VERSION_STRING: &str = env!("VERSION_STRING");
Expand All @@ -16,8 +18,10 @@ USAGE:
sl-sh [FLAGS] [OPTIONS] [args]

FLAGS:
-v, --version Print the version, platform and revision of sl-sh then exit.
-h, --help Print help (this) and exit.
-v, --version Print the version, platform and revision of sl-sh then exit.
-h, --help Print help (this) and exit.
--fuse-daemon Start as FUSE daemon (detaches from terminal).
--fuse-daemon-foreground Start as FUSE daemon in foreground (for debugging).

OPTIONS:
-c Command to run instead of entering the REPL.
Expand Down Expand Up @@ -47,6 +51,8 @@ pub fn get_config() -> Option<Config> {
let mut command: Option<String> = None;
let mut script: Option<String> = None;
let mut command_args: Vec<String> = Vec::new();
let mut fuse_daemon = false;
let mut fuse_daemon_foreground = false;

let mut args: Vec<OsString> = env::args_os().collect();

Expand All @@ -72,6 +78,12 @@ pub fn get_config() -> Option<Config> {
help(&exe_name);
return None;
}
"--fuse-daemon" => {
fuse_daemon = true;
}
"--fuse-daemon-foreground" => {
fuse_daemon_foreground = true;
}
_ => {
if command.is_none() && script.is_none() {
script = Some(arg);
Expand All @@ -90,5 +102,7 @@ pub fn get_config() -> Option<Config> {
command,
script,
args: command_args,
fuse_daemon,
fuse_daemon_foreground,
})
}
14 changes: 14 additions & 0 deletions slosh-fuse/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[package]
name = "slosh-fuse"
version.workspace = true
edition = "2021"

[dependencies]
fuser = "0.14"
libc = "0.2"
log = "0.4"
env_logger = "0.11"
base64 = "0.21"
tempfile = "3.0"
nix = { workspace = true, features = ["signal", "process", "fs", "dir"] }
signal-hook = "0.3"
56 changes: 56 additions & 0 deletions slosh-fuse/Containerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Containerfile — development toolchain for slosh-fuse (volume-mounted source)
#
# This is the primary development container. Source code is mounted at runtime
# (not copied), so edits are reflected instantly and incremental builds are fast.
# Includes socat for debugging the daemon's Unix domain socket.
# Runs as non-root user "slosh" with XDG dirs pre-created.
#
# Build the image (from repo root, once or after changing this file):
# docker build -t dyn-slosh-fuse -f slosh-fuse/Containerfile .
#
# Run unit tests (no FUSE device needed):
# docker run --rm -v "$PWD:/home/slosh/src" dyn-slosh-fuse cargo test -p slosh-fuse
#
# Run the full integration test (needs FUSE device access):
# docker run --rm -v "$PWD:/home/slosh/src" --cap-add SYS_ADMIN --device /dev/fuse \
# dyn-slosh-fuse bash slosh-fuse/test-fuse.sh
#
# Build slosh-fuse:
# docker run --rm -v "$PWD:/home/slosh/src" dyn-slosh-fuse cargo build -p slosh-fuse
#
# Interactive shell for debugging:
# docker run --rm -it -v "$PWD:/home/slosh/src" --cap-add SYS_ADMIN --device /dev/fuse \
# dyn-slosh-fuse bash

FROM ubuntu:24.04

RUN apt-get update && apt-get install -y \
fuse3 \
libfuse3-dev \
build-essential \
curl \
pkg-config \
git \
socat \
&& rm -rf /var/lib/apt/lists/*

# Allow non-root users to use allow_other mount option
RUN echo 'user_allow_other' >> /etc/fuse.conf

# Create non-root user with XDG directories
RUN useradd -m -s /bin/bash slosh \
&& mkdir -p /home/slosh/.config /home/slosh/.local/share \
&& chown -R slosh:slosh /home/slosh

# Install Rust for the slosh user
USER slosh
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
ENV PATH="/home/slosh/.cargo/bin:${PATH}"

# Trust volume-mounted source (host UID differs from container user)
RUN git config --global --add safe.directory /home/slosh/src

# Pre-fetch crate index so first build is faster
RUN cargo init /tmp/warmup && cd /tmp/warmup && cargo fetch 2>/dev/null; rm -rf /tmp/warmup

WORKDIR /home/slosh/src
Loading
Loading