diff options
| author | Karel Zak <kzak@redhat.com> | 2012-12-04 17:54:15 +0100 |
|---|---|---|
| committer | Karel Zak <kzak@redhat.com> | 2012-12-04 17:54:15 +0100 |
| commit | 512a430fe7acf705880eaddb887653b79f8dc223 (patch) | |
| tree | a3e1a0b7935bd6d06df6a27af995c8fc599d8f58 /fdisks/fdisk.c | |
| parent | 602ebe7da99c2294b63a76140a1a2626d3dc7b63 (diff) | |
| download | util-linux-512a430fe7acf705880eaddb887653b79f8dc223.tar.gz | |
fdisk: (gpt) align newly created partitions
- default "First sector" has to be aligned
- "Last sector" has to be aligned if specified by +<size><suffix> convention
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'fdisks/fdisk.c')
| -rw-r--r-- | fdisks/fdisk.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/fdisks/fdisk.c b/fdisks/fdisk.c index 7c3fee4b..dd06b9b2 100644 --- a/fdisks/fdisk.c +++ b/fdisks/fdisk.c @@ -352,6 +352,22 @@ sector_t align_lba(struct fdisk_context *cxt, sector_t lba, int direction) return res; } + +sector_t align_lba_in_range(struct fdisk_context *cxt, + sector_t lba, sector_t start, sector_t stop) +{ + start = align_lba(cxt, start, ALIGN_UP); + stop = align_lba(cxt, stop, ALIGN_DOWN); + + lba = align_lba(cxt, lba, ALIGN_NEAREST); + + if (lba < start) + return start; + else if (lba > stop) + return stop; + return lba; +} + int warn_geometry(struct fdisk_context *cxt) { char *m = NULL; |
