Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

filesystem: store the actual size in bytes alongside the human readable size #1759

Merged
merged 1 commit into from
Aug 9, 2023

Commits on Aug 9, 2023

  1. filesystem: store the actual size in bytes alongside the human readab…

    …le size
    
    Currently, the partition form stores the size as a human readable value.
    (e.g., 123456K, 1.1G, 1.876G, 100G). When we exit the size field (i.e., upon
    losing focus), we convert the value to a number of bytes and then align
    it up to the nearest MiB (or whatever the alignment requirement is).
    
    Unfortunately, after computing the aligned value, we turn it back into a
    human-readable string and store it as is. It is not okay because the
    conversion does not ensure that the alignment requirement is still
    honored.
    
    For instance, if the user types in 1.1G, we do the following:
    
     * convert it to a number of bytes -> 1181116006.4 (surprise, it is not
       even an integer).
    
     * round it up to the nearest MiB -> 1181745152 (this is the correct
       value)
    
     * transform it into a human readable string and store it as is -> 1.1G
       - which actually corresponds to the original value.
    
    This leads to an exception later when creating the partition:
    
        File "subiquity/models/filesystem.py", line 1841, in add_partition
          raise Exception(
       Exception: ('size %s or offset %s not aligned to %s', 1181116006, 1048576, 1048576)
    
    Fixed by storing the actual size as a number of bytes - alongside the
    human readable size.
    
    Signed-off-by: Olivier Gayot <[email protected]>
    ogayot committed Aug 9, 2023
    Configuration menu
    Copy the full SHA
    cda6c54 View commit details
    Browse the repository at this point in the history