feat: vfs - add stat syscall

This commit is contained in:
2026-07-21 14:23:06 +02:00
parent 5c02c5fe79
commit de7edaf623
12 changed files with 110 additions and 1 deletions
+14
View File
@@ -209,6 +209,9 @@ namespace montauk::abi {
// Absolute path of the running executable (for argv[0]).
static constexpr uint64_t SYS_GETEXECPATH = 151; // (index, flags) -> new front index; index=-1 queries support (1/0); flags bit0 = wait vsync
// Path metadata (size, timestamps, mode). (const char* path, FileStat* out) -> 0, -1 on error/unsupported.
static constexpr uint64_t SYS_STAT = 152;
// Tunable parameters (for SYS_SDR_SETPARAM / SYS_SDR_GETPARAM).
static constexpr int SDR_PARAM_FREQ = 0; // center frequency, Hz
static constexpr int SDR_PARAM_SAMPLE_RATE = 1; // sample rate, Hz
@@ -287,6 +290,17 @@ namespace montauk::abi {
uint8_t Second;
};
// Path metadata returned by SYS_STAT. Timestamps are UTC unix seconds;
// a filesystem that does not record a given time reports it as 0.
struct FileStat {
uint64_t size; // file size in bytes
int64_t mtime; // last data modification time
int64_t ctime; // last inode (metadata) change time
int64_t atime; // last access time
uint32_t mode; // ext2/POSIX mode bits (type + permissions)
uint32_t isDir; // 1 if the entry is a directory, else 0
};
struct FbInfo {
uint64_t width;
uint64_t height;
+1
View File
@@ -175,6 +175,7 @@ extern "C" {
#define MTK_SYS_POWERINFO 149
#define MTK_SYS_FBFLIP 150
#define MTK_SYS_GETEXECPATH 151
#define MTK_SYS_STAT 152
/* @SYSCALLS-END */
#define MTK_SOCK_TCP 1
+5
View File
@@ -165,6 +165,11 @@ namespace montauk {
inline int frename(const char* oldPath, const char* newPath) {
return (int)syscall2(montauk::abi::SYS_FRENAME, (uint64_t)oldPath, (uint64_t)newPath);
}
// Fill *out with metadata (size, timestamps, mode) for the path.
// Returns 0 on success, -1 on error or if the filesystem lacks stat support.
inline int stat(const char* path, montauk::abi::FileStat* out) {
return (int)syscall2(montauk::abi::SYS_STAT, (uint64_t)path, (uint64_t)out);
}
inline int drivelist(int* outDrives, int max) {
return (int)syscall2(montauk::abi::SYS_DRIVELIST, (uint64_t)outDrives, (uint64_t)max);
}