rendered paste body#include <fcntl.h>#include <stdio.h>#include <stdlib.h>#include <sys/mman.h>#include <sys/stat.h>#include <unistd.h>void bail(const char* message){ printf("%s\n", message); exit(1);}int detect(unsigned char* fptr, size_t size){ for (size_t i = 0; i < size; ++i) { if (fptr[i]) return i; } return 0;}int main(int argc, char* argv[]){ struct stat status; int desc = 0; void* fptr = NULL; if ( argc != 2 ) bail("Invalid arguments."); if ( stat(argv[1], &status) ) bail("stat() failed."); desc = open(argv[1], O_RDONLY); if ( desc == -1 ) bail("open() failed."); fptr = mmap(0, status.st_size, PROT_READ, MAP_SHARED, desc, 0); if ( fptr == MAP_FAILED ) bail("mmap() failed."); if ( close(desc) ) bail("close() failed."); if ( detect(fptr, status.st_size) ) bail("file might be corrupt."); if ( munmap(fptr, status.st_size) ) bail("munmap() failed."); return 0;}