xref: /openbsd/sys/dev/microcode/afb/build.c (revision a6445c1d)
1 /*	$OpenBSD: build.c,v 1.1 2009/12/07 20:35:25 kettenis Exp $ */
2 
3 /*
4  * Copyright (c) 2007 David Gwynne <dlg@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 
19 #include <sys/types.h>
20 
21 #include <err.h>
22 #include <fcntl.h>
23 #include <stdio.h>
24 #include <unistd.h>
25 
26 #include "microcode.h"
27 
28 #define AFB_FW_NAME "afb"
29 
30 int
31 main(int argc, char *argv[])
32 {
33 	ssize_t		len;
34 	int		fd;
35 	int		i;
36 
37 	fd = open(AFB_FW_NAME, O_WRONLY | O_CREAT | O_TRUNC, 0644);
38 	if (fd == -1)
39 		err(1, "%s", AFB_FW_NAME);
40 
41 	len = write(fd, afb_fw, sizeof(afb_fw));
42 	if (len == -1)
43 		err(1, "%s write", AFB_FW_NAME);
44 	if (len != sizeof(afb_fw))
45 		errx(1, "%s: short write", AFB_FW_NAME);
46 
47 	close(fd);
48 
49 	return (0);
50 }
51