#include #include #include #include #include #include #include typedef long ssize_t; int main() { if (gettid() == 0) // why are we the idle task? { __luna_abort("SHENANIGANS! init is tid 0 (which is reserved for the idle task)\n"); } printf("Welcome to Luna!\n"); printf("Running as tid %ld\n\n", gettid()); sleep(1); char version[40]; syscall(SYS_getversion, version, sizeof(version)); printf("Your kernel version is %s\n\n", version); sleep(2); const char* filename = "/sys/config"; printf("Opening %s for reading...\n", filename); int fd = open(filename, O_RDONLY); if (fd < 0) { perror("open"); // return 1; } char buf[4096]; ssize_t nread = read(fd, buf, sizeof(buf)); if (nread < 0) { perror("read"); // return 1; } else { buf[nread] = 0; printf("Read %zd bytes\n\n", nread); printf("%s", buf); } if (close(fd) < 0) { perror("close"); // return 1; } printf("\n\nPress any key to restart.\n"); return 0; }