1 /** 2 * Copyright (C) 2017 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 #define _GNU_SOURCE 17 18 #include <ctype.h> 19 #include <dirent.h> 20 #include <dlfcn.h> 21 #include <elf.h> 22 #include <errno.h> 23 #include <fcntl.h> 24 #include <pthread.h> 25 #include <stdbool.h> 26 #include <stdio.h> 27 #include <stdlib.h> 28 #include <string.h> 29 #include <sys/mman.h> 30 #include <sys/ptrace.h> 31 #include <sys/stat.h> 32 #include <sys/types.h> 33 #include <sys/wait.h> 34 #include <unistd.h> 35 36 #define FILE_PATH ("/proc/cld/athdiagpfs") 37 38 #define TEST_SIZE (8092) 39 40 void *read_test(int arg) { 41 size_t buffer_size = (size_t)arg; 42 FILE *fd = fopen(FILE_PATH, "rb"); 43 char *buffer = (char *)malloc(sizeof(char) * buffer_size); 44 memset(buffer, '0', buffer_size); 45 buffer[buffer_size-1] = '\0'; 46 while (fgets(buffer, buffer_size, fd)) { } 47 return NULL; 48 } 49 50 int main() { read_test(TEST_SIZE); } 51