media.c (8637) | media.c (8641) |
---|---|
1/* 2 * The new sysinstall program. 3 * 4 * This is probably the last attempt in the `sysinstall' line, the next 5 * generation being slated to essentially a complete rewrite. 6 * | 1/* 2 * The new sysinstall program. 3 * 4 * This is probably the last attempt in the `sysinstall' line, the next 5 * generation being slated to essentially a complete rewrite. 6 * |
7 * $Id: media.c,v 1.7 1995/05/20 00:13:11 jkh Exp $ | 7 * $Id: media.c,v 1.8 1995/05/20 03:49:09 gpalmer 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 --- 23 unchanged lines hidden (view full) --- 39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 40 * SUCH DAMAGE. 41 * 42 */ 43 44#include <stdio.h> 45#include "sysinstall.h" 46 | 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 --- 23 unchanged lines hidden (view full) --- 39 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 40 * SUCH DAMAGE. 41 * 42 */ 43 44#include <stdio.h> 45#include "sysinstall.h" 46 |
47static int 48genericHook(char *str, DeviceType type) 49{ 50 Device **devs; 51 52 /* Clip garbage off the ends */ 53 string_prune(str); 54 str = string_skipwhite(str); 55 if (!*str) 56 return 0; 57 devs = deviceFind(str, type); 58 if (devs) 59 mediaDevice = devs[0]; 60 return devs ? 1 : 0; 61} 62 63static int 64cdromHook(char *str) 65{ 66 return genericHook(str, DEVICE_TYPE_CDROM); 67} 68 |
|
47/* 48 * Return 1 if we successfully found and set the installation type to 49 * be a CD. 50 */ 51int 52mediaSetCDROM(char *str) 53{ 54 Device **devs; 55 int cnt; 56 | 69/* 70 * Return 1 if we successfully found and set the installation type to 71 * be a CD. 72 */ 73int 74mediaSetCDROM(char *str) 75{ 76 Device **devs; 77 int cnt; 78 |
57 if (OnCDROM == TRUE) | 79 if (OnCDROM == TRUE) { 80 /* XXX point mediaDevice at something meaningful here - perhaps a static device structure */ |
58 return 1; | 81 return 1; |
82 } |
|
59 else { 60 devs = deviceFind(NULL, DEVICE_TYPE_CDROM); 61 cnt = deviceCount(devs); 62 if (!cnt) { 63 msgConfirm("No CDROM devices found! Please check that your system's\nconfiguration is correct and that the CDROM drive is of a supported\ntype. For more information, consult the hardware guide\nin the Doc menu."); 64 return 0; 65 } 66 else if (cnt > 1) { | 83 else { 84 devs = deviceFind(NULL, DEVICE_TYPE_CDROM); 85 cnt = deviceCount(devs); 86 if (!cnt) { 87 msgConfirm("No CDROM devices found! Please check that your system's\nconfiguration is correct and that the CDROM drive is of a supported\ntype. For more information, consult the hardware guide\nin the Doc menu."); 88 return 0; 89 } 90 else if (cnt > 1) { |
67 /* put up a menu */ | 91 DMenu *menu; 92 93 menu = deviceCreateMenu(&MenuMediaCDROM, DEVICE_TYPE_CDROM, cdromHook); 94 if (!menu) 95 msgFatal("Unable to create CDROM menu! Something is seriously wrong."); 96 dmenuOpenSimple(menu); 97 free(menu); |
68 } | 98 } |
69 else { | 99 else |
70 mediaDevice = devs[0]; | 100 mediaDevice = devs[0]; |
71 } | |
72 } | 101 } |
73 return 0; | 102 return mediaDevice ? 1 : 0; |
74} 75 | 103} 104 |
105static int 106floppyHook(char *str) 107{ 108 return genericHook(str, DEVICE_TYPE_FLOPPY); 109} 110 |
|
76/* 77 * Return 1 if we successfully found and set the installation type to 78 * be a floppy 79 */ 80int 81mediaSetFloppy(char *str) 82{ | 111/* 112 * Return 1 if we successfully found and set the installation type to 113 * be a floppy 114 */ 115int 116mediaSetFloppy(char *str) 117{ |
83 dmenuOpenSimple(&MenuMediaFloppy); 84 return 0; | 118 Device **devs; 119 int cnt; 120 121 devs = deviceFind(NULL, DEVICE_TYPE_FLOPPY); 122 cnt = deviceCount(devs); 123 if (!cnt) { 124 msgConfirm("No floppy devices found! Please check that your system's\nconfiguration is correct. For more information, consult the hardware guide\nin the Doc menu."); 125 return 0; 126 } 127 else if (cnt > 1) { 128 DMenu *menu; 129 130 menu = deviceCreateMenu(&MenuMediaFloppy, DEVICE_TYPE_FLOPPY, floppyHook); 131 if (!menu) 132 msgFatal("Unable to create Floppy menu! Something is seriously wrong."); 133 dmenuOpenSimple(menu); 134 free(menu); 135 } 136 else 137 mediaDevice = devs[0]; 138 return mediaDevice ? 1 : 0; |
85} 86 87/* 88 * Return 1 if we successfully found and set the installation type to 89 * be a DOS partition. 90 */ 91int 92mediaSetDOS(char *str) 93{ 94 Device **devs; | 139} 140 141/* 142 * Return 1 if we successfully found and set the installation type to 143 * be a DOS partition. 144 */ 145int 146mediaSetDOS(char *str) 147{ 148 Device **devs; |
149 Disk *d; 150 Chunk *c1; 151 int i; |
|
95 96 devs = deviceFind(NULL, DEVICE_TYPE_DISK); 97 if (!devs) 98 msgConfirm("No disk devices found!"); | 152 153 devs = deviceFind(NULL, DEVICE_TYPE_DISK); 154 if (!devs) 155 msgConfirm("No disk devices found!"); |
99 return 0; | 156 for (i = 0; devs[i]; i++) { 157 if (!devs[i]->enabled) 158 continue; 159 d = (Disk *)devs[i]->private; 160 /* Now try to find a DOS partition */ 161 for (c1 = d->chunks->part; c1; c1 = c1->next) { 162 if (c1->type == fat) { 163 /* Got one! */ 164 mediaDevice = deviceRegister(c1->name, c1->name, c1->name, DEVICE_TYPE_DISK, TRUE, 165 mediaInitDOS, mediaGetDOS, mediaCloseDOS, NULL); 166 msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name); 167 break; 168 } 169 } 170 } 171 if (!mediaDevice) 172 msgConfirm("No DOS primary partitions found! This installation method is unavailable"); 173 return mediaDevice ? 1 : 0; |
100} 101 102/* 103 * Return 1 if we successfully found and set the installation type to 104 * be a tape drive. 105 */ 106int 107mediaSetTape(char *str) --- 45 unchanged lines hidden (view full) --- 153mediaExtractDist(FILE *fp) 154{ 155 return TRUE; 156} 157 158Boolean 159mediaGetType(void) 160{ | 174} 175 176/* 177 * Return 1 if we successfully found and set the installation type to 178 * be a tape drive. 179 */ 180int 181mediaSetTape(char *str) --- 45 unchanged lines hidden (view full) --- 227mediaExtractDist(FILE *fp) 228{ 229 return TRUE; 230} 231 232Boolean 233mediaGetType(void) 234{ |
161 char *cp; 162 | |
163 dmenuOpenSimple(&MenuMedia); | 235 dmenuOpenSimple(&MenuMedia); |
164#if 0 165 cp = getenv(MEDIA_TYPE); 166 if (!cp) 167 return FALSE; 168#endif | |
169 return TRUE; 170} 171 172/* Return TRUE if all the media variables are set up correctly */ 173Boolean 174mediaVerify(void) 175{ 176 if (!mediaDevice) { 177 msgConfirm("Media type not set! Please select a media type\nfrom the Installation menu before proceeding."); 178 return FALSE; 179 } 180 return TRUE; 181} 182 183void 184mediaClose(void) 185{ 186} | 236 return TRUE; 237} 238 239/* Return TRUE if all the media variables are set up correctly */ 240Boolean 241mediaVerify(void) 242{ 243 if (!mediaDevice) { 244 msgConfirm("Media type not set! Please select a media type\nfrom the Installation menu before proceeding."); 245 return FALSE; 246 } 247 return TRUE; 248} 249 250void 251mediaClose(void) 252{ 253} |