[syslinux] [PATCH 20/28] com32/chain: index -1 partiter adjustment
Michal Soltys
soltys at ziu.info
Tue Jan 29 06:06:07 PST 2013
Currently, the only situation when index could be set to -1 was empty
logical partition (with stepall flag active). To keep things consistent
(and with index0 already providing "full" info), adjust the partiter to
also set -1 on empty main partition.
This change also allows simple index check to see whether we're are at
the empty partition or not, without digging into disk_dos_part_entry
data and retesting ostype field. We rely on it now in manglepe_hide().
Also some retab! changes in partiter.h and one variable rename.
Signed-off-by: Michal Soltys <soltys at ziu.info>
---
com32/chain/mangle.c | 4 +---
com32/chain/partiter.c | 6 +++---
com32/chain/partiter.h | 16 ++++++++--------
3 files changed, 12 insertions(+), 14 deletions(-)
diff --git a/com32/chain/mangle.c b/com32/chain/mangle.c
index 391554b..215ca41 100644
--- a/com32/chain/mangle.c
+++ b/com32/chain/mangle.c
@@ -527,7 +527,6 @@ int manglepe_hide(struct part_iter *miter)
{
int wb = 0, werr = 0;
struct part_iter *iter = NULL;
- struct disk_dos_part_entry *dp;
int ridx;
if (!(opt.hide & HIDE_ON))
@@ -549,8 +548,7 @@ int manglepe_hide(struct part_iter *miter)
if (!(opt.hide & HIDE_EXT) && ridx > 3)
break; /* skip when we're constrained to pri only */
- dp = (struct disk_dos_part_entry *)iter->record;
- if (dp->ostype)
+ if (iter->index != -1)
wb |= fliphide(iter, miter);
/*
diff --git a/com32/chain/partiter.c b/com32/chain/partiter.c
index 2e03fb5..0c11457 100644
--- a/com32/chain/partiter.c
+++ b/com32/chain/partiter.c
@@ -371,7 +371,7 @@ static int dos_next_ebr(struct part_iter *iter, uint32_t *lba,
}
if (!dp[0].ostype)
- iter->dos.skipcnt++;
+ iter->dos.logskipcnt++;
if (dp[0].ostype || (iter->flags & PIF_STEPALL)) {
*lba = iter->dos.cebr_lba + dp[0].start_lba;
@@ -471,10 +471,10 @@ static int pi_dos_next(struct part_iter *iter)
* non-PIF_STEPALL iterators
*/
- if (iter->index0 >= 4 && !dos_part->ostype)
+ if (!dos_part->ostype)
iter->index = -1;
else
- iter->index = iter->index0 - iter->dos.skipcnt + 1;
+ iter->index = iter->index0 + 1 - iter->dos.logskipcnt;
iter->start_lba = start_lba;
iter->length = dos_part->length;
iter->record = (char *)dos_part;
diff --git a/com32/chain/partiter.h b/com32/chain/partiter.h
index 4004ef9..31df785 100644
--- a/com32/chain/partiter.h
+++ b/com32/chain/partiter.h
@@ -73,17 +73,17 @@ struct part_iter {
struct disk_info di;
union {
struct {
- uint32_t disk_sig; /* 32bit disk signature as stored in MBR */
+ uint32_t disk_sig; /* 32bit disk signature as stored in MBR */
- uint32_t bebr_lba; /* absolute lba of base extended partition */
- uint32_t bebr_siz; /* size of base extended partition */
+ uint32_t bebr_lba; /* absolute lba of base extended partition */
+ uint32_t bebr_siz; /* size of base extended partition */
- uint32_t cebr_lba; /* absolute lba of curr ext. partition */
- uint32_t nebr_lba; /* absolute lba of next ext. partition */
- uint32_t nebr_siz; /* size of next ext. partition */
+ uint32_t cebr_lba; /* absolute lba of curr ext. partition */
+ uint32_t nebr_lba; /* absolute lba of next ext. partition */
+ uint32_t nebr_siz; /* size of next ext. partition */
- int bebr_index0; /* index of (0-3) of base ext. part., -1 if not present in MBR */
- int skipcnt; /* how many logical holes were skipped */
+ int bebr_index0; /* index of (0-3) of base ext. part., -1 if not present in MBR */
+ int logskipcnt; /* how many logical holes were skipped */
} dos;
struct {
struct guid disk_guid;
--
1.7.10.4
More information about the Syslinux
mailing list