1 /* 2 * Copyright (c) 2015 The Chromium OS Authors. All rights reserved. 3 * Use of this source code is governed by a BSD-style license that can be 4 * found in the LICENSE file. 5 */ 6 7 #include <fcntl.h> 8 #include <stdlib.h> 9 #include <unistd.h> 10 11 #include <sys/stat.h> 12 #include <sys/types.h> 13 main(void)14int main(void) { 15 char buf[128]; 16 int fd, ret; 17 unsigned int i; 18 19 fd = open("/dev/zero", O_RDONLY); 20 if (fd < 0) 21 return 1; 22 23 ret = read(fd, buf, sizeof(buf)); 24 if (ret < 0) 25 return 2; 26 27 for (i = 0; i < (sizeof(buf) / sizeof(buf[0])); i++) { 28 if (buf[i] != 0) 29 return 3; 30 } 31 32 ret = close(fd); 33 if (ret < 0) 34 return 4; 35 36 return 0; 37 } 38