daemon: Reimplement 'part_get_mbr_part_type' API in OCaml.

Instead of parsing 'parted' output OCaml implementation relies on the following facts:

1. MBR partition table can hold up to 4 "primary" partitions.
2. Partition with number greater then 4 is "logical" partition.
3. Partition with number less then or equal to 4 with MBR ID 0x05 or 0x0f is "extended" partition (http://thestarman.pcministry.com/asm/mbr/PartTypes.htm; https://en.wikipedia.org/wiki/Partition_type) or "primary" otherwise.
This commit is contained in:
Nikolay Ivanets
2018-05-01 03:53:58 +03:00
committed by Richard W.M. Jones
parent 81d951239f
commit 994ca1f8eb
3 changed files with 14 additions and 106 deletions

View File

@@ -9213,6 +9213,7 @@ All data will be zeroed, but metadata and the like is preserved." };
{ defaults with
name = "part_get_mbr_part_type"; added = (1, 29, 32);
style = RString (RPlainString, "partitiontype"), [String (Device, "device"); Int "partnum"], [];
impl = OCaml "Parted.part_get_mbr_part_type";
tests = [
InitEmpty, Always, TestResultString (
[["part_init"; "/dev/sda"; "mbr"];