This source file includes following definitions.
- fullwrite
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 #include <sys/types.h>
19 #include <fcntl.h>
20 #include <unistd.h>
21 #include <err.h>
22 #include <stdio.h>
23
24 #include "3c990img.h"
25 #define FILENAME "3c990"
26
27 void
28 fullwrite(int fd, const void *buf, size_t nbytes)
29 {
30 ssize_t r;
31
32 r = write(fd, buf, nbytes);
33 if (r == -1)
34 err(1, "write");
35 if (r != nbytes)
36 errx(1, "write: short write");
37 }
38
39 int
40 main(int argc, char *argv[])
41 {
42 int fd;
43 ssize_t rlen;
44
45 printf("creating %s length %d\n", FILENAME, sizeof tc990image);
46 fd = open(FILENAME, O_WRONLY|O_CREAT|O_TRUNC, 0644);
47 if (fd == -1)
48 err(1, "%s", FILENAME);
49
50 rlen = write(fd, tc990image, sizeof tc990image);
51 if (rlen == -1)
52 err(1, "%s", FILENAME);
53 if (rlen != sizeof tc990image)
54 errx(1, "%s: short write", FILENAME);
55 close(fd);
56 return 0;
57 }