summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/dev/microcode/atmel/build.c13
-rw-r--r--sys/dev/microcode/cirruslogic/build.c14
-rw-r--r--sys/dev/microcode/fxp/build.c12
-rw-r--r--sys/dev/microcode/kue/build.c16
-rw-r--r--sys/dev/microcode/neomagic/build.c15
-rw-r--r--sys/dev/microcode/tigon/build.c9
-rw-r--r--sys/dev/microcode/typhoon/build.c25
-rw-r--r--sys/dev/microcode/uyap/build.c27
-rw-r--r--sys/dev/microcode/yds/build.c16
9 files changed, 118 insertions, 29 deletions
diff --git a/sys/dev/microcode/atmel/build.c b/sys/dev/microcode/atmel/build.c
index 0a4bf972968..b83741284e4 100644
--- a/sys/dev/microcode/atmel/build.c
+++ b/sys/dev/microcode/atmel/build.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: build.c,v 1.8 2005/03/08 11:50:39 dlg Exp $ */
+/* $OpenBSD: build.c,v 1.9 2005/05/17 18:48:51 jason Exp $ */
/*
* Copyright (c) 2004 Theo de Raadt <deraadt@openbsd.org>
@@ -17,6 +17,9 @@
*/
#include <sys/types.h>
#include <fcntl.h>
+#include <stdio.h>
+#include <err.h>
+#include <unistd.h>
#include "atmel_intersil_fw.h"
#include "atmel_rfmd2958-smc_fw.h"
@@ -30,7 +33,7 @@
void
output(const char *name, char *buf, int buflen)
{
- int i;
+ ssize_t rlen;
int fd;
printf("creating %s length %d\n", name, buflen);
@@ -38,7 +41,11 @@ output(const char *name, char *buf, int buflen)
if (fd == -1)
err(1, "%s", name);
- write(fd, buf, buflen);
+ rlen = write(fd, buf, buflen);
+ if (rlen == -1)
+ err(1, "%s", name);
+ if (rlen != buflen)
+ errx(1, "%s: short write", name);
close(fd);
}
diff --git a/sys/dev/microcode/cirruslogic/build.c b/sys/dev/microcode/cirruslogic/build.c
index 52daaf77f65..724b47e8fe1 100644
--- a/sys/dev/microcode/cirruslogic/build.c
+++ b/sys/dev/microcode/cirruslogic/build.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: build.c,v 1.1 2004/12/19 16:06:23 deraadt Exp $ */
+/* $OpenBSD: build.c,v 1.2 2005/05/17 18:48:52 jason Exp $ */
/*
* Copyright (c) 2004 Theo de Raadt <deraadt@openbsd.org>
@@ -17,7 +17,9 @@
*/
#include <sys/types.h>
#include <fcntl.h>
-
+#include <stdio.h>
+#include <err.h>
+#include <unistd.h>
#include <dev/pci/cs4280reg.h>
#include "cs4280_image.h"
#define FILENAME "cs4280"
@@ -25,7 +27,7 @@
int
main(int argc, char *argv[])
{
- int i;
+ ssize_t rlen;
int fd;
printf("creating %s length %d\n", FILENAME, sizeof BA1Struct);
@@ -33,7 +35,11 @@ main(int argc, char *argv[])
if (fd == -1)
err(1, "%s", FILENAME);
- write(fd, &BA1Struct, sizeof BA1Struct);
+ rlen = write(fd, &BA1Struct, sizeof BA1Struct);
+ if (rlen == -1)
+ err(1, "%s", FILENAME);
+ if (rlen != sizeof BA1Struct)
+ errx(1, "%s: short write", FILENAME);
close(fd);
return 0;
}
diff --git a/sys/dev/microcode/fxp/build.c b/sys/dev/microcode/fxp/build.c
index 7fe2372c0eb..7fd5ed0bb69 100644
--- a/sys/dev/microcode/fxp/build.c
+++ b/sys/dev/microcode/fxp/build.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: build.c,v 1.2 2005/04/24 20:41:34 brad Exp $ */
+/* $OpenBSD: build.c,v 1.3 2005/05/17 18:48:52 jason Exp $ */
/*
* Copyright (c) 2004 Theo de Raadt <deraadt@openbsd.org>
@@ -21,6 +21,9 @@
#include <fcntl.h>
#include <stdlib.h>
+#include <stdio.h>
+#include <err.h>
+#include <unistd.h>
#include "rcvbundl.h"
@@ -37,6 +40,7 @@ const u_int32_t fxp_ucode_d102e[] = D102_E_RCVBUNDLE_UCODE;
static void
output(const char *name, const u_int32_t *ucode, const int ucode_len)
{
+ ssize_t rlen;
int fd, i;
u_int32_t dword;
@@ -47,7 +51,11 @@ output(const char *name, const u_int32_t *ucode, const int ucode_len)
err(1, "%s", name);
for (i = 0; i < ucode_len / sizeof(u_int32_t); i++) {
dword = htole32(ucode[i]);
- write(fd, &dword, sizeof(dword));
+ rlen = write(fd, &dword, sizeof(dword));
+ if (rlen == -1)
+ err(1, "%s", name);
+ if (rlen != sizeof(dword))
+ errx(1, "%s: short write", name);
}
close(fd);
}
diff --git a/sys/dev/microcode/kue/build.c b/sys/dev/microcode/kue/build.c
index 2b101b5b427..892773e3f59 100644
--- a/sys/dev/microcode/kue/build.c
+++ b/sys/dev/microcode/kue/build.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: build.c,v 1.2 2004/11/22 20:47:48 deraadt Exp $ */
+/* $OpenBSD: build.c,v 1.3 2005/05/17 18:48:52 jason Exp $ */
/*
* Copyright (c) 2004 Theo de Raadt <deraadt@openbsd.org>
@@ -19,7 +19,10 @@
#include <dev/usb/if_kuevar.h>
#include <fcntl.h>
#include <stdlib.h>
-
+#include <err.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
#include "kue_fw.h"
#define FILENAME "kue"
@@ -28,7 +31,8 @@ int
main(int argc, char *argv[])
{
struct kue_firmware kfproto, *kf;
- int len, fd, i;
+ int len, fd;
+ ssize_t rlen;
len = sizeof(*kf) - sizeof(kfproto.data) +
sizeof(kue_code_seg) + sizeof(kue_fix_seg) +
@@ -52,7 +56,11 @@ main(int argc, char *argv[])
if (fd == -1)
err(1, FILENAME);
- write(fd, kf, len);
+ rlen = write(fd, kf, len);
+ if (rlen == -1)
+ err(1, "%s", FILENAME);
+ if (rlen != len)
+ errx(1, "%s: short write", FILENAME);
free(kf);
close(fd);
return 0;
diff --git a/sys/dev/microcode/neomagic/build.c b/sys/dev/microcode/neomagic/build.c
index 8b76aa39502..05dbea62624 100644
--- a/sys/dev/microcode/neomagic/build.c
+++ b/sys/dev/microcode/neomagic/build.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: build.c,v 1.1 2004/11/22 04:29:06 deraadt Exp $ */
+/* $OpenBSD: build.c,v 1.2 2005/05/17 18:48:52 jason Exp $ */
/*
* Copyright (c) 2004 Theo de Raadt <deraadt@openbsd.org>
@@ -17,6 +17,10 @@
*/
#include <sys/types.h>
#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+#include <err.h>
#include <dev/pci/neoreg.h>
#include "neo-coeff.h"
@@ -26,8 +30,9 @@
int
main(int argc, char *argv[])
{
+ ssize_t rlen;
struct neo_firmware nf;
- int fd, i;
+ int fd;
fd = open(FILENAME, O_WRONLY|O_CREAT|O_TRUNC, 0644);
if (fd == -1)
@@ -38,7 +43,11 @@ main(int argc, char *argv[])
bcopy(coefficients, &nf.coefficients,
sizeof nf.coefficients);
- write(fd, &nf, sizeof nf);
+ rlen = write(fd, &nf, sizeof nf);
+ if (rlen == -1)
+ err(1, "%s", FILENAME);
+ if (rlen != sizeof nf)
+ errx(1, "%s: short write", FILENAME);
printf("created %s length %d\n", FILENAME, sizeof nf);
close(fd);
return (0);
diff --git a/sys/dev/microcode/tigon/build.c b/sys/dev/microcode/tigon/build.c
index 527ea3df31d..7e9a519dc43 100644
--- a/sys/dev/microcode/tigon/build.c
+++ b/sys/dev/microcode/tigon/build.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: build.c,v 1.2 2004/11/22 20:47:48 deraadt Exp $ */
+/* $OpenBSD: build.c,v 1.3 2005/05/17 18:48:52 jason Exp $ */
/*
* Copyright (c) 2004 Theo de Raadt <deraadt@openbsd.org>
@@ -38,6 +38,7 @@ output(const char *name,
{
struct tigon_firmware tfproto, *tf;
int len, fd, i;
+ ssize_t rlen;
len = sizeof tf - sizeof(tfproto.data) + sizetext + sizerodata +
sizedata;
@@ -79,7 +80,11 @@ output(const char *name,
if (fd == -1)
err(1, "%s", name);
- write(fd, tf, len);
+ rlen = write(fd, tf, len);
+ if (rlen == -1)
+ err(1, "%s", name);
+ if (rlen != len)
+ errx(1, "%s: short write", name);
free(tf);
close(fd);
}
diff --git a/sys/dev/microcode/typhoon/build.c b/sys/dev/microcode/typhoon/build.c
index 6faba4609bf..0e1f83b17b3 100644
--- a/sys/dev/microcode/typhoon/build.c
+++ b/sys/dev/microcode/typhoon/build.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: build.c,v 1.1 2004/12/14 01:50:42 deraadt Exp $ */
+/* $OpenBSD: build.c,v 1.2 2005/05/17 18:48:52 jason Exp $ */
/*
* Copyright (c) 2004 Theo de Raadt <deraadt@openbsd.org>
@@ -17,22 +17,41 @@
*/
#include <sys/types.h>
#include <fcntl.h>
+#include <unistd.h>
+#include <err.h>
+#include <stdio.h>
#include "3c990img.h"
#define FILENAME "3c990"
+void
+fullwrite(int fd, const void *buf, size_t nbytes)
+{
+ ssize_t r;
+
+ r = write(fd, buf, nbytes);
+ if (r == -1)
+ err(1, "write");
+ if (r != nbytes)
+ errx(1, "write: short write");
+}
+
int
main(int argc, char *argv[])
{
- int i;
int fd;
+ ssize_t rlen;
printf("creating %s length %d\n", FILENAME, sizeof tc990image);
fd = open(FILENAME, O_WRONLY|O_CREAT|O_TRUNC, 0644);
if (fd == -1)
err(1, "%s", FILENAME);
- write(fd, tc990image, sizeof tc990image);
+ rlen = write(fd, tc990image, sizeof tc990image);
+ if (rlen == -1)
+ err(1, "%s", FILENAME);
+ if (rlen != sizeof tc990image)
+ errx(1, "%s: short write", FILENAME);
close(fd);
return 0;
}
diff --git a/sys/dev/microcode/uyap/build.c b/sys/dev/microcode/uyap/build.c
index 6f0b204f81f..60347695260 100644
--- a/sys/dev/microcode/uyap/build.c
+++ b/sys/dev/microcode/uyap/build.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: build.c,v 1.2 2005/04/14 19:01:08 damien Exp $ */
+/* $OpenBSD: build.c,v 1.3 2005/05/17 18:48:52 jason Exp $ */
/*
* Copyright (c) 2004 Theo de Raadt <deraadt@openbsd.org>
@@ -16,6 +16,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/types.h>
+#include <sys/uio.h>
#include <fcntl.h>
#include <sys/param.h>
@@ -36,10 +37,28 @@ main(int argc, char *argv[])
err(1, "%s", FILENAME);
for (ptr = uyap_firmware; ; ptr++) {
- write(fd, &ptr->length, 1);
+ struct iovec iov[3];
+ u_int8_t length;
+ ssize_t tlen, rlen;
+
+ length = ptr->length;
+ iov[0].iov_base = &length;
+ iov[0].iov_len = 1;
+
address = htole16(ptr->address);
- write(fd, &address, 2);
- write(fd, ptr->data, ptr->length);
+ iov[1].iov_base = &address;
+ iov[1].iov_len = 2;
+
+ iov[2].iov_base = ptr->data;
+ iov[2].iov_len = ptr->length;
+
+ tlen = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
+
+ rlen = writev(fd, iov, 3);
+ if (rlen == -1)
+ err(1, "%s", FILENAME);
+ if (rlen != tlen)
+ err(1, "%s: short write", FILENAME);
if (ptr->length == 0)
break;
diff --git a/sys/dev/microcode/yds/build.c b/sys/dev/microcode/yds/build.c
index 21900cd56a7..95f98780522 100644
--- a/sys/dev/microcode/yds/build.c
+++ b/sys/dev/microcode/yds/build.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: build.c,v 1.1 2004/12/20 12:29:40 deraadt Exp $ */
+/* $OpenBSD: build.c,v 1.2 2005/05/17 18:48:52 jason Exp $ */
/*
* Copyright (c) 2004 Theo de Raadt <deraadt@openbsd.org>
@@ -19,7 +19,10 @@
#include <dev/pci/ydsvar.h>
#include <fcntl.h>
#include <stdlib.h>
-
+#include <unistd.h>
+#include <err.h>
+#include <string.h>
+#include <stdio.h>
#include "yds_hwmcode.h"
#define FILENAME "yds"
@@ -28,7 +31,8 @@ int
main(int argc, char *argv[])
{
struct yds_firmware yfproto, *yf;
- int len, fd, i;
+ int len, fd;
+ ssize_t rlen;
len = sizeof(*yf) - sizeof(yfproto.data) +
sizeof(yds_dsp_mcode) + sizeof(yds_ds1_ctrl_mcode) +
@@ -52,7 +56,11 @@ main(int argc, char *argv[])
if (fd == -1)
err(1, FILENAME);
- write(fd, yf, len);
+ rlen = write(fd, yf, len);
+ if (rlen == -1)
+ err(1, "%s", FILENAME);
+ if (rlen != len)
+ errx(1, "%s: short write", FILENAME);
free(yf);
close(fd);
return 0;