Deleted Added
full compact
media.c (8686) media.c (8702)
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.12 1995/05/21 15:40:50 jkh Exp $
7 * $Id: media.c,v 1.13 1995/05/21 19:28:05 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);
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;
296 msgNotify("Attempting to open %s distribution", distname);
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 = "/";
297 fd = (*mediaDevice->get)(distname);
298 return fd;
299}
300
301void
302mediaClose(void)
303{
304 if (mediaDevice->close)
305 (*mediaDevice->close)(mediaDevice);
306 mediaDevice = NULL;
307}
308
309Boolean
310mediaExtractDist(char *dir, int fd)
311{
312 int i, j, zpid, cpid, pfd[2];
313
314 if (!dir)
315 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);
316 msgNotify("Extracting into %s directory..", dir);
317 Mkdir(dir, NULL);
318 chdir(dir);
319 pipe(pfd);
320 zpid = fork();
321 if (!zpid) {
322 dup2(fd, 0); close(fd);
323 dup2(pfd[1], 1); close(pfd[1]);
324 if (DebugFD != -1)
325 dup2(DebugFD, 2);
326 else {
327 close(2);
328 open("/dev/null", O_WRONLY);
330 }
329 }
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]);
330 close(pfd[0]);
349 close(pfd[1]);
331 i = execl("/stand/gunzip", "/stand/gunzip", 0);
332 msgDebug("/stand/gunzip command returns %d status\n", i);
333 exit(i);
334 }
335 cpid = fork();
336 if (!cpid) {
337 dup2(pfd[0], 0); close(pfd[0]);
350 close(fd);
338 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);
339 close(pfd[1]);
340 if (DebugFD != -1) {
341 dup2(DebugFD, 1);
342 dup2(DebugFD, 2);
357 }
343 }
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);
344 else {
345 close(1); open("/dev/null", O_WRONLY);
346 dup2(1, 2);
363 }
347 }
364 exit(0);
348 i = execl("/stand/cpio", "/stand/cpio", "-iduvm", "-H", "tar", 0);
349 msgDebug("/stand/cpio command returns %d status\n", i);
350 exit(i);
365 }
351 }
366 else
367 i = wait(&j);
368 if (i < 0 || _WSTATUS(j))
352 close(pfd[0]);
353 close(pfd[1]);
354 close(fd);
355
356 i = waitpid(zpid, &j, 0);
357 if (i < 0 || _WSTATUS(j)) {
358 dialog_clear();
359 msgConfirm("gunzip returned error status of %d!", _WSTATUS(j));
369 return FALSE;
360 return FALSE;
361 }
362 i = waitpid(cpid, &j, 0);
363 if (i < 0 || _WSTATUS(j)) {
364 dialog_clear();
365 msgConfirm("cpio returned error status of %d!", _WSTATUS(j));
366 return FALSE;
367 }
370 return TRUE;
371}
372
373Boolean
374mediaGetType(void)
375{
376 dmenuOpenSimple(&MenuMedia);
377 return TRUE;

--- 12 unchanged lines hidden ---
368 return TRUE;
369}
370
371Boolean
372mediaGetType(void)
373{
374 dmenuOpenSimple(&MenuMedia);
375 return TRUE;

--- 12 unchanged lines hidden ---