On Wed, Nov 24, 2021 at 11:37:46AM +0100, Laszlo Ersek wrote:
+let has_bogus_mbr device =
+ try
+ with_openfile device [O_RDONLY; O_CLOEXEC] 0 (fun fd ->
+ let sec0size = 0x200
+ and sigofs = 0x1FE
+ and sysidofs = 0x003 and sysidsize = 0x008
+ and pte1ofs = 0x1BE
+ and parttypes = [0x01; (* FAT12 *)
+ 0x04; (* FAT16 *)
+ 0x06; (* FAT12, FAT16, FAT16B *)
+ 0x0C; (* FAT32 LBA *)
+ 0x0E (* FAT16B LBA *)] in
+ let sec0 = Bytes.create sec0size in
+ let sec0read = Unix.read fd sec0 0 sec0size in
I forgot to say that since Unix has been "open"-d here, you don't need
the "Unix." prefix, unless you think it's necessary for clarity about
which particular read function is being called. (I personally
wouldn't use it because it's like the read(2) function in C which also
doesn't have a prefix.)
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
Read my programming and virtualization blog:
http://rwmj.wordpress.com
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://people.redhat.com/~rjones/virt-df/