From f167db559451bfdca148a712ba256d1c616b7af6 Mon Sep 17 00:00:00 2001 From: Michal Soltys Date: Thu, 30 Sep 2010 23:21:11 +0200 Subject: [PATCH] com32/chain: Add unhide and unhideall options It could be useful to be able to simply unhide partitions. This short patch adds such functionality. Signed-off-by: Michal Soltys --- com32/chain/chain.c | 14 +++++++------- com32/chain/options.c | 11 +++++++---- doc/chain.txt | 6 ++++-- 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/com32/chain/chain.c b/com32/chain/chain.c index cb619fb..ae46fec 100644 --- a/com32/chain/chain.c +++ b/com32/chain/chain.c @@ -349,7 +349,7 @@ static int pem_sethide(struct part_iter *miter, struct part_iter *iter) if ((t <= 0x1f) && ((mask >> (t & ~0x10u)) & 1)) { /* It's a hideable partition type */ - if (miter->index == iter->index) + if (miter->index == iter->index || opt.hide & 4) t &= (uint8_t)(~0x10u); /* unhide */ else t |= 0x10u; /* hide */ @@ -398,22 +398,22 @@ static int pentry_mangle(struct part_iter *miter) int ridx; if (miter->type != typedos) { - error("Partition entry mangling ('hide[all]', 'mbrchs')\n" + error("Partition entry mangling ('[un]hide[all]', 'mbrchs')\n" "is meaningful only for legacy partition scheme."); goto bail; } - if ((miter->index < 1 || miter->index > 4) && opt.hide == 1) - error("WARNING: option 'hide' specified with a non-primary partition.\n"); + if ((miter->index < 1 || miter->index > 4) && opt.hide & 1) + error("WARNING: option '[un]hide' specified with a non-primary partition.\n"); if (!(iter = pi_begin(&miter->di, 1))) /* turn on stepall */ goto bail; - while (!pi_next(&iter) && !werr && (opt.hide == 2 || opt.mbrchs)) { + while (!pi_next(&iter) && !werr && (opt.hide & 2 || opt.mbrchs)) { ridx = iter->rawindex; dp = (struct disk_dos_part_entry *)iter->record; if (dp->ostype) { - if (opt.hide == 2 || (opt.hide == 1 && ridx <= 4)) { + if (opt.hide & 2 || (opt.hide & 1 && ridx <= 4)) { wb |= pem_sethide(miter, iter); } if (opt.mbrchs) { @@ -436,7 +436,7 @@ bail: pi_del(&iter); if (werr) error("WARNING: failed to write E/MBR for partition\n" - "mangling options ('hide[all]', 'mbrchs').\n"); + "mangling options ('[un]hide[all]', 'mbrchs').\n"); return 0; } diff --git a/com32/chain/options.c b/com32/chain/options.c index 14c96d7..2c3d0ff 100644 --- a/com32/chain/options.c +++ b/com32/chain/options.c @@ -225,13 +225,16 @@ int parse_args(int argc, char *argv[]) opt.swap = true; } else if (!strcmp(argv[i], "noswap")) { opt.swap = false; - } else if (!strcmp(argv[i], "nohide") || - !strcmp(argv[i], "nohideall")) { + } else if (!strcmp(argv[i], "nohide")) { opt.hide = 0; } else if (!strcmp(argv[i], "hide")) { - opt.hide = 1; + opt.hide = 1; /* 001b */ } else if (!strcmp(argv[i], "hideall")) { - opt.hide = 2; + opt.hide = 2; /* 010b */ + } else if (!strcmp(argv[i], "unhide")) { + opt.hide = 5; /* 101b */ + } else if (!strcmp(argv[i], "unhideall")) { + opt.hide = 6; /* 110b */ } else if (!strcmp(argv[i], "setbpb")) { opt.setbpb = true; } else if (!strcmp(argv[i], "nosetbpb")) { diff --git a/doc/chain.txt b/doc/chain.txt index 886625d..76234f1 100644 --- a/doc/chain.txt +++ b/doc/chain.txt @@ -181,13 +181,15 @@ This option will install a tiny stub code used to swap drive numbers, if the drive we use during chainloading is not fd0 or hd0. hide[all] + unhide[all] *nohide In certain situations it's useful to hide partitions - for example to make sure DOS gets C:. 'hide' will hide hidable primary partitions, except the one we're booting from. Similary, 'hideall' will hide all hidable partitions, except the -one we're booting from. Hiding is performed only on the boot drive. -Writing is only performed, if the values actually got changed. +one we're booting from. Hiding is performed only on the booting drive. Options +starting with 'un' will simply unhide every partition (primary ones or all). +Writing is only performed, if the os type values actually changed. mbrchs *nombrchs -- 2.7.4