Skip to content

Conversation

@psafont
Copy link
Member

@psafont psafont commented Dec 22, 2025

These device IDs are handled in an ad-hoc way, and none of the implementations follow the actual linux behaviour, replace all of them with an in imeplementation that uses the glibc macros to handle these.

Also change vhd_wrapper_tool to print better error messages when there's an error when getting the base VHD.

I'm still testing the changes that are not unit-tested, so drafting this for the time being

Some {major; minor}

let encode_st_dev {major; minor} =
0
Copy link
Member Author

@psafont psafont Dec 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the 0 |^ is added to make ocamlformat behave and keep the first major term parenthesised and aligned. The same has been done in in decode

These device IDs are handled in an ad-hoc way, and none of the
implementations follow the actual linux behaviour.

The glibc-provided macros are used for the implementation, with a
pure-ocaml implementation that was useful to compare against while
implementing, which has been kept in the tests, to detect any
behavioural changes.

Because Unix.stat returns an `int` instead of an int64, the code does
not support all possible values for major supported by glibc. This
shouldn't be an issue in Linux since the device value is 32-bit wide.

Signed-off-by: Pau Ruiz Safont <[email protected]>
There were 5 ad-hoc implementations, they were all getting wrong results
for the minor because only the lower 8 bits were accounted for. Use the
unixext one which handles up to 32-bit-wide minors correctly.

Signed-off-by: Pau Ruiz Safont <[email protected]>
Previously, when a failure happened while getting a base vhd, a
non-descriptive error was printed. Because there can be many reasons
that can cause this code to fail, model the possible errors and print
them when needed.

Signed-off-by: Pau Ruiz Safont <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant