-
Notifications
You must be signed in to change notification settings - Fork 1
/
slhgen.py
executable file
·29 lines (26 loc) · 914 Bytes
/
slhgen.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python3
import argparse
import sys
from formats import slh
parser = argparse.ArgumentParser()
parser.add_argument("--serial-number", default='')
parser.add_argument("--revision", default='')
parser.add_argument("--model-name", default='')
parser.add_argument("--sectorsize", type=int, default=512)
parser.add_argument("--size", type=int, required=True, help="size of the raw image in bytes")
parser.add_argument("cylinders", type=int)
parser.add_argument("heads", type=int)
parser.add_argument("sectors", type=int)
args = parser.parse_args()
header = slh.header.pack(
magic=b"HDIM",
cylinders=args.cylinders,
heads=args.heads,
sectors=args.sectors,
sectorsize=args.sectorsize,
size=args.size,
serial_number=args.serial_number.encode("ascii"),
revision=args.revision.encode("ascii"),
model_name=args.model_name.encode("ascii")
)
sys.stdout.buffer.write(header)