Deleted Added
full compact
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.12 1995/05/21 15:40:50 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

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

288{
289 char distname[FILENAME_MAX];
290 int fd;
291
292 if (parent)
293 snprintf(distname, FILENAME_MAX, "%s%s", parent, me);
294 else
295 snprintf(distname, FILENAME_MAX, "%s/%s", me, me);
296 if (mediaDevice->init)
297 if ((*mediaDevice->init)(mediaDevice) == FALSE)
298 return -1;
299 fd = (*mediaDevice->get)(distname);
300 return fd;
301}
302
303void
304mediaClose(void)
305{
306 if (mediaDevice->close)
307 (*mediaDevice->close)(mediaDevice);
308 mediaDevice = NULL;
309}
310
311Boolean
312mediaExtractDist(char *dir, int fd)
313{
314 int i, j, zpid, cpid, pfd[2];
315
316 if (!dir)
317 dir = "/";
318 j = fork();
319 if (!j) {
320 chdir(dir);
321 pipe(pfd);
322 zpid = fork();
323 if (!zpid) {
324 dup2(fd, 0); close(fd);
325 dup2(pfd[1], 1); close(pfd[1]);
326 close(pfd[0]);
327 i = execl("/stand/gunzip", "/stand/gunzip", 0);
328 msgDebug("/stand/gunzip command returns %d status\n", i);
329 exit(i);
330 }
331 cpid = fork();
332 if (!cpid) {
333 dup2(pfd[0], 0); close(pfd[0]);
334 close(fd);
335 close(pfd[1]);
336 if (DebugFD != -1) {
337 dup2(DebugFD, 1);
338 dup2(DebugFD, 2);
339 }
340 else {
341 close(1); open("/dev/null", O_WRONLY);
342 dup2(1, 2);
343 }
344 i = execl("/stand/cpio", "/stand/cpio", "-iduvm", "-H", "tar", 0);
345 msgDebug("/stand/cpio command returns %d status\n", i);
346 exit(i);
347 }
348 close(pfd[0]);
349 close(pfd[1]);
350 close(fd);
351
352 i = waitpid(zpid, &j, 0);
353 if (i < 0 || _WSTATUS(j)) {
354 dialog_clear();
355 msgConfirm("gunzip returned error status of %d!", _WSTATUS(j));
356 exit(1);
357 }
358 i = waitpid(cpid, &j, 0);
359 if (i < 0 || _WSTATUS(j)) {
360 dialog_clear();
361 msgConfirm("cpio returned error status of %d!", _WSTATUS(j));
362 exit(2);
363 }
364 exit(0);
365 }
366 else
367 i = wait(&j);
368 if (i < 0 || _WSTATUS(j))
369 return FALSE;
370 return TRUE;
371}
372
373Boolean
374mediaGetType(void)
375{
376 dmenuOpenSimple(&MenuMedia);
377 return TRUE;

--- 12 unchanged lines hidden ---