diff options
author | jhb <jhb@FreeBSD.org> | 2002-11-12 21:09:58 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2002-11-12 21:09:58 +0000 |
commit | 905d7568e9f871b8af24c49de554d1bd18a5f478 (patch) | |
tree | 96aad0f9d962a835488a82a39d4b92b76cee1a73 /usr.sbin/sade/label.c | |
parent | 42ccf7bdc3014903c44e1aefbb002005a3be9129 (diff) | |
download | FreeBSD-src-905d7568e9f871b8af24c49de554d1bd18a5f478.zip FreeBSD-src-905d7568e9f871b8af24c49de554d1bd18a5f478.tar.gz |
Try to cleanup the non-interactive disk labeling code a bit. Rework
the loop that runs through the environment variables to be a bit more
intuitive. Also, change some 'continue's in failure cases to 'break's
instead. If we are going to fail, we should just do it.
PR: bin/40654
Submitted by: Thomas Zenker <thz@Lennartz-electronic.de> (partially)
Diffstat (limited to 'usr.sbin/sade/label.c')
-rw-r--r-- | usr.sbin/sade/label.c | 88 |
1 files changed, 39 insertions, 49 deletions
diff --git a/usr.sbin/sade/label.c b/usr.sbin/sade/label.c index b7bc035..7308071 100644 --- a/usr.sbin/sade/label.c +++ b/usr.sbin/sade/label.c @@ -1352,62 +1352,52 @@ diskLabelNonInteractive(Device *dev) if (label_chunk_info[i].type == PART_SLICE) { char name[512]; - int entries = 1; + char typ[10], mpoint[50]; + int entries; - while (entries) { + for (entries = 1;; entries++) { + int sz, soft = 0; snprintf(name, sizeof name, "%s-%d", c1->name, entries); - if ((cp = variable_get(name)) != NULL) { - int sz, soft = 0; - char typ[10], mpoint[50]; - - if (sscanf(cp, "%s %d %s %d", typ, &sz, mpoint, &soft) < 3) { - msgConfirm("For slice entry %s, got an invalid detail entry of: %s", c1->name, cp); + if ((cp = variable_get(name)) == NULL) + break; + if (sscanf(cp, "%s %d %s %d", typ, &sz, mpoint, &soft) < 3) { + msgConfirm("For slice entry %s, got an invalid detail entry of: %s", c1->name, cp); + status = DITEM_FAILURE; + break; + } else { + Chunk *tmp; + + if (!strcmp(typ, "swap")) { + type = PART_SWAP; + strcpy(mpoint, "SWAP"); + } else { + type = PART_FILESYSTEM; + if (!strcmp(mpoint, "/")) + flags |= CHUNK_IS_ROOT; + else + flags &= ~CHUNK_IS_ROOT; + } + if (!sz) + sz = space_free(c1); + if (sz > space_free(c1)) { + msgConfirm("Not enough free space to create partition: %s", mpoint); status = DITEM_FAILURE; - continue; + break; } - else { - Chunk *tmp; - - if (!strcmp(typ, "swap")) { - type = PART_SWAP; - strcpy(mpoint, "SWAP"); - } - else { - type = PART_FILESYSTEM; - if (!strcmp(mpoint, "/")) - flags |= CHUNK_IS_ROOT; - else - flags &= ~CHUNK_IS_ROOT; - } - if (!sz) - sz = space_free(c1); - if (sz > space_free(c1)) { - msgConfirm("Not enough free space to create partition: %s", mpoint); - status = DITEM_FAILURE; - continue; - } - if (!(tmp = Create_Chunk_DWIM(d, c1, sz, part, - (type == PART_SWAP) ? FS_SWAP : FS_BSDFFS, flags))) { - msgConfirm("Unable to create from partition spec: %s. Too big?", cp); - status = DITEM_FAILURE; - break; - } - else { - tmp->private_data = new_part(mpoint, TRUE); - tmp->private_free = safe_free; - ((PartInfo *)tmp->private_data)->soft = soft; - status = DITEM_SUCCESS; - } + if (!(tmp = Create_Chunk_DWIM(d, c1, sz, part, + (type == PART_SWAP) ? FS_SWAP : FS_BSDFFS, flags))) { + msgConfirm("Unable to create from partition spec: %s. Too big?", cp); + status = DITEM_FAILURE; + break; + } else { + tmp->private_data = new_part(mpoint, TRUE); + tmp->private_free = safe_free; + ((PartInfo *)tmp->private_data)->soft = soft; + status = DITEM_SUCCESS; } - entries++; - } - else { - /* No more matches, leave the loop */ - entries = 0; } } - } - else { + } else { /* Must be something we can set a mountpoint for */ cp = variable_get(c1->name); if (cp) { |