devices.c (8262) | devices.c (8278) |
---|---|
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: devices.c,v 1.1 1995/05/01 21:56:19 jkh Exp $ | 7 * $Id: devices.c,v 1.2 1995/05/04 03:51:14 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 --- 22 unchanged lines hidden (view full) --- 38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 40 * SUCH DAMAGE. 41 * 42 */ 43 44#include "sysinstall.h" 45#include "libdisk.h" | 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 --- 22 unchanged lines hidden (view full) --- 38 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 40 * SUCH DAMAGE. 41 * 42 */ 43 44#include "sysinstall.h" 45#include "libdisk.h" |
46#include <ctype.h> |
|
46 47/* Where we start displaying chunk information on the screen */ 48#define CHUNK_START_ROW 5 49 50/* Get all device information for a given device class */ 51Device * 52device_get_all(DeviceType which, int *ndevs) 53{ --- 53 unchanged lines hidden (view full) --- 107 mvaddstr(0, 0, "Disk name:\t"); 108 attrset(A_BOLD); addstr(disk); attrset(A_NORMAL); 109 mvprintw(1, 0, 110 "BIOS Geometry:\t%lu cyls/%lu heads/%lu sectors", 111 d->bios_cyl, d->bios_hd, d->bios_sect); 112 mvprintw(3, 1, "%10s %10s %10s %8s %8s %8s %8s %8s", 113 "Offset", "Size", "End", "Name", "PType", "Desc", 114 "Subtype", "Flags"); | 47 48/* Where we start displaying chunk information on the screen */ 49#define CHUNK_START_ROW 5 50 51/* Get all device information for a given device class */ 52Device * 53device_get_all(DeviceType which, int *ndevs) 54{ --- 53 unchanged lines hidden (view full) --- 108 mvaddstr(0, 0, "Disk name:\t"); 109 attrset(A_BOLD); addstr(disk); attrset(A_NORMAL); 110 mvprintw(1, 0, 111 "BIOS Geometry:\t%lu cyls/%lu heads/%lu sectors", 112 d->bios_cyl, d->bios_hd, d->bios_sect); 113 mvprintw(3, 1, "%10s %10s %10s %8s %8s %8s %8s %8s", 114 "Offset", "Size", "End", "Name", "PType", "Desc", 115 "Subtype", "Flags"); |
115 attrset(A_NORMAL); | |
116 for (i = 0, row = CHUNK_START_ROW; chunk_info[i]; i++, row++) { 117 if (i == current_chunk) 118 attrset(A_BOLD); 119 mvprintw(row, 2, "%10lu %10lu %10lu %8s %8d %8s %8d %6lx", 120 chunk_info[i]->offset, chunk_info[i]->size, 121 chunk_info[i]->end, chunk_info[i]->name, 122 chunk_info[i]->type, chunk_n[chunk_info[i]->type], 123 chunk_info[i]->subtype, chunk_info[i]->flags); 124 if (i == current_chunk) 125 attrset(A_NORMAL); 126 } 127} 128 129static void 130print_command_summary() 131{ 132 mvprintw(15, 0, "The following commands are supported (in upper or lower case):"); 133 mvprintw(17, 0, "C = Create New Partition D = Delete Partition"); 134 mvprintw(18, 0, "B = Scan For Bad Blocks U = Undo All Changes"); | 116 for (i = 0, row = CHUNK_START_ROW; chunk_info[i]; i++, row++) { 117 if (i == current_chunk) 118 attrset(A_BOLD); 119 mvprintw(row, 2, "%10lu %10lu %10lu %8s %8d %8s %8d %6lx", 120 chunk_info[i]->offset, chunk_info[i]->size, 121 chunk_info[i]->end, chunk_info[i]->name, 122 chunk_info[i]->type, chunk_n[chunk_info[i]->type], 123 chunk_info[i]->subtype, chunk_info[i]->flags); 124 if (i == current_chunk) 125 attrset(A_NORMAL); 126 } 127} 128 129static void 130print_command_summary() 131{ 132 mvprintw(15, 0, "The following commands are supported (in upper or lower case):"); 133 mvprintw(17, 0, "C = Create New Partition D = Delete Partition"); 134 mvprintw(18, 0, "B = Scan For Bad Blocks U = Undo All Changes"); |
135 mvprintw(19, 0, "ESC = Proceed to next screen"); | 135 mvprintw(19, 0, "W = Write Changes ESC = Proceed to next screen"); |
136 mvprintw(21, 0, "The currently selected partition is displayed in "); 137 attrset(A_BOLD); addstr("bold"); attrset(A_NORMAL); | 136 mvprintw(21, 0, "The currently selected partition is displayed in "); 137 attrset(A_BOLD); addstr("bold"); attrset(A_NORMAL); |
138 mvprintw(22, 0, "Use F1 or `?' for help on this screen"); |
|
138 move(0, 0); 139} 140 141struct disk * 142device_slice_disk(char *disk) 143{ 144 struct disk *d; 145 char *p; --- 21 unchanged lines hidden (view full) --- 167 print_command_summary(); 168 if (msg) { 169 standout(); mvprintw(23, 0, msg); standend(); 170 beep(); 171 msg = NULL; 172 } 173 refresh(); 174 | 139 move(0, 0); 140} 141 142struct disk * 143device_slice_disk(char *disk) 144{ 145 struct disk *d; 146 char *p; --- 21 unchanged lines hidden (view full) --- 168 print_command_summary(); 169 if (msg) { 170 standout(); mvprintw(23, 0, msg); standend(); 171 beep(); 172 msg = NULL; 173 } 174 refresh(); 175 |
175 key = getch(); | 176 key = toupper(getch()); |
176 switch (key) { 177 case KEY_UP: 178 case '-': 179 if (current_chunk != 0) 180 --current_chunk; 181 break; 182 183 case KEY_DOWN: --- 14 unchanged lines hidden (view full) --- 198 break; 199 200 case KEY_F(1): 201 case '?': 202 systemDisplayFile("slice.hlp"); 203 break; 204 205 case 'B': | 177 switch (key) { 178 case KEY_UP: 179 case '-': 180 if (current_chunk != 0) 181 --current_chunk; 182 break; 183 184 case KEY_DOWN: --- 14 unchanged lines hidden (view full) --- 199 break; 200 201 case KEY_F(1): 202 case '?': 203 systemDisplayFile("slice.hlp"); 204 break; 205 206 case 'B': |
206 case 'b': | |
207 if (chunk_info[current_chunk]->type != freebsd) 208 msg = "Can only scan for bad blocks in FreeBSD partition."; 209 else 210 chunk_info[current_chunk]->flags |= CHUNK_BAD144; 211 break; 212 213 case 'C': | 207 if (chunk_info[current_chunk]->type != freebsd) 208 msg = "Can only scan for bad blocks in FreeBSD partition."; 209 else 210 chunk_info[current_chunk]->flags |= CHUNK_BAD144; 211 break; 212 213 case 'C': |
214 case 'c': | |
215 if (chunk_info[current_chunk]->type != unused) 216 msg = "Partition in use, delete it first or move to an unused one."; 217 else { 218 char *val; 219 char tmp[20]; 220 int size; 221 222 snprintf(tmp, 20, "%d", chunk_info[current_chunk]->size); --- 5 unchanged lines hidden (view full) --- 228 3, 229 chunk_info[current_chunk]->flags); 230 record_chunks(disk, d); 231 } 232 } 233 break; 234 235 case 'D': | 214 if (chunk_info[current_chunk]->type != unused) 215 msg = "Partition in use, delete it first or move to an unused one."; 216 else { 217 char *val; 218 char tmp[20]; 219 int size; 220 221 snprintf(tmp, 20, "%d", chunk_info[current_chunk]->size); --- 5 unchanged lines hidden (view full) --- 227 3, 228 chunk_info[current_chunk]->flags); 229 record_chunks(disk, d); 230 } 231 } 232 break; 233 234 case 'D': |
236 case 'd': | |
237 if (chunk_info[current_chunk]->type == unused) 238 msg = "Partition is already unused!"; 239 else { 240 Delete_Chunk(d, chunk_info[current_chunk]); 241 record_chunks(disk, d); 242 } 243 break; 244 245 case 'U': | 235 if (chunk_info[current_chunk]->type == unused) 236 msg = "Partition is already unused!"; 237 else { 238 Delete_Chunk(d, chunk_info[current_chunk]); 239 record_chunks(disk, d); 240 } 241 break; 242 243 case 'U': |
246 case 'u': | |
247 Free_Disk(d); 248 d = Open_Disk(disk); 249 record_chunks(disk, d); 250 break; 251 | 244 Free_Disk(d); 245 d = Open_Disk(disk); 246 record_chunks(disk, d); 247 break; 248 |
249 case 'W': 250 if (!msgYesNo("Are you sure you want to write this to disk?")) 251 Write_Disk(d); 252 else 253 msg = "Write not confirmed"; 254 break; 255 |
|
252 case 27: /* ESC */ 253 chunking = FALSE; 254 break; 255 256 default: 257 msg = "Invalid character typed."; 258 break; 259 } --- 47 unchanged lines hidden --- | 256 case 27: /* ESC */ 257 chunking = FALSE; 258 break; 259 260 default: 261 msg = "Invalid character typed."; 262 break; 263 } --- 47 unchanged lines hidden --- |