// // Copyright 2026 Aarav Ravindra Kharade // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. // #include #include #include __attribute__((constructor(101))) void early_mounts(void) { mkdir("/proc", 0755); mount("proc", "/proc", "proc", 0, 0); mkdir("/sys", 0755); mount("sysfs", "/sys", "sysfs", 0, 0); mkdir("/dev", 0755); mount("devtmpfs", "/dev", "devtmpfs", 0, 0); mkdir("/run", 0755); mount("tmpfs", "/run", "tmpfs", 0, 0); setenv("XDG_RUNTIME_DIR", "/run", 1); setenv("LD_LIBRARY_PATH", "/lib", 1); } #include #include void* ark_opendir(const char* name) { return opendir(name); } int ark_closedir(void* dirp) { return closedir((DIR*)dirp); } void* ark_readdir(void* dirp) { return readdir((DIR*)dirp); } const char* ark_dirent_name(void* entry) { if (!entry) return NULL; return ((struct dirent*)entry)->d_name; } int ark_getline(char** lineptr, size_t* n, void* stream) { return getline(lineptr, n, (FILE*)stream); } #include int ark_open2_c(const char* path, int flags) { return open(path, flags); } int ark_open3_c(const char* path, int flags, int mode) { return open(path, flags, mode); } #include int ark_errno(void) { return errno; }