blob: 55be780787077bda77e9b010d23f3572b1274126 [file] [log] [blame]
Eric Caruso10cf4822019-04-02 17:14:49 -07001/*
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
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}