#include #include #include #include #include #include void error(const char* msg) { fprintf(stderr, ":( error: %s\n", msg); exit(EXIT_FAILURE); } const char* read_file(const char* path) { struct stat stat_info; if (stat(path, &stat_info) == -1) error("i couldn't open that file, sorry :("); const int file = open(path, O_RDONLY); if (file == -1) error("i couldn't open that file, sorry :("); const int mmap_prot = PROT_READ; const int mmap_flags = MAP_PRIVATE; const void* file_data = mmap( NULL, stat_info.st_size, mmap_prot, mmap_flags, file, 0 ); return (const char*)file_data; } int main(const int argc, const char* argv[]) { if (argc != 2) { printf("usage: catboot \n"); return EXIT_FAILURE; } const char* file_path = argv[1]; const char* source = read_file(file_path); printf("%s", source); return EXIT_SUCCESS; }