2023-01-27 13:41:30 +04:00

22 lines
546 B
C

#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
if (argc != 2) {
fprintf(stderr, "Usage: %s mbr.bin\n", argv[0]);
return 1;
}
const char* filename = argv[1];
int fd = open(filename, O_RDWR);
off_t length = lseek(fd, 0, SEEK_END);
if (length > 510) {
fprintf(stderr, "file %s is larger than 510 bytes (size: %llu)\n",
filename, length);
return 1;
}
lseek(fd, 510, SEEK_SET);
write(fd, "\x55\xaa", 2);
return 0;
}