From 505a26ad9794776d7b018c81bf993751fba6b06f Mon Sep 17 00:00:00 2001 From: Michal Soltys Date: Sun, 22 Aug 2010 23:31:55 +0200 Subject: [PATCH] chain, options: fixes, additions - add 'bss=' option - update usage() - ommited offsets in 'file=' and 'sect=' default to 0x7c00 now - cosmetics Signed-off-by: Michal Soltys --- com32/chain/chain.c | 16 ++++------------ com32/chain/options.c | 40 +++++++++++++++++++++++++++++----------- com32/chain/utility.c | 1 + 3 files changed, 34 insertions(+), 23 deletions(-) diff --git a/com32/chain/chain.c b/com32/chain/chain.c index 88424db..7eed880 100644 --- a/com32/chain/chain.c +++ b/com32/chain/chain.c @@ -302,11 +302,11 @@ static void hide_unhide(const struct part_iter *_iter) if (_iter->type != typedos) { error("Option 'hide' is only meaningful for legacy partition scheme."); - goto out; + goto bail; } if (!(mbr = disk_read_sectors(&_iter->di, 0, 1))) { error("WARNING: Couldn't read MBR to hide/unhide partitions.\n"); - goto out; + goto bail; } if (_iter->index < 1 || _iter->index > 4) @@ -330,7 +330,7 @@ static void hide_unhide(const struct part_iter *_iter) if (write_back && disk_write_verify_sector(&_iter->di, 0, mbr)) error("WARNING: failed to write MBR for option 'hide'\n"); -out: +bail: free(mbr); } @@ -350,7 +350,6 @@ int find_dp(struct part_iter **_iter) error("Unable to find requested MBR signature.\n"); goto bail; } - } else if (!strncmp(opt.drivename, "guid", 4)) { if (str_to_guid(opt.drivename + 5, &gpt_guid)) goto bail; @@ -358,7 +357,6 @@ int find_dp(struct part_iter **_iter) error("Unable to find requested GPT disk or partition by guid.\n"); goto bail; } - } else if (!strncmp(opt.drivename, "label", 5)) { if (!opt.drivename[6]) { error("No label specified.\n"); @@ -368,7 +366,6 @@ int find_dp(struct part_iter **_iter) error("Unable to find requested GPT partition by label.\n"); goto bail; } - } else if ((opt.drivename[0] == 'h' || opt.drivename[0] == 'f') && opt.drivename[1] == 'd') { hd = opt.drivename[0] == 'h' ? 0x80 : 0; @@ -387,19 +384,14 @@ int find_dp(struct part_iter **_iter) "'boot' and 'fs' are meaningless.\n"); goto bail; } -#if 0 /* offsets match, but in case it changes in the future */ if (sdi->c.filesystem == SYSLINUX_FS_ISOLINUX) { drive = sdi->iso.drive_number; fs_lba = *sdi->iso.partoffset; } else { -#endif drive = sdi->disk.drive_number; fs_lba = *sdi->disk.partoffset; -#if 0 } -#endif - if (disk_get_params(drive, &diskinfo)) goto bail; /* this will start iteration over disk emulation, possibly raw */ @@ -736,7 +728,7 @@ int main(int argc, char *argv[]) printf("iter dsk: %d\n", iter->di.disk); printf("iter idx: %d\n", iter->index); printf("iter lba: %llu\n", iter->start_lba); - if (hand_area) + if (hidx >= 0) printf("hand lba: %u\n", hand_area->start_lba); #endif diff --git a/com32/chain/options.c b/com32/chain/options.c index efb563d..3514124 100644 --- a/com32/chain/options.c +++ b/com32/chain/options.c @@ -10,13 +10,13 @@ int soi_s2n(char *ptr, unsigned int *seg, unsigned int *off, unsigned int *ip) { - unsigned int segval = 0, offval = 0, ipval = 0, val; + unsigned int segval = 0, offval = 0x7c00, ipval = 0x7c00, val; char *p; segval = strtoul(ptr, &p, 0); - if (*p == ':') + if (p[0] == ':' && p[1] && p[1] != ':') offval = strtoul(p+1, &p, 0); - if (*p == ':') + if (p[0] == ':' && p[1] && p[1] != ':') ipval = strtoul(p+1, NULL, 0); val = (segval << 4) + offval; @@ -47,7 +47,10 @@ bail: void usage(void) { - static const char *const usage[] = { "\ + unsigned int i; + static const char key[] = "Press any key...\n"; + static const char *const usage[] = { +"\ Usage:\n\ chain.c32 [options]\n\ chain.c32 {fd|hd} [] [options]\n\ @@ -56,16 +59,18 @@ Usage:\n\ chain.c32 label{:|=}