Deleted Added
full compact
media.c (8803) media.c (8837)
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.20 1995/05/27 23:39:31 phk Exp $
7 * $Id: media.c,v 1.21 1995/05/28 03:04:58 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

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

159/*
160 * Return 1 if we successfully found and set the installation type to
161 * be a DOS partition.
162 */
163int
164mediaSetDOS(char *str)
165{
166 Device **devs;
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

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

159/*
160 * Return 1 if we successfully found and set the installation type to
161 * be a DOS partition.
162 */
163int
164mediaSetDOS(char *str)
165{
166 Device **devs;
167 Disk *d;
168 Chunk *c1;
169 int i, cnt;
167 int cnt;
170
171 devs = deviceFind(NULL, DEVICE_TYPE_DOS);
172 cnt = deviceCount(devs);
168
169 devs = deviceFind(NULL, DEVICE_TYPE_DOS);
170 cnt = deviceCount(devs);
173 if (cnt > 1) {
171 if (!cnt) {
172 msgConfirm("No DOS primary partitions found! This installation method is unavailable");
173 return 0;
174 }
175 else if (cnt > 1) {
174 DMenu *menu;
175
176 menu = deviceCreateMenu(&MenuMediaDOS, DEVICE_TYPE_DOS, DOSHook);
177 if (!menu)
178 msgFatal("Unable to create DOS menu! Something is seriously wrong.");
179 dmenuOpenSimple(menu);
180 free(menu);
181 }
176 DMenu *menu;
177
178 menu = deviceCreateMenu(&MenuMediaDOS, DEVICE_TYPE_DOS, DOSHook);
179 if (!menu)
180 msgFatal("Unable to create DOS menu! Something is seriously wrong.");
181 dmenuOpenSimple(menu);
182 free(menu);
183 }
182 else if (cnt) {
184 else
183 mediaDevice = devs[0];
185 mediaDevice = devs[0];
184 return 1;
185 }
186 else {
187 devs = deviceFind(NULL, DEVICE_TYPE_DISK);
188 if (!devs) {
189 msgConfirm("No disk devices found!");
190 return 0;
191 }
192 /* Now go chewing through looking for a DOS FAT partition */
193 for (i = 0; devs[i]; i++) {
194 d = (Disk *)devs[i]->private;
195 /* Now try to find a DOS partition */
196 for (c1 = d->chunks->part; c1; c1 = c1->next) {
197 if (c1->type == fat) {
198 /* Got one! */
199 mediaDevice = deviceRegister(c1->name, c1->name, c1->name, DEVICE_TYPE_DOS, TRUE,
200 mediaInitDOS, mediaGetDOS, NULL, mediaShutdownDOS, NULL);
201 mediaDevice->private = c1;
202 msgDebug("Found a DOS partition %s on drive %s\n", c1->name, d->name);
203 break;
204 }
205 }
206 }
207 }
208 if (!mediaDevice)
209 msgConfirm("No DOS primary partitions found! This installation method is unavailable");
210 return mediaDevice ? 1 : 0;
211}
212
213static int
214tapeHook(char *str)
215{
216 return genericHook(str, DEVICE_TYPE_TAPE);
217}

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

275 ftpDevice.get = mediaGetFTP;
276 ftpDevice.close = mediaCloseFTP;
277 ftpDevice.shutdown = mediaShutdownFTP;
278 ftpDevice.private = mediaDevice;
279 mediaDevice = &ftpDevice;
280 return 1;
281}
282
186 return mediaDevice ? 1 : 0;
187}
188
189static int
190tapeHook(char *str)
191{
192 return genericHook(str, DEVICE_TYPE_TAPE);
193}

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

251 ftpDevice.get = mediaGetFTP;
252 ftpDevice.close = mediaCloseFTP;
253 ftpDevice.shutdown = mediaShutdownFTP;
254 ftpDevice.private = mediaDevice;
255 mediaDevice = &ftpDevice;
256 return 1;
257}
258
283/*
284 * Return 0 if we successfully found and set the installation type to
285 * be some sort of mounted filesystem (it's also mounted at this point)
286 */
287int
259int
288mediaSetFS(char *str)
260mediaSetUFS(char *str)
289{
261{
290 return 0;
262 static Device ufsDevice;
263 char *val;
264
265 val = msgGetInput(NULL, "Enter a fully qualified pathname for the directory\ncontaining the FreeBSD distribtion files:");
266 if (!val)
267 return 0;
268 strcpy(ufsDevice.name, "ufs");
269 ufsDevice.type = DEVICE_TYPE_UFS;
270 ufsDevice.get = mediaGetUFS;
271 ufsDevice.private = strdup(val);
272 mediaDevice = &ufsDevice;
273 return 1;
291}
292
274}
275
276int
277mediaSetNFS(char *str)
278{
279 static Device nfsDevice;
280 char *val;
281
282 val = msgGetInput(NULL, "Please enter the full NFS file specification for the remote\nhost and directory containing the FreeBSD distribution files.\nThis should be in the format: hostname:/some/freebsd/dir");
283 if (!val)
284 return 0;
285 strcpy(nfsDevice.name, "nfs");
286 nfsDevice.type = DEVICE_TYPE_NFS;
287 nfsDevice.init = mediaInitNFS;
288 nfsDevice.get = mediaGetNFS;
289 nfsDevice.shutdown = mediaShutdownNFS;
290 nfsDevice.private = strdup(val);
291 mediaDevice = &nfsDevice;
292 return 1;
293}
294
293Boolean
295Boolean
294mediaExtractDistBegin(char *distname, char *dir, int *fd, int *zpid, int *cpid)
296mediaExtractDistBegin(char *dir, int *fd, int *zpid, int *cpid)
295{
296 int i, pfd[2],qfd[2];
297
298 if (!dir)
299 dir = "/";
297{
298 int i, pfd[2],qfd[2];
299
300 if (!dir)
301 dir = "/";
300 msgWeHaveOutput("Extracting %s into %s directory..", distname, dir);
301
302 Mkdir(dir, NULL);
303 chdir(dir);
304 pipe(pfd);
305 pipe(qfd);
306 *zpid = fork();
307 if (!*zpid) {
308 dup2(qfd[0], 0); close(qfd[0]);
309 dup2(pfd[1], 1); close(pfd[1]);
310 if (DebugFD != -1)
311 dup2(DebugFD, 2);
312 else {
313 close(2);
314 open("/dev/null", O_WRONLY);
315 }
316 close(qfd[1]);
317 close(pfd[0]);
318 i = execl("/stand/gunzip", "/stand/gunzip", 0);
302 Mkdir(dir, NULL);
303 chdir(dir);
304 pipe(pfd);
305 pipe(qfd);
306 *zpid = fork();
307 if (!*zpid) {
308 dup2(qfd[0], 0); close(qfd[0]);
309 dup2(pfd[1], 1); close(pfd[1]);
310 if (DebugFD != -1)
311 dup2(DebugFD, 2);
312 else {
313 close(2);
314 open("/dev/null", O_WRONLY);
315 }
316 close(qfd[1]);
317 close(pfd[0]);
318 i = execl("/stand/gunzip", "/stand/gunzip", 0);
319 msgDebug("/stand/gunzip command returns %d status\n", i);
319 if (isDebug())
320 msgDebug("/stand/gunzip command returns %d status\n", i);
320 exit(i);
321 }
322 *fd = qfd[1];
323 close(qfd[0]);
324 *cpid = fork();
325 if (!*cpid) {
326 dup2(pfd[0], 0); close(pfd[0]);
327 close(pfd[1]);
328 close(qfd[1]);
329 if (DebugFD != -1) {
330 dup2(DebugFD, 1);
331 dup2(DebugFD, 2);
332 }
333 else {
334 close(1); open("/dev/null", O_WRONLY);
335 dup2(1, 2);
336 }
337 i = execl("/stand/cpio", "/stand/cpio", "-iduVm", "-H", "tar", 0);
321 exit(i);
322 }
323 *fd = qfd[1];
324 close(qfd[0]);
325 *cpid = fork();
326 if (!*cpid) {
327 dup2(pfd[0], 0); close(pfd[0]);
328 close(pfd[1]);
329 close(qfd[1]);
330 if (DebugFD != -1) {
331 dup2(DebugFD, 1);
332 dup2(DebugFD, 2);
333 }
334 else {
335 close(1); open("/dev/null", O_WRONLY);
336 dup2(1, 2);
337 }
338 i = execl("/stand/cpio", "/stand/cpio", "-iduVm", "-H", "tar", 0);
338 msgDebug("/stand/cpio command returns %d status\n", i);
339 if (isDebug())
340 msgDebug("/stand/cpio command returns %d status\n", i);
339 exit(i);
340 }
341 close(pfd[0]);
342 close(pfd[1]);
343 return TRUE;
344}
345
346Boolean
347mediaExtractDistEnd(int zpid, int cpid)
348{
349 int i,j;
350
351 i = waitpid(zpid, &j, 0);
352 if (i < 0) { /* Don't check status - gunzip seems to return a bogus one! */
353 dialog_clear();
341 exit(i);
342 }
343 close(pfd[0]);
344 close(pfd[1]);
345 return TRUE;
346}
347
348Boolean
349mediaExtractDistEnd(int zpid, int cpid)
350{
351 int i,j;
352
353 i = waitpid(zpid, &j, 0);
354 if (i < 0) { /* Don't check status - gunzip seems to return a bogus one! */
355 dialog_clear();
354 msgDebug("wait for gunzip returned status of %d!\n", i);
356 if (isDebug())
357 msgDebug("wait for gunzip returned status of %d!\n", i);
355 return FALSE;
356 }
357 i = waitpid(cpid, &j, 0);
358 if (i < 0 || WEXITSTATUS(j)) {
359 dialog_clear();
358 return FALSE;
359 }
360 i = waitpid(cpid, &j, 0);
361 if (i < 0 || WEXITSTATUS(j)) {
362 dialog_clear();
360 msgDebug("cpio returned error status of %d!\n", WEXITSTATUS(j));
363 if (isDebug())
364 msgDebug("cpio returned error status of %d!\n", WEXITSTATUS(j));
361 return FALSE;
362 }
363 return TRUE;
364}
365
366
367Boolean
365 return FALSE;
366 }
367 return TRUE;
368}
369
370
371Boolean
368mediaExtractDist(char *distname, char *dir, int fd)
372mediaExtractDist(char *dir, int fd)
369{
370 int i, j, zpid, cpid, pfd[2];
371
372 if (!dir)
373 dir = "/";
373{
374 int i, j, zpid, cpid, pfd[2];
375
376 if (!dir)
377 dir = "/";
374 msgWeHaveOutput("Extracting %s into %s directory..", distname, dir);
375
376 Mkdir(dir, NULL);
377 chdir(dir);
378 pipe(pfd);
379 zpid = fork();
380 if (!zpid) {
381 dup2(fd, 0); close(fd);
382 dup2(pfd[1], 1); close(pfd[1]);
383 if (DebugFD != -1)
384 dup2(DebugFD, 2);
385 else {
386 close(2);
387 open("/dev/null", O_WRONLY);
388 }
389 close(pfd[0]);
390 i = execl("/stand/gunzip", "/stand/gunzip", 0);
378
379 Mkdir(dir, NULL);
380 chdir(dir);
381 pipe(pfd);
382 zpid = fork();
383 if (!zpid) {
384 dup2(fd, 0); close(fd);
385 dup2(pfd[1], 1); close(pfd[1]);
386 if (DebugFD != -1)
387 dup2(DebugFD, 2);
388 else {
389 close(2);
390 open("/dev/null", O_WRONLY);
391 }
392 close(pfd[0]);
393 i = execl("/stand/gunzip", "/stand/gunzip", 0);
391 msgDebug("/stand/gunzip command returns %d status\n", i);
394 if (isDebug())
395 msgDebug("/stand/gunzip command returns %d status\n", i);
392 exit(i);
393 }
394 cpid = fork();
395 if (!cpid) {
396 dup2(pfd[0], 0); close(pfd[0]);
397 close(fd);
398 close(pfd[1]);
399 if (DebugFD != -1) {
400 dup2(DebugFD, 1);
401 dup2(DebugFD, 2);
402 }
403 else {
404 close(1); open("/dev/null", O_WRONLY);
405 dup2(1, 2);
406 }
407 i = execl("/stand/cpio", "/stand/cpio", "-iduVm", "-H", "tar", 0);
396 exit(i);
397 }
398 cpid = fork();
399 if (!cpid) {
400 dup2(pfd[0], 0); close(pfd[0]);
401 close(fd);
402 close(pfd[1]);
403 if (DebugFD != -1) {
404 dup2(DebugFD, 1);
405 dup2(DebugFD, 2);
406 }
407 else {
408 close(1); open("/dev/null", O_WRONLY);
409 dup2(1, 2);
410 }
411 i = execl("/stand/cpio", "/stand/cpio", "-iduVm", "-H", "tar", 0);
408 msgDebug("/stand/cpio command returns %d status\n", i);
412 if (isDebug())
413 msgDebug("/stand/cpio command returns %d status\n", i);
409 exit(i);
410 }
411 close(pfd[0]);
412 close(pfd[1]);
413
414 i = waitpid(zpid, &j, 0);
415 if (i < 0) { /* Don't check status - gunzip seems to return a bogus one! */
416 dialog_clear();
414 exit(i);
415 }
416 close(pfd[0]);
417 close(pfd[1]);
418
419 i = waitpid(zpid, &j, 0);
420 if (i < 0) { /* Don't check status - gunzip seems to return a bogus one! */
421 dialog_clear();
417 msgDebug("wait for gunzip returned status of %d!\n", i);
422 if (isDebug())
423 msgDebug("wait for gunzip returned status of %d!\n", i);
418 return FALSE;
419 }
420 i = waitpid(cpid, &j, 0);
421 if (i < 0 || WEXITSTATUS(j)) {
422 dialog_clear();
424 return FALSE;
425 }
426 i = waitpid(cpid, &j, 0);
427 if (i < 0 || WEXITSTATUS(j)) {
428 dialog_clear();
423 msgDebug("cpio returned error status of %d!\n", WEXITSTATUS(j));
429 if (isDebug())
430 msgDebug("cpio returned error status of %d!\n", WEXITSTATUS(j));
424 return FALSE;
425 }
426 return TRUE;
427}
428
429Boolean
430mediaGetType(void)
431{

--- 14 unchanged lines hidden ---
431 return FALSE;
432 }
433 return TRUE;
434}
435
436Boolean
437mediaGetType(void)
438{

--- 14 unchanged lines hidden ---