In MSDOS 6.22 there are alignment restrictions for partitions. This means a partition of size capacity = /start - end/ = end - start, partition boundaries (start, end) must coincide with certain boundaries; in this case cylinder boundaries.
The following alignment algorithm is taken from the libvirt virtualization API.
In short, the algorithm will make sure allocated continuous space is aligned on the right, that is on the end. If the available free space for alignment already starts at a given boundary value, it will be fully aligned .
- Input: c := capacity, l := alignment interval, s := start
- Output: e := end
- s = m*l, for some m (the start is aligned at a boundary)
- s != m*l; s mod l <= r (the start offset fits into the extra space reserved for alignment)
- s != m*l; s mod l > r (the start offset doesn't fit)