feat: add SMB networking support

This commit is contained in:
daniel committed 2026-11-22 08:43:18 +01:00
1 parent 6665750528
commit 2af2e90606
55 files changed
+7456 -158

No files matched your search

+73 -1
View File
@@ -320,6 +320,17 @@ namespace montauk::abi {
/* Time.hpp -- wall clock as UTC unix seconds (SYS_GETTIME is local time). */
static constexpr uint64_t SYS_GETUNIXTIME = 209; // () -> seconds
/* UserFsSyscall.hpp -- userspace filesystem providers. A provider process
mounts a drive and then serves the VFS calls other processes make on it:
it receives each as a UserFsRequest and answers with a result and
optional data. The drive disappears when the provider unmounts or exits.
Used by smbfs.elf to expose SMB shares as ordinary drives. */
static constexpr uint64_t SYS_USERFS_MOUNT = 210; // (const UserFsMountParams*) -> drive / status
static constexpr uint64_t SYS_USERFS_RECV = 211; // (drive, UserFsRequest*, data, dataMax, timeoutMs) -> 1 / 0 / status
static constexpr uint64_t SYS_USERFS_REPLY = 212; // (drive, id, result, data, len) -> status
static constexpr uint64_t SYS_USERFS_UNMOUNT = 213; // (drive) -> status; non-providers request an eject
static constexpr uint64_t SYS_USERFS_INFO = 214; // (drive, UserFsInfo*) -> status
/* Kernel-owned process capabilities. User identities may namespace
per-user resources, but never participate in authorization decisions. */
static constexpr uint64_t CAP_PROCESS_ADMIN = 1ULL << 0;
@@ -897,7 +908,7 @@ namespace montauk::abi {
int32_t drive; // VFS drive number ("N:/")
int32_t blockDev; // backing block device index, -1 if none
int32_t partIndex; // global GPT partition index, -1 if none
uint32_t kind; // BlockDeviceKind: 0=none/ramdisk, 1=SATA, 2=SATAPI, 3=NVMe, 4=USB MSC
uint32_t kind; // BlockDeviceKind: 0=none/ramdisk, 1=SATA, 2=SATAPI, 3=NVMe, 4=USB MSC, 5=SD, 6=network (DRIVE_KIND_NETWORK)
uint64_t startLba; // partition start LBA, 0 if none
uint64_t sectorCount; // partition length in sectors, 0 if none
uint32_t sectorSize; // logical sector size in bytes, 0 if none
@@ -936,6 +947,67 @@ namespace montauk::abi {
uint32_t stepsTotal;
};
/* ---- Userspace filesystem providers (SYS_USERFS_*) ---- */
/* VolInfo::kind / SYS_DRIVEKIND value of a provider-backed drive. */
static constexpr uint32_t DRIVE_KIND_NETWORK = 6;
/* Largest data payload of one request or reply. The kernel splits larger
reads and writes; SYS_USERFS_RECV needs a buffer at least this big. */
static constexpr uint32_t USERFS_MAX_DATA = 65536;
/* UserFsRequest::op. Unless noted, the provider replies with result >= 0
on success or a negative StatusCodes value. */
static constexpr uint32_t USERFS_OP_OPEN = 1; // path -> provider file handle (>= 0)
static constexpr uint32_t USERFS_OP_CREATE = 2; // path (create or truncate) -> provider file handle
static constexpr uint32_t USERFS_OP_CLOSE = 3; // handle; no reply expected (id == 0)
static constexpr uint32_t USERFS_OP_READ = 4; // handle, offset, size -> bytes read, reply data
static constexpr uint32_t USERFS_OP_WRITE = 5; // handle, offset, size, request data -> bytes written
static constexpr uint32_t USERFS_OP_GETSIZE = 6; // handle -> size in bytes
static constexpr uint32_t USERFS_OP_READDIR = 7; // path, offset = first index, size = max entries
// -> count; reply data = NUL-terminated names,
// directories with a trailing '/'
static constexpr uint32_t USERFS_OP_STAT = 8; // path -> 0, reply data = FileStat
static constexpr uint32_t USERFS_OP_DELETE = 9; // path (file or empty directory)
static constexpr uint32_t USERFS_OP_MKDIR = 10; // path
static constexpr uint32_t USERFS_OP_RENAME = 11; // path -> path2
static constexpr uint32_t USERFS_OP_SETTIMES = 12; // path, atime, mtime
static constexpr uint32_t USERFS_OP_UNMOUNT = 13; // eject requested: flush, then unmount or exit; no reply
struct UserFsMountParams {
char label[36]; // volume label shown for the drive
char fsType[12]; // short type name, e.g. "smb"
char source[128]; // what is mounted, e.g. "smb://nas/media"
uint32_t flags; // USERFS_MOUNT_*
uint32_t _pad0;
};
static constexpr uint32_t USERFS_MOUNT_READONLY = 1u << 0;
struct UserFsRequest {
uint64_t id; // pass back to SYS_USERFS_REPLY; 0 = no reply expected
uint32_t op; // USERFS_OP_*
int32_t handle; // provider file handle (CLOSE/READ/WRITE/GETSIZE)
uint64_t offset;
uint64_t size;
int64_t atime;
int64_t mtime;
uint32_t dataLen; // bytes of request data copied to the RECV buffer
uint32_t replyMax; // most reply data the kernel will accept
char path[256]; // drive-local path, starts with '/'
char path2[256];
};
struct UserFsInfo {
int32_t drive;
int32_t providerPid;
uint32_t flags;
uint32_t _pad0;
char label[36];
char fsType[12];
char source[128];
};
// Bluetooth scan result (returned by SYS_BTSCAN)
struct BtScanResult {
uint8_t bdAddr[6];