added my responsibility for the `cpm' port
[unix-history] / sys / i386 / netboot / makerom.c
CommitLineData
db4d0741
MR
1#include <stdio.h>
2#include <fcntl.h>
3
4unsigned char rom[ROMSIZE];
5unsigned int sum;
6
7main(argc,argv)
8 int argc; char *argv[];
9{
10 int i, fd;
11 if (argc < 1) {
12 fprintf(stderr,"usage: %s rom-file\n",argv[0]);
13 exit(2);
14 }
15 if ((fd = open(argv[1], O_RDWR)) < 0) {
16 perror("unable to open file");
17 exit(2);
18 }
19 bzero(rom, ROMSIZE);
20 if (read(fd, rom, ROMSIZE) < 0) {
21 perror("read error");
22 exit(2);
23 }
24 rom[5] = 0;
25 for (i=0,sum=0; i<ROMSIZE; i++)
26 sum += rom[i];
27 rom[5] = -sum;
28 for (i=0,sum=0; i<ROMSIZE; i++);
29 sum += rom[i];
30 if (sum)
31 printf("checksum fails.\n");
32 if (lseek(fd, 0L, SEEK_SET) < 0) {
33 perror("unable to seek");
34 exit(2);
35 }
36 if (write(fd, rom, ROMSIZE) < 0) {
37 perror("unable to write");
38 exit(2);
39 }
40 close(fd);
41 exit(0);
42}