Commit Graph

10 Commits

Author SHA1 Message Date
Laszlo Ersek
edfebee404 daemon/parted: work around part table type misreporting by "parted"
"parted" incorrectly reports "loop" rather than "msdos" for the partition
table type, when the (fake) partition table comes from the "--mbr" option
of "mkfs.fat" (in dosfstools-4.2+), and the FAT variant in question is
FAT16 or FAT32. (See RHBZ#2026224.) Work this around by
- parsing the partition table ourselves, and
- overriding "loop" with "msdos" when appropriate.

Note that when the FAT variant is FAT12, "parted" fails to parse the fake
MBR partition table completely (see RHBZ#2026220), which we cannot work
around. However, FAT12 should be a rare corner case in libguestfs usage --
"mkfs.fat" auto-chooses FAT12 only below 9MB disk size, and even "-F 12"
can only be forced up to and including 255MB disk size.

Add the helper function "has_bogus_mbr" to the Utils module; we'll use it
elsewhere too.

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1931821
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Richard W.M. Jones <rjones@redhat.com>
Message-Id: <20211125094954.9713-5-lersek@redhat.com>
[lersek@redhat.com: drop "fun" keyword, and use partial application, in
 the definition of "sec0at" [Rich]]
2021-11-26 10:17:05 +01:00
Richard W.M. Jones
0e17236d7d Update copyright dates to 2020. 2020-03-06 19:32:32 +00:00
Richard W.M. Jones
05d4fcb64d Update copyright dates for 2019.
This command run over the source:

perl -pi.bak -e 's/(20[01][0-9])-2018/$1-2019/g' `git ls-files`
2019-01-08 11:58:30 +00:00
Richard W.M. Jones
212762c593 Update copyright dates for 2018.
Run the following command over the source:

  perl -pi.bak -e 's/(20[01][0-9])-2017/$1-2018/g' `git ls-files`
2018-01-04 15:30:10 +00:00
Pino Toscano
93ceed59a3 daemon: add split_key_value_strings helper
Add a simple helper to turn a list of strings into key/value pairs,
splitting by '=', with the possibility to apply a function to unquote
values.

Add also a simple unquote function.
2017-10-16 18:30:24 +02:00
Richard W.M. Jones
11b8a5db19 daemon: utils: New functions and tests.
These utility functions will be used in the OCaml inspection code.
2017-09-16 22:27:16 +01:00
Richard W.M. Jones
07ba8b6d6b daemon: Refine check for Device and Dev_or_Path parameters (RHBZ#1477623).
For Device parameters we expect a block device name.  However we were
only testing for "/dev/..." and so chardevs (from the appliance) could
be passed here, resulting in strange effects.  This adds a function
is_device_parameter which tests for a valid block device name.

For Dev_or_Path parameters much the same, except we can also use the
is_device_parameter function elsewhere in the daemon to distinguish if
we were called with a device or path parameter.  Previously we used a
simple test if the path begins with "/dev/...".

Reported by Mathieu Tarral.
2017-08-08 17:50:23 +01:00
Richard W.M. Jones
0bf521cfcb daemon: Deduplicate some utility functions.
The following functions were previously reimplemented in OCaml.  This
commit replaces them with calls to the C functions:

 - is_root_device
 - prog_exists
 - udev_settle

plus the internal get_verbose_flag function.

However note that we cannot do this for every utility function.  In
particular the C function must not call any reply* functions.
2017-08-08 16:23:42 +01:00
Richard W.M. Jones
bedb6c1322 daemon: Reimplement several devsparts APIs in OCaml.
The reimplemented APIs are:

* list_devices
* list_partitions
* part_to_dev
* part_to_partnum
* is_whole_device
2017-07-27 22:31:22 +01:00
Richard W.M. Jones
d5b6f1df5f daemon: Allow parts of the daemon and APIs to be written in OCaml.
This change allows parts of the daemon to be written in the OCaml
programming language.  I am using the ‘Main Program in C’ method along
with ‘-output-obj’ to create an object file from the OCaml code /
runtime, as described here:
https://caml.inria.fr/pub/docs/manual-ocaml/intfc.html

Furthermore, change the generator to allow individual APIs to be
implemented in OCaml.  This is picked by setting:

  impl = OCaml <ocaml_function>;

The generator creates ‘do_function’ (the same one you would have to
write by hand in C), with the function calling the named
‘ocaml_function’ and dealing with marshalling/unmarshalling the OCaml
parameters.
2017-07-27 22:31:22 +01:00