1 /* $OpenBSD: build.c,v 1.3 2016/12/18 18:28:39 krw Exp $ */
2
3 /*
4 * Copyright (c) 2004 Theo de Raadt <deraadt@openbsd.org>
5 *
6 * Permission to use, copy, modify, and distribute this software for any
7 * purpose with or without fee is hereby granted, provided that the above
8 * copyright notice and this permission notice appear in all copies.
9 *
10 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
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
fullwrite(int fd,const void * buf,size_t nbytes)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
main(int argc,char * argv[])40 main(int argc, char *argv[])
41 {
42 int fd;
43 ssize_t rlen;
44
45 printf("creating %s length %zu\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 }
58