label.c (8702) | label.c (8705) |
---|---|
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.20 1995/05/21 18:24:33 jkh Exp $ | 7 * $Id: label.c,v 1.21 1995/05/22 14:10:20 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 --- 31 unchanged lines hidden (view full) --- 47 48/* 49 * Everything to do with editing the contents of disk labels. 50 */ 51 52/* A nice message we use a lot in the disklabel editor */ 53#define MSG_NOT_APPLICABLE "That option is not applicable here" 54 | 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 --- 31 unchanged lines hidden (view full) --- 47 48/* 49 * Everything to do with editing the contents of disk labels. 50 */ 51 52/* A nice message we use a lot in the disklabel editor */ 53#define MSG_NOT_APPLICABLE "That option is not applicable here" 54 |
55/* 56 * I make some pretty gross assumptions about having a max of 50 chunks 57 * total - 8 slices and 42 partitions. I can't easily display many more 58 * than that on the screen at once! 59 * 60 * For 2.1 I'll revisit this and try to make it more dynamic, but since 61 * this will catch 99.99% of all possible cases, I'm not too worried. 62 */ 63#define MAX_CHUNKS 50 64 | |
65/* Where to start printing the freebsd slices */ 66#define CHUNK_SLICE_START_ROW 2 67#define CHUNK_PART_START_ROW 11 68 69/* One MB worth of blocks */ 70#define ONE_MEG 2048 71 72/* The smallest filesystem we're willing to create */ --- 270 unchanged lines hidden (view full) --- 343 */ 344 memset(onestr, ' ', PART_OFF - 1); 345 onestr[PART_OFF - 1] = '\0'; 346 /* Go for two columns */ 347 if (prow == (CHUNK_PART_START_ROW + CHUNK_COLUMN_MAX)) { 348 pcol = PART_OFF; 349 prow = CHUNK_PART_START_ROW; 350 } | 55/* Where to start printing the freebsd slices */ 56#define CHUNK_SLICE_START_ROW 2 57#define CHUNK_PART_START_ROW 11 58 59/* One MB worth of blocks */ 60#define ONE_MEG 2048 61 62/* The smallest filesystem we're willing to create */ --- 270 unchanged lines hidden (view full) --- 333 */ 334 memset(onestr, ' ', PART_OFF - 1); 335 onestr[PART_OFF - 1] = '\0'; 336 /* Go for two columns */ 337 if (prow == (CHUNK_PART_START_ROW + CHUNK_COLUMN_MAX)) { 338 pcol = PART_OFF; 339 prow = CHUNK_PART_START_ROW; 340 } |
351 memcpy(onestr + PART_PART_COL, label_chunk_info[i].c->name, 352 strlen(label_chunk_info[i].c->name)); | 341 memcpy(onestr + PART_PART_COL, label_chunk_info[i].c->name, strlen(label_chunk_info[i].c->name)); |
353 /* If it's a filesystem, display the mountpoint */ | 342 /* If it's a filesystem, display the mountpoint */ |
354 if (label_chunk_info[i].type == PART_FILESYSTEM) { | 343 if (label_chunk_info[i].type == PART_FILESYSTEM || label_chunk_info[i].type == PART_FAT) { |
355 if (label_chunk_info[i].c->private == NULL) { 356 static int mnt = 0; 357 char foo[10]; 358 359 /* 360 * Hmm! A partition that must have already been here. 361 * Fill in a fake mountpoint and register it 362 */ 363 sprintf(foo, "/mnt%d", mnt++); | 344 if (label_chunk_info[i].c->private == NULL) { 345 static int mnt = 0; 346 char foo[10]; 347 348 /* 349 * Hmm! A partition that must have already been here. 350 * Fill in a fake mountpoint and register it 351 */ 352 sprintf(foo, "/mnt%d", mnt++); |
364 label_chunk_info[i].c->private = 365 new_part(foo, FALSE,label_chunk_info[i].c->size); | 353 label_chunk_info[i].c->private = new_part(foo, FALSE, label_chunk_info[i].c->size); |
366 label_chunk_info[i].c->private_free = safe_free; 367 } 368 mountpoint = ((PartInfo *)label_chunk_info[i].c->private)->mountpoint; | 354 label_chunk_info[i].c->private_free = safe_free; 355 } 356 mountpoint = ((PartInfo *)label_chunk_info[i].c->private)->mountpoint; |
369 newfs = ((PartInfo *)label_chunk_info[i].c->private)->newfs ? "Y" : "N"; | 357 if (label_chunk_info[i].type == PART_FAT) 358 newfs = "DOS"; 359 else 360 newfs = ((PartInfo *)label_chunk_info[i].c->private)->newfs ? "Y" : "N"; |
370 } 371 else if (label_chunk_info[i].type == PART_SWAP) { 372 mountpoint = "swap"; 373 newfs = " "; 374 } | 361 } 362 else if (label_chunk_info[i].type == PART_SWAP) { 363 mountpoint = "swap"; 364 newfs = " "; 365 } |
375 else if (label_chunk_info[i].type == PART_FAT) { 376 mountpoint = "DOS FAT"; 377 newfs = "*"; 378 } | |
379 else { | 366 else { |
380 mountpoint = "<unknown>"; | 367 mountpoint = "<NONE>"; |
381 newfs = "*"; 382 } 383 for (j = 0; j < MAX_MOUNT_NAME && mountpoint[j]; j++) 384 onestr[PART_MOUNT_COL + j] = mountpoint[j]; 385 snprintf(num, 10, "%4ldMB", label_chunk_info[i].c->size ? 386 label_chunk_info[i].c->size / ONE_MEG : 0); 387 memcpy(onestr + PART_SIZE_COL, num, strlen(num)); 388 memcpy(onestr + PART_NEWFS_COL, newfs, strlen(newfs)); --- 87 unchanged lines hidden (view full) --- 476 break; 477 } 478 sz = space_free(label_chunk_info[here].c); 479 if (sz <= FS_MIN_SIZE) { 480 msg = "Not enough space to create additional FreeBSD partition"; 481 break; 482 } 483 { | 368 newfs = "*"; 369 } 370 for (j = 0; j < MAX_MOUNT_NAME && mountpoint[j]; j++) 371 onestr[PART_MOUNT_COL + j] = mountpoint[j]; 372 snprintf(num, 10, "%4ldMB", label_chunk_info[i].c->size ? 373 label_chunk_info[i].c->size / ONE_MEG : 0); 374 memcpy(onestr + PART_SIZE_COL, num, strlen(num)); 375 memcpy(onestr + PART_NEWFS_COL, newfs, strlen(newfs)); --- 87 unchanged lines hidden (view full) --- 463 break; 464 } 465 sz = space_free(label_chunk_info[here].c); 466 if (sz <= FS_MIN_SIZE) { 467 msg = "Not enough space to create additional FreeBSD partition"; 468 break; 469 } 470 { |
484 char *val, *cp, tmpb[20]; | 471 char *val, *cp; |
485 int size; 486 struct chunk *tmp; 487 u_long flags = 0; 488 | 472 int size; 473 struct chunk *tmp; 474 u_long flags = 0; 475 |
489 snprintf(tmpb, 20, "%d", sz); 490 val = msgGetInput(tmpb, "Please specify the size for new FreeBSD partition in blocks, or append\na trailing `M' for megabytes (e.g. 20M)."); | 476 val = msgGetInput(NULL, "Please specify the size for new FreeBSD partition in blocks, or append\na trailing `M' for megabytes (e.g. 20M).\nSpace free: %d blocks (%dMB)", sz, sz / ONE_MEG); |
491 if (!val || (size = strtol(val, &cp, 0)) <= 0) 492 break; 493 494 if (sz <= FS_MIN_SIZE) { 495 msgConfirm("The minimum filesystem size is %dMB", FS_MIN_SIZE / ONE_MEG); 496 break; 497 } 498 if (*cp && toupper(*cp) == 'M') --- 13 unchanged lines hidden (view full) --- 512 } else 513 p = NULL; 514 515 if ((flags & CHUNK_IS_ROOT)) { 516 if (!(label_chunk_info[here].c->flags & CHUNK_BSD_COMPAT)) { 517 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!"); 518 break; 519 } | 477 if (!val || (size = strtol(val, &cp, 0)) <= 0) 478 break; 479 480 if (sz <= FS_MIN_SIZE) { 481 msgConfirm("The minimum filesystem size is %dMB", FS_MIN_SIZE / ONE_MEG); 482 break; 483 } 484 if (*cp && toupper(*cp) == 'M') --- 13 unchanged lines hidden (view full) --- 498 } else 499 p = NULL; 500 501 if ((flags & CHUNK_IS_ROOT)) { 502 if (!(label_chunk_info[here].c->flags & CHUNK_BSD_COMPAT)) { 503 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!"); 504 break; 505 } |
520 if (size < ROOT_MIN_SIZE) { 521 msgConfirm("This is too small a size for a root partition. For a variety of\nreasons, root partitions should be at least %dMB in size", ROOT_MIN_SIZE / ONE_MEG); 522 break; 523 } | 506 if (size < ROOT_MIN_SIZE) 507 msgConfirm("Warning: This is smaller than the recommended size for a\nroot partition. For a variety of reasons, root\npartitions should usually be at least %dMB in size", ROOT_MIN_SIZE / ONE_MEG); |
524 } 525 tmp = Create_Chunk_DWIM(label_chunk_info[here].d, 526 label_chunk_info[here].c, 527 size, part, 528 (type == PART_SWAP) ? FS_SWAP : FS_BSDFFS, 529 flags); 530 if (!tmp) { 531 msgConfirm("Unable to create the partition. Too big?"); --- 17 unchanged lines hidden (view full) --- 549 break; 550 551 case 'D': /* delete */ 552 if (label_chunk_info[here].type == PART_SLICE) { 553 msg = MSG_NOT_APPLICABLE; 554 break; 555 } 556 else if (label_chunk_info[here].type == PART_FAT) { | 508 } 509 tmp = Create_Chunk_DWIM(label_chunk_info[here].d, 510 label_chunk_info[here].c, 511 size, part, 512 (type == PART_SWAP) ? FS_SWAP : FS_BSDFFS, 513 flags); 514 if (!tmp) { 515 msgConfirm("Unable to create the partition. Too big?"); --- 17 unchanged lines hidden (view full) --- 533 break; 534 535 case 'D': /* delete */ 536 if (label_chunk_info[here].type == PART_SLICE) { 537 msg = MSG_NOT_APPLICABLE; 538 break; 539 } 540 else if (label_chunk_info[here].type == PART_FAT) { |
557 msg = "Use the Disk Partition Editor to delete this"; | 541 msg = "Use the Disk Partition Editor to delete DOS partitions"; |
558 break; 559 } 560 Delete_Chunk(label_chunk_info[here].d, label_chunk_info[here].c); 561 record_label_chunks(); 562 break; 563 564 case 'M': /* mount */ 565 switch(label_chunk_info[here].type) { --- 88 unchanged lines hidden --- | 542 break; 543 } 544 Delete_Chunk(label_chunk_info[here].d, label_chunk_info[here].c); 545 record_label_chunks(); 546 break; 547 548 case 'M': /* mount */ 549 switch(label_chunk_info[here].type) { --- 88 unchanged lines hidden --- |