Home | History | Annotate | Download | only in src
      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 
     14 int main(void)
     15 {
     16 	char buf[128];
     17 	int fd, ret;
     18 	unsigned int i;
     19 
     20 	fd = open("/dev/zero", O_RDONLY);
     21 	if (fd < 0)
     22 		return 1;
     23 
     24 	ret = read(fd, buf, sizeof(buf));
     25 	if (ret < 0)
     26 		return 2;
     27 
     28 	for (i = 0; i < (sizeof(buf) / sizeof(buf[0])); i++) {
     29 		if (buf[i] != 0)
     30 			return 3;
     31 	}
     32 
     33 	ret = close(fd);
     34 	if (ret < 0)
     35 		return 4;
     36 
     37 	return 0;
     38 }
     39