if (miter->index > 4 && !(opt.hide & 2))
error("WARNING: your partition is beyond mbr, so it can't be unhidden without '*hideall'.\n");
- if (!(iter = pi_begin(&miter->di, 1))) /* turn stepall on */
+ if (!(iter = pi_begin(&miter->di, PIF_STEPALL)))
return -1;
while (!pi_next(&iter) && !werr) {
return -1;
}
- if (!(iter = pi_begin(&miter->di, 1))) /* turn stepall on */
+ if (!(iter = pi_begin(&miter->di, PIF_STEPALL)))
return -1;
while (!pi_next(&iter) && !werr) {
* iter_ctor() - common iterator initialization
* @iter: iterator pointer
* @args(0): disk_info structure used for disk functions
- * @args(1): stepall modifier
+ * @args(1): flags modifier
*
* Second and further arguments are passed as a pointer to va_list
**/
static int iter_ctor(struct part_iter *iter, va_list *args)
{
const struct disk_info *di = va_arg(*args, const struct disk_info *);
- int stepall = va_arg(*args, int);
+ int flags = va_arg(*args, int);
#ifdef DEBUG
if (!di)
#endif
memcpy(&iter->di, di, sizeof(struct disk_info));
- iter->stepall = stepall;
+ iter->flags = flags;
iter->index0 = -1;
iter->length = di->lbacnt;
/* record base EBR index */
iter->dos.bebr_index0 = iter->index0;
}
- if (!ost_is_nondata(dp->ostype) || iter->stepall) {
+ if (!ost_is_nondata(dp->ostype) || (iter->flags & PIF_STEPALL)) {
*lba = dp->start_lba;
*_dp = dp;
break;
if (!dp[0].ostype)
iter->dos.skipcnt++;
- if (dp[0].ostype || iter->stepall) {
+ if (dp[0].ostype || (iter->flags & PIF_STEPALL)) {
*lba = iter->dos.cebr_lba + dp[0].start_lba;
*_dp = dp;
return 0;
goto bail;
}
- if (!guid_is0(&gpt_part->type) || iter->stepall)
+ if (!guid_is0(&gpt_part->type) || (iter->flags & PIF_STEPALL))
break;
}
/* no more partitions ? */
* This function checks the disk for GPT or legacy partition table and allocates
* an appropriate iterator.
**/
-struct part_iter *pi_begin(const struct disk_info *di, int stepall)
+struct part_iter *pi_begin(const struct disk_info *di, int flags)
{
int setraw = 0;
struct part_iter *iter = NULL;
}
}
/* allocate iterator and exit */
- iter = pi_new(typegpt, di, stepall, gpth, gptl);
+ iter = pi_new(typegpt, di, flags, gpth, gptl);
} else {
/* looks like MBR */
- iter = pi_new(typedos, di, stepall, mbr);
+ iter = pi_new(typedos, di, flags, mbr);
}
setraw = 0;
bail:
if (setraw) {
error("WARNING: treating disk as raw.\n");
- iter = pi_new(typeraw, di, stepall);
+ iter = pi_new(typeraw, di, flags);
}
free(mbr);
free(gpth);
#define PI_DONE 1
#define PI_OK 0
+/* behaviour flags */
+
+#define PIF_STEPALL 0x01
+
struct itertype;
struct part_iter;
int index;
int rawindex;
struct disk_info di;
- int stepall;
+ int flags;
int status;
/* internal */
int index0;
extern const struct itertype * const typegpt;
extern const struct itertype * const typeraw;
-struct part_iter *pi_begin(const struct disk_info *, int stepall);
+struct part_iter *pi_begin(const struct disk_info *, int flags);
struct part_iter *pi_new(const struct itertype *, ...);
void pi_del(struct part_iter **);
int pi_next(struct part_iter **);