5 #include <netinet/in.h>
7 #define BB_SIZE (2*512)
9 int main(int argc
, char **argv
)
14 uint8_t bootblock
[BB_SIZE
];
15 uint32_t *p
= (uint32_t *)bootblock
;
16 fd
= open(argv
[1], O_RDWR
);
20 if (read(fd
, bootblock
, BB_SIZE
) < BB_SIZE
) {
24 if (ntohl(p
[0]) != 'DOS\0') {
25 fprintf(stderr
, "bad bootblock signature!\n");
29 for (sum
= 0, i
= 0; i
< (BB_SIZE
)/sizeof(uint32_t); i
++) {
38 //fprintf(stderr, "checksum: 0x%lx\n", (long)sum);
40 ((uint32_t *)bootblock
)[1] = htonl(sum
);
41 lseek(fd
, 0LL, SEEK_SET
);
42 write(fd
, bootblock
, BB_SIZE
);