Deleted Added
full compact
label.c (8581) label.c (8589)
1/*
2 * The new sysinstall program.
3 *
4 * This is probably the last program in the `sysinstall' line - the next
5 * generation being essentially a complete rewrite.
6 *
1/*
2 * The new sysinstall program.
3 *
4 * This is probably the last program in the `sysinstall' line - the next
5 * generation being essentially a complete rewrite.
6 *
7 * $Id: label.c,v 1.4 1995/05/17 15:41:52 jkh Exp $
7 * $Id: label.c,v 1.5 1995/05/17 16:16:09 jkh Exp $
8 *
9 * Copyright (c) 1995
10 * Jordan Hubbard. All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright

--- 170 unchanged lines hidden (view full) ---

186 strncpy(ret->mountpoint, mpoint, FILENAME_MAX);
187 strcpy(ret->newfs_cmd, "newfs");
188 ret->newfs = newfs;
189 return ret;
190}
191
192/* Get the mountpoint for a partition and save it away */
193PartInfo *
8 *
9 * Copyright (c) 1995
10 * Jordan Hubbard. All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright

--- 170 unchanged lines hidden (view full) ---

186 strncpy(ret->mountpoint, mpoint, FILENAME_MAX);
187 strcpy(ret->newfs_cmd, "newfs");
188 ret->newfs = newfs;
189 return ret;
190}
191
192/* Get the mountpoint for a partition and save it away */
193PartInfo *
194get_mountpoint(struct chunk *parent, struct chunk *me)
194get_mountpoint(struct chunk *old)
195{
196 char *val;
197 PartInfo *tmp;
198
195{
196 char *val;
197 PartInfo *tmp;
198
199 val = msgGetInput(me && me->private ? ((PartInfo *)me->private)->mountpoint : NULL,
199 val = msgGetInput(old && old->private ? ((PartInfo *)old->private)->mountpoint : NULL,
200 "Please specify a mount point for the partition");
201 if (val) {
202 /* Is it just the same value? */
200 "Please specify a mount point for the partition");
201 if (val) {
202 /* Is it just the same value? */
203 if (me && me->private && !strcmp(((PartInfo *)me->private)->mountpoint, val))
203 if (old && old->private && !strcmp(((PartInfo *)old->private)->mountpoint, val))
204 return NULL;
205 if (check_conflict(val)) {
206 msgConfirm("You already have a mount point for %s assigned!", val);
207 return NULL;
208 }
209 else if (*val != '/') {
210 msgConfirm("Mount point must start with a / character");
211 return NULL;
212 }
213 else if (!strcmp(val, "/")) {
204 return NULL;
205 if (check_conflict(val)) {
206 msgConfirm("You already have a mount point for %s assigned!", val);
207 return NULL;
208 }
209 else if (*val != '/') {
210 msgConfirm("Mount point must start with a / character");
211 return NULL;
212 }
213 else if (!strcmp(val, "/")) {
214#if 0
215 if (parent) {
216 if (parent->flags & CHUNK_PAST_1024) {
217 msgConfirm("This region cannot be used for your root partition as\nit is past the 1024'th cylinder mark and the system would not be\nable to boot from it. Please pick another location for your\nroot partition and try again!");
218 return NULL;
219 }
220 else if (!(parent->flags & CHUNK_BSD_COMPAT)) {
221 msgConfirm("This region cannot be used for your root partition as\nthe FreeBSD boot code cannot deal with a root partition created in\nsuch a region. Please choose another partition for this.");
222 return NULL;
223 }
224 }
225#endif
226 if (me)
227 me->flags |= CHUNK_IS_ROOT;
214 if (old)
215 old->flags |= CHUNK_IS_ROOT;
228 }
216 }
229 else if (me)
230 me->flags &= ~CHUNK_IS_ROOT;
231 safe_free(me ? me->private : NULL);
217 else if (old)
218 old->flags &= ~CHUNK_IS_ROOT;
219 safe_free(old ? old->private : NULL);
232 tmp = new_part(val, TRUE);
220 tmp = new_part(val, TRUE);
233 if (me) {
234 me->private = tmp;
235 me->private_free = safe_free;
221 if (old) {
222 old->private = tmp;
223 old->private_free = safe_free;
236 }
237 return tmp;
238 }
239 return NULL;
240}
241
242/* Get the type of the new partiton */
243static PartType

--- 43 unchanged lines hidden (view full) ---

287
288/* stick this all up on the screen */
289static void
290print_label_chunks(void)
291{
292 int i, j, srow, prow, pcol;
293 int sz;
294
224 }
225 return tmp;
226 }
227 return NULL;
228}
229
230/* Get the type of the new partiton */
231static PartType

--- 43 unchanged lines hidden (view full) ---

275
276/* stick this all up on the screen */
277static void
278print_label_chunks(void)
279{
280 int i, j, srow, prow, pcol;
281 int sz;
282
295 dialog_clear();
283 clear();
296 attrset(A_REVERSE);
297 mvaddstr(0, 25, "FreeBSD Disklabel Editor");
298 attrset(A_NORMAL);
299
300 for (i = 0; i < 2; i++) {
301 attrset(A_UNDERLINE);
302 mvaddstr(CHUNK_PART_START_ROW - 1, PART_PART_COL + (i * PART_OFF),
303 "Part");

--- 184 unchanged lines hidden (view full) ---

488
489 if (*cp && toupper(*cp) == 'M')
490 size *= 2048;
491
492 type = get_partition_type();
493 if (type == PART_NONE)
494 break;
495 else if (type == PART_FILESYSTEM) {
284 attrset(A_REVERSE);
285 mvaddstr(0, 25, "FreeBSD Disklabel Editor");
286 attrset(A_NORMAL);
287
288 for (i = 0; i < 2; i++) {
289 attrset(A_UNDERLINE);
290 mvaddstr(CHUNK_PART_START_ROW - 1, PART_PART_COL + (i * PART_OFF),
291 "Part");

--- 184 unchanged lines hidden (view full) ---

476
477 if (*cp && toupper(*cp) == 'M')
478 size *= 2048;
479
480 type = get_partition_type();
481 if (type == PART_NONE)
482 break;
483 else if (type == PART_FILESYSTEM) {
496 if ((p = get_mountpoint(label_chunk_info[here].c, NULL)) == NULL)
484 if ((p = get_mountpoint(NULL)) == NULL)
497 break;
498 else if (!strcmp(p->mountpoint, "/"))
499 flags |= CHUNK_IS_ROOT;
500 else
501 flags &= ~CHUNK_IS_ROOT;
502 }
503 else
504 p = NULL;
505
506 tmp = Create_Chunk_DWIM(label_chunk_info[here].d,
507 label_chunk_info[here].c,
508 size, part,
509 (type == PART_SWAP) ? FS_SWAP : FS_BSDFFS,
510 flags);
485 break;
486 else if (!strcmp(p->mountpoint, "/"))
487 flags |= CHUNK_IS_ROOT;
488 else
489 flags &= ~CHUNK_IS_ROOT;
490 }
491 else
492 p = NULL;
493
494 tmp = Create_Chunk_DWIM(label_chunk_info[here].d,
495 label_chunk_info[here].c,
496 size, part,
497 (type == PART_SWAP) ? FS_SWAP : FS_BSDFFS,
498 flags);
511 if (!tmp)
499 if (!tmp) {
512 msgConfirm("Unable to create the partition. Too big?");
500 msgConfirm("Unable to create the partition. Too big?");
513 else {
514 tmp->private = p;
515 tmp->private_free = safe_free;
516 record_label_chunks();
501 break;
517 }
502 }
503 else if (flags & CHUNK_IS_ROOT) {
504 if (tmp->flags & CHUNK_PAST_1024) {
505 msgConfirm("This region cannot be used for your root partition as it starts\nor extends past the 1024'th cylinder mark and is thus a\npoor location to boot from. Please choose another\nlocation for your root partition and try again!");
506 Delete_Chunk(label_chunk_info[here].d, tmp);
507 break;
508 }
509 else if (!(tmp->flags & CHUNK_BSD_COMPAT)) {
510 msgConfirm("This region cannot be used for your root partition as\nthe FreeBSD boot code cannot deal with a root partition created in\nsuch a location. Please choose another location for your root\npartition and try again!");
511 Delete_Chunk(label_chunk_info[here].d, tmp);
512 break;
513 }
514 }
515 tmp->private = p;
516 tmp->private_free = safe_free;
517 record_label_chunks();
518 }
519 }
520 break;
521
522 case 'D': /* delete */
523 if (label_chunk_info[here].type == PART_SLICE) {
524 msg = MSG_NOT_APPLICABLE;
525 break;

--- 13 unchanged lines hidden (view full) ---

539 break;
540
541 case PART_SWAP:
542 msg = "You don't need to specify a mountpoint for a swap partition.";
543 break;
544
545 case PART_FAT:
546 case PART_FILESYSTEM:
518 }
519 }
520 break;
521
522 case 'D': /* delete */
523 if (label_chunk_info[here].type == PART_SLICE) {
524 msg = MSG_NOT_APPLICABLE;
525 break;

--- 13 unchanged lines hidden (view full) ---

539 break;
540
541 case PART_SWAP:
542 msg = "You don't need to specify a mountpoint for a swap partition.";
543 break;
544
545 case PART_FAT:
546 case PART_FILESYSTEM:
547 p = get_mountpoint(NULL, label_chunk_info[here].c);
547 p = get_mountpoint(label_chunk_info[here].c);
548 if (p) {
549 p->newfs = FALSE;
550 record_label_chunks();
551 }
552 break;
553
554 default:
555 msgFatal("Bogus partition under cursor???");

--- 62 unchanged lines hidden ---
548 if (p) {
549 p->newfs = FALSE;
550 record_label_chunks();
551 }
552 break;
553
554 default:
555 msgFatal("Bogus partition under cursor???");

--- 62 unchanged lines hidden ---