//! Configuration Demo - Shows available virtiofsd options
//! 
//! This example demonstrates different configuration options
//! using directories that exist on the system.

// Check if virtiofsd is available
if !virtiofsd_available() {
    print("Error: virtiofsd is not installed");
    throw "virtiofsd not available";
}

print("=== Virtiofsd Configuration Demo ===");

// Example 1: Basic configuration with /tmp
print("\n1. Basic Configuration:");
let basic_config = virtiofsd_config()
    .socket_path("/tmp/basic.sock")
    .shared_dir("/tmp")
    .readonly(false)
    .sandbox(true)
    .build();

print("Config created successfully");
print("   Socket: " + basic_config.socket_path_str);
print("   Shared: " + basic_config.shared_dir_str);
print("   Read-only: " + if basic_config.readonly_val { "true" } else { "false" });
print("   Sandbox: " + if basic_config.sandbox_val { "true" } else { "false" });

// Example 2: High-performance configuration with /var
print("\n2. High-Performance Configuration:");
let perf_config = virtiofsd_config()
    .socket_path("/tmp/perf.sock")
    .shared_dir("/var")
    .readonly(false)
    .sandbox(false)
    .thread_pool_size(16)
    .cache(true)
    .build();

print("Performance config created");
print("   Socket: " + perf_config.socket_path_str);
print("   Shared: " + perf_config.shared_dir_str);
print("   Thread pool: 16");
print("   Cache: " + if perf_config.cache_val { "enabled" } else { "disabled" });
print("   Sandbox: " + if perf_config.sandbox_val { "enabled" } else { "disabled" });

// Example 3: Read-only configuration with /usr
print("\n3. Read-Only Configuration:");
let readonly_config = virtiofsd_config()
    .socket_path("/tmp/readonly.sock")
    .shared_dir("/usr")
    .readonly(true)
    .sandbox(true)
    .build();

print("Read-only config created");
print("   Socket: " + readonly_config.socket_path_str);
print("   Shared: " + readonly_config.shared_dir_str);
print("   Read-only: " + if readonly_config.readonly_val { "true" } else { "false" });

// Example 4: Configuration with guest mount point
print("\n4. Configuration with Guest Mount:");
let mount_config = virtiofsd_config()
    .socket_path("/tmp/mount.sock")
    .shared_dir_with_mount("/etc", "/mnt/host-etc")
    .readonly(true)
    .sandbox(true)
    .build();

print("Mount config created");
print("   Socket: " + mount_config.socket_path_str);
print("   Host dir: " + mount_config.shared_dir_str);
print("   Guest mount: " + mount_config.guest_mount_str);

print("\n=== Configuration Summary ===");
print("Available configuration options:");
print("- socket_path: Where to create the Unix socket");
print("- shared_dir: Directory to share with VM");
print("- shared_dir_with_mount: Set both host dir and guest mount point");
print("- readonly: Prevent writes from guest");
print("- sandbox: Security sandbox (disable for performance)");
print("- thread_pool_size: Number of worker threads");
print("- cache: Enable caching");
print("- extra_args: Additional virtiofsd arguments");
