jcs's openbsd hax
openbsd
at jcs 45 lines 1.4 kB view raw
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 <stdio.h> 21#include <err.h> 22#include <unistd.h> 23#include <dev/pci/cs4280reg.h> 24#include "cs4280_image.h" 25#define FILENAME "cs4280" 26 27int 28main(int argc, char *argv[]) 29{ 30 ssize_t rlen; 31 int fd; 32 33 printf("creating %s length %zu\n", FILENAME, sizeof BA1Struct); 34 fd = open(FILENAME, O_WRONLY|O_CREAT|O_TRUNC, 0644); 35 if (fd == -1) 36 err(1, "%s", FILENAME); 37 38 rlen = write(fd, &BA1Struct, sizeof BA1Struct); 39 if (rlen == -1) 40 err(1, "%s", FILENAME); 41 if (rlen != sizeof BA1Struct) 42 errx(1, "%s: short write", FILENAME); 43 close(fd); 44 return 0; 45}