source: MondoRescue/branches/stable/mondo/src/common/libmondo-fork.c@ 1548

Last change on this file since 1548 was 1548, checked in by Bruno Cornec, 17 years ago
  • Add the possibiilty to edit in interactive mode mtab and device.map for grub
  • Remove blkid cache files after restore to avoid problems in cloning mode
  • Fix what seems to appear a huge number of bugs in hack-fstab (illustration of 1 LOC = 1 bug :-)
  • Especially improve LABEL and UUID support.
  • Should fix #185
  • Exclude_path should be 4*MAX_STR_LEN everywhere. Fixed now.
  • Increasing that value will allow to having larger exclude paths.
  • Should solve bug #137 (and maybe #3 as well)
  • Adds support for fedora 7

(merge -r 1533:1547 $SVN_M/branches/2.2.5)

  • Property svn:keywords set to Id
File size: 18.9 KB
Line 
1/* libmondo-fork.c - subroutines for handling forking/pthreads/etc.
2 * $Id: libmondo-fork.c 1548 2007-07-23 23:39:36Z bruno $
3 */
4#include "my-stuff.h"
5#include "mr_mem.h"
6#include "mr_msg.h"
7#include "mr_str.h"
8#include "mr_gettext.h"
9
10#include "mondostructures.h"
11#include "libmondo-fork.h"
12#include "libmondo-string-EXT.h"
13#include "newt-specific-EXT.h"
14#include "libmondo-files-EXT.h"
15#include "libmondo-tools-EXT.h"
16
17/*@unused@*/
18//static char cvsid[] = "$Id: libmondo-fork.c 1548 2007-07-23 23:39:36Z bruno $";
19
20extern char *g_tmpfs_mountpt;
21extern t_bkptype g_backup_media_type;
22extern bool g_text_mode;
23extern char *MONDO_LOGFILE;
24pid_t g_buffer_pid = 0;
25
26
27/**
28 * Call a program and retrieve its last line of output.
29 * @param call The program to run.
30 * @return The last line of its output.
31 * @note The returned value points to static storage that will be overwritten with each call.
32 */
33char *call_program_and_get_last_line_of_output(char *call)
34{
35 /*@ buffers ***************************************************** */
36 static char result[512];
37 char *tmp;
38
39 /*@ pointers **************************************************** */
40 FILE *fin;
41
42 /*@ initialize data ********************************************* */
43 malloc_string(tmp);
44 result[0] = '\0';
45 tmp[0] = '\0';
46
47 /*@******************************************************************** */
48
49 assert_string_is_neither_NULL_nor_zerolength(call);
50
51 if ((fin = popen(call, "r"))) {
52 for (fgets(tmp, MAX_STR_LEN, fin); !feof(fin);
53 fgets(tmp, MAX_STR_LEN, fin)) {
54 if (strlen(tmp) > 1) {
55 strcpy(result, tmp);
56 }
57 }
58 paranoid_pclose(fin);
59 } else {
60 log_OS_error("Unable to popen call");
61 }
62 mr_strip_spaces(result);
63 mr_free(tmp);
64 return (result);
65}
66
67
68
69
70
71
72#define MONDO_POPMSG "Your PC will not retract the CD tray automatically. Please call mondoarchive with the -m (manual CD tray) flag."
73
74/**
75 * Call mkisofs to create an ISO image.
76 * @param bkpinfo The backup information structure. Fields used:
77 * - @c bkpinfo->manual_cd_tray
78 * - @c bkpinfo->backup_media_type
79 * - @c bkpinfo->please_dont_eject_when_restoring
80 * @param basic_call The call to mkisofs. May contain tokens that will be resolved to actual data. The tokens are:
81 * - @c _ISO_ will become the ISO file (@p isofile)
82 * - @c _CD#_ becomes the CD number (@p cd_no)
83 * - @c _ERR_ becomes the logfile (@p g_logfile)
84 * @param isofile Replaces @c _ISO_ in @p basic_call. Should probably be the ISO image to create (-o parameter to mkisofs).
85 * @param cd_no Replaces @c _CD#_ in @p basic_call. Should probably be the CD number.
86 * @param logstub Unused.
87 * @param what_i_am_doing The action taking place (e.g. "Making ISO #1"). Used as the title of the progress dialog.
88 * @return Exit code of @c mkisofs (0 is success, anything else indicates failure).
89 * @bug @p logstub is unused.
90 */
91int
92eval_call_to_make_ISO(struct s_bkpinfo *bkpinfo,
93 char *basic_call, char *isofile,
94 int cd_no, char *logstub, char *what_i_am_doing)
95{
96
97 /*@ int's *** */
98 int retval = 0;
99
100
101 /*@ buffers *** */
102 char *midway_call, *ultimate_call, *tmp;
103 char *p = NULL;
104 char *cd_number_str = NULL;
105 char *command = NULL;
106
107
108/*@*********** End Variables ***************************************/
109
110 mr_msg(3, "Starting");
111 assert(bkpinfo != NULL);
112 // BERLIOS: doesn't work even if the string is correct !
113 //assert_string_is_neither_NULL_nor_zerolength(basic_call);
114 assert_string_is_neither_NULL_nor_zerolength(isofile);
115 assert_string_is_neither_NULL_nor_zerolength(logstub);
116
117 midway_call = mr_malloc(1200);
118 ultimate_call = mr_malloc(1200);
119 tmp = mr_malloc(1200);
120
121 mr_asprintf(&cd_number_str, "%d", cd_no);
122 resolve_naff_tokens(midway_call, basic_call, isofile, "_ISO_");
123 resolve_naff_tokens(tmp, midway_call, cd_number_str, "_CD#_");
124 mr_free(cd_number_str);
125
126 resolve_naff_tokens(ultimate_call, tmp, MONDO_LOGFILE, "_ERR_");
127 mr_msg(4, "basic call = '%s'", basic_call);
128 mr_msg(4, "midway_call = '%s'", midway_call);
129 mr_msg(4, "tmp = '%s'", tmp);
130 mr_msg(4, "ultimate call = '%s'", ultimate_call);
131 mr_asprintf(&command, "%s >> %s", ultimate_call, MONDO_LOGFILE);
132
133 log_to_screen
134 (_("Please be patient. Do not be alarmed by on-screen inactivity."));
135 mr_msg(4, "Calling open_evalcall_form() with what_i_am_doing='%s'",
136 what_i_am_doing);
137 if (bkpinfo->manual_cd_tray) {
138 /* Find everything after a 2>> and remove it */
139 p = strstr(command, "2>>");
140 if (p) {
141 for (; *p != ' ' && *p != '\0'; p++) {
142 *p = ' ';
143 }
144 }
145#ifndef _XWIN
146 if (!g_text_mode) {
147 newtSuspend();
148 }
149#endif
150 mr_msg(1, "command = '%s'", command);
151 retval += system(command);
152 if (!g_text_mode) {
153 newtResume();
154 }
155 if (retval) {
156 mr_msg(2, "Basic call '%s' returned an error.", basic_call);
157 popup_and_OK(_("Press ENTER to continue."));
158 popup_and_OK
159 (_("mkisofs and/or cdrecord returned an error. CD was not created"));
160 }
161 }
162 /* if text mode then do the above & RETURN; if not text mode, do this... */
163 else {
164 mr_msg(3, "command = '%s'", command);
165// yes_this_is_a_goto:
166 retval =
167 run_external_binary_with_percentage_indicator_NEW
168 (what_i_am_doing, command);
169 }
170 mr_free(command);
171
172 mr_free(midway_call);
173 mr_free(ultimate_call);
174 mr_free(tmp);
175 return (retval);
176}
177
178
179/**
180 * Run a program and log its output (stdout and stderr) to the logfile.
181 * @param program The program to run. Passed to the shell, so you can use pipes etc.
182 * @param debug_level If @p g_loglevel is higher than this, do not log the output.
183 * @return The exit code of @p program (depends on the command, but 0 almost always indicates success).
184 */
185int run_program_and_log_output(char *program, int debug_level)
186{
187 /*@ buffer ****************************************************** */
188 char *callstr = NULL;
189 char *incoming = NULL;
190
191 /*@ int ********************************************************* */
192 int res = 0;
193 size_t n = 0;
194 bool log_if_failure = FALSE;
195 bool log_if_success = FALSE;
196
197 /*@ pointers *************************************************** */
198 FILE *fin = NULL;
199 char *p = NULL;
200
201 /*@ end vars *************************************************** */
202
203 assert(program != NULL);
204 if (!program[0]) {
205 mr_msg(2, "Warning - asked to run zerolength program");
206 return (1);
207 }
208
209 if (debug_level <= g_loglevel) {
210 log_if_success = TRUE;
211 log_if_failure = TRUE;
212 }
213 mr_asprintf(&callstr,
214 "%s > /tmp/mondo-run-prog-thing.tmp 2> /tmp/mondo-run-prog-thing.err",
215 program);
216 while ((p = strchr(callstr, '\r'))) {
217 *p = ' ';
218 }
219 while ((p = strchr(callstr, '\n'))) {
220 *p = ' ';
221 } /* single '=' is intentional */
222
223 res = system(callstr);
224 if (((res == 0) && log_if_success) || ((res != 0) && log_if_failure)) {
225 mr_msg(0, "running: %s", callstr);
226 mr_msg(0,
227 "--------------------------------start of output-----------------------------");
228 }
229 mr_free(callstr);
230
231 if (log_if_failure
232 &&
233 system
234 ("cat /tmp/mondo-run-prog-thing.err >> /tmp/mondo-run-prog-thing.tmp 2> /dev/null"))
235 {
236 log_OS_error("Command failed");
237 }
238 unlink("/tmp/mondo-run-prog-thing.err");
239 fin = fopen("/tmp/mondo-run-prog-thing.tmp", "r");
240 if (fin) {
241 for (mr_getline(&incoming, &n, fin); !feof(fin); mr_getline(&incoming, &n, fin)) {
242 /* Suppress % so they are not interpreted in mr_msg */
243 while ((p = strchr(incoming, '%'))) {
244 *p = ' ';
245 }
246 mr_strip_spaces(incoming);
247 if ((res == 0 && log_if_success)
248 || (res != 0 && log_if_failure)) {
249 mr_msg(0, incoming);
250 }
251 }
252 mr_free(incoming);
253 paranoid_fclose(fin);
254 }
255 unlink("/tmp/mondo-run-prog-thing.tmp");
256 if ((res == 0 && log_if_success) || (res != 0 && log_if_failure)) {
257 mr_msg(0,
258 "--------------------------------end of output------------------------------");
259 if (res) {
260 mr_msg(0, "...ran with res=%d", res);
261 } else {
262 mr_msg(0, "...ran just fine. :-)");
263 }
264 }
265 return (res);
266}
267
268
269/**
270 * Run a program and log its output to the screen.
271 * @param basic_call The program to run.
272 * @param what_i_am_doing The title of the evalcall form.
273 * @return The return value of the command (varies, but 0 almost always means success).
274 * @see run_program_and_log_output
275 * @see log_to_screen
276 */
277int run_program_and_log_to_screen(char *basic_call, char *what_i_am_doing)
278{
279 /*@ int ******************************************************** */
280 int retval = 0;
281 int res = 0;
282 int i;
283
284 /*@ pointers **************************************************** */
285 FILE *fin;
286
287 /*@ buffers **************************************************** */
288 char *tmp = NULL;
289 char *command = NULL;
290 char *lockfile = NULL;
291
292 /*@ end vars *************************************************** */
293
294 assert_string_is_neither_NULL_nor_zerolength(basic_call);
295
296 mr_asprintf(&lockfile, "/tmp/mojo-jojo.blah.XXXXXX");
297 mkstemp(lockfile);
298 mr_asprintf(&command,
299 "echo hi > %s ; %s >> %s 2>> %s; res=$?; sleep 1; rm -f %s; exit $res",
300 lockfile, basic_call, MONDO_LOGFILE, MONDO_LOGFILE, lockfile);
301 open_evalcall_form(what_i_am_doing);
302 mr_asprintf(&tmp, "Executing %s", basic_call);
303 mr_msg(2, tmp);
304 mr_free(tmp);
305
306 if (!(fin = popen(command, "r"))) {
307 log_OS_error("Unable to popen-in command");
308 mr_asprintf(&tmp, _("Failed utterly to call '%s'"), command);
309 log_to_screen(tmp);
310 mr_free(tmp);
311 mr_free(lockfile);
312 mr_free(command);
313 return (1);
314 }
315 mr_free(command);
316
317 if (!does_file_exist(lockfile)) {
318 log_to_screen(_("Waiting for external binary to start"));
319 for (i = 0; i < 60 && !does_file_exist(lockfile); sleep(1), i++) {
320 mr_msg(3, "Waiting for lockfile %s to exist", lockfile);
321 }
322 }
323 /* This works on Newt, and it gives quicker updates. */
324 for (; does_file_exist(lockfile); sleep(1)) {
325 log_file_end_to_screen(MONDO_LOGFILE, "");
326 update_evalcall_form(1);
327 }
328 /* Evaluate the status returned by pclose to get the exit code of the called program. */
329 errno = 0;
330 res = pclose(fin);
331 /* Log actual pclose errors. */
332 if (errno) {
333 mr_msg(5, "pclose err: %d", errno);
334 }
335 /* Check if we have a valid status. If we do, extract the called program's exit code. */
336 /* If we don't, highlight this fact by returning -1. */
337 if (WIFEXITED(res)) {
338 retval = WEXITSTATUS(res);
339 } else {
340 retval = -1;
341 }
342 close_evalcall_form();
343 unlink(lockfile);
344 mr_free(lockfile);
345
346 return (retval);
347}
348
349
350/**
351 * Apparently used. @bug This has a purpose, but what?
352 */
353#define PIMP_START_SZ "STARTSTARTSTART9ff3kff9a82gv34r7fghbkaBBC2T231hc81h42vws8"
354#define PIMP_END_SZ "ENDENDEND0xBBC10xBBC2T231hc81h42vws89ff3kff9a82gv34r7fghbka"
355
356
357
358
359int copy_from_src_to_dest(FILE * f_orig, FILE * f_archived, char direction)
360{
361// if dir=='w' then copy from orig to archived
362// if dir=='r' then copy from archived to orig
363 char *tmp = NULL;
364 char *tmp1 = NULL;
365 char *buf = NULL;
366 long int bytes_to_be_read, bytes_read_in, bytes_written_out =
367 0, bufcap, subsliceno = 0;
368 int retval = 0;
369 FILE *fin = NULL;
370 FILE *fout = NULL;
371 FILE *ftmp = NULL;
372
373 mr_msg(5, "Opening.");
374 malloc_string(tmp);
375 tmp[0] = '\0';
376 bufcap = 256L * 1024L;
377 buf = mr_malloc(bufcap);
378
379 if (direction == 'w') {
380 fin = f_orig;
381 fout = f_archived;
382 mr_asprintf(&tmp1, "%-64s", PIMP_START_SZ);
383 if (fwrite(tmp1, 1, 64, fout) != 64) {
384 fatal_error("Can't write the introductory block");
385 }
386 mr_free(tmp1);
387
388 while (1) {
389 bytes_to_be_read = bytes_read_in = fread(buf, 1, bufcap, fin);
390 if (bytes_read_in == 0) {
391 break;
392 }
393 mr_asprintf(&tmp1, "%-64ld", bytes_read_in);
394 if (fwrite(tmp1, 1, 64, fout) != 64) {
395 fatal_error("Cannot write introductory block");
396 }
397 mr_free(tmp1);
398
399 mr_msg(7,
400 "subslice #%ld --- I have read %ld of %ld bytes in from f_orig",
401 subsliceno, bytes_read_in, bytes_to_be_read);
402 bytes_written_out += fwrite(buf, 1, bytes_read_in, fout);
403 mr_asprintf(&tmp1, "%-64ld", subsliceno);
404 if (fwrite(tmp1, 1, 64, fout) != 64) {
405 fatal_error("Cannot write post-thingy block");
406 }
407 mr_free(tmp1);
408
409 mr_msg(7, "Subslice #%d written OK", subsliceno);
410 subsliceno++;
411 }
412 sprintf(tmp, "%-64ld", 0L);
413 if (fwrite(tmp, 1, 64L, fout) != 64L) {
414 fatal_error("Cannot write final introductory block");
415 }
416 } else {
417 fin = f_archived;
418 fout = f_orig;
419 tmp = mr_malloc(64L);
420 if (fread(tmp, 1, 64L, fin) != 64L) {
421 fatal_error("Cannot read the introductory block");
422 }
423 mr_msg(5, "tmp is %s", tmp);
424 if (!strstr(tmp, PIMP_START_SZ)) {
425 fatal_error("Can't find intro blk");
426 }
427 if (fread(tmp, 1, 64L, fin) != 64L) {
428 fatal_error("Cannot read introductory blk");
429 }
430 bytes_to_be_read = atol(tmp);
431 while (bytes_to_be_read > 0) {
432 mr_msg(7, "subslice#%ld, bytes=%ld", subsliceno,
433 bytes_to_be_read);
434 bytes_read_in = fread(buf, 1, bytes_to_be_read, fin);
435 if (bytes_read_in != bytes_to_be_read) {
436 fatal_error
437 ("Danger, WIll Robinson. Failed to read whole subvol from archives.");
438 }
439 bytes_written_out += fwrite(buf, 1, bytes_read_in, fout);
440 if (fread(tmp, 1, 64L, fin) != 64L) {
441 fatal_error("Cannot read post-thingy block");
442 }
443 if (atol(tmp) != subsliceno) {
444 mr_msg(1, "Wanted subslice %ld but got %ld ('%s')",
445 subsliceno, atol(tmp), tmp);
446 }
447 mr_msg(7, "Subslice #%ld read OK", subsliceno);
448 subsliceno++;
449 if (fread(tmp, 1, 64L, fin) != 64L) {
450 fatal_error("Cannot read introductory block");
451 }
452 bytes_to_be_read = atol(tmp);
453 }
454 }
455
456// mr_msg(4, "Written %ld of %ld bytes", bytes_written_out, bytes_read_in);
457
458 if (direction == 'w') {
459 mr_asprintf(&tmp1, "%-64s", PIMP_END_SZ);
460 if (fwrite(tmp1, 1, 64L, fout) != 64L) {
461 fatal_error("Can't write the final block");
462 }
463 mr_free(tmp1);
464 } else {
465 mr_msg(1, "tmpA is %s", tmp);
466 if (!strstr(tmp, PIMP_END_SZ)) {
467 if (fread(tmp, 1, 64L, fin) != 64L) {
468 fatal_error("Can't read the final block");
469 }
470 mr_msg(5, "tmpB is %s", tmp);
471 if (!strstr(tmp, PIMP_END_SZ)) {
472 ftmp = fopen("/tmp/out.leftover", "w");
473 bytes_read_in = fread(tmp, 1, 64L, fin);
474 mr_msg(1, "bytes_read_in = %ld", bytes_read_in);
475// if (bytes_read_in!=128+64) { fatal_error("Can't read the terminating block"); }
476 fwrite(tmp, 1, bytes_read_in, ftmp);
477 sprintf(tmp, "I am here - %lld", (long long)ftello(fin));
478// mr_msg(0, tmp);
479 fread(tmp, 1, 512, fin);
480 mr_msg(0, "tmp = '%s'", tmp);
481 fwrite(tmp, 1, 512, ftmp);
482 fclose(ftmp);
483 fatal_error("Missing terminating block");
484 }
485 }
486 }
487
488 mr_free(buf);
489 mr_free(tmp);
490 mr_msg(3, "Successfully copied %ld bytes", bytes_written_out);
491 return (retval);
492}
493
494/**
495 * Feed @p input_device through ntfsclone to @p output_fname.
496 * @param input_device The device to image.
497 * @param output_fname The file to write.
498 * @return 0 for success, nonzero for failure.
499 */
500int feed_into_ntfsprog(char *input_device, char *output_fname)
501{
502// BACKUP
503 int res = -1;
504 char *command = NULL;
505
506 if (!does_file_exist(input_device)) {
507 fatal_error("input device does not exist");
508 }
509 if ( !find_home_of_exe("ntfsclone")) {
510 fatal_error("ntfsclone not found");
511 }
512 mr_asprintf(&command, "ntfsclone --force --save-image --overwrite %s %s", output_fname, input_device);
513 res = run_program_and_log_output(command, 5);
514 mr_free(command);
515
516 unlink(output_fname);
517 return (res);
518}
519
520
521int run_external_binary_with_percentage_indicator_OLD(char *tt, char *cmd)
522{
523
524 int res = 0;
525 int percentage = 0;
526 int maxpc = 0;
527 int pcno = 0;
528 int last_pcno = 0;
529
530 char *command = NULL;
531 char *tempfile;
532 char *title;
533 /*@ pointers ********************************************************** */
534 FILE *pin;
535
536 malloc_string(title);
537 malloc_string(tempfile);
538 assert_string_is_neither_NULL_nor_zerolength(cmd);
539 assert_string_is_neither_NULL_nor_zerolength(title);
540
541 strcpy(title, tt);
542 strcpy(tempfile,
543 call_program_and_get_last_line_of_output
544 ("mktemp -q /tmp/mondo.XXXXXXXX"));
545 mr_asprintf(&command, "%s >> %s 2>> %s; rm -f %s", cmd, tempfile, tempfile,
546 tempfile);
547 mr_msg(3, command);
548 open_evalcall_form(title);
549 if (!(pin = popen(command, "r"))) {
550 log_OS_error("fmt err");
551 mr_free(command);
552 return (1);
553 }
554 mr_free(command);
555
556 maxpc = 100;
557// OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD
558 for (sleep(1); does_file_exist(tempfile); sleep(1)) {
559 pcno = grab_percentage_from_last_line_of_file(MONDO_LOGFILE);
560 if (pcno < 0 || pcno > 100) {
561 mr_msg(5, "Weird pc#");
562 continue;
563 }
564 percentage = pcno * 100 / maxpc;
565 if (pcno <= 5 && last_pcno > 40) {
566 close_evalcall_form();
567 strcpy(title, "Verifying...");
568 open_evalcall_form(title);
569 }
570 last_pcno = pcno;
571 update_evalcall_form(percentage);
572 }
573// OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD OLD
574 close_evalcall_form();
575 if (pclose(pin)) {
576 res++;
577 log_OS_error("Unable to pclose");
578 }
579 unlink(tempfile);
580 mr_free(tempfile);
581 mr_free(title);
582 return (res);
583}
584
585
586void *run_prog_in_bkgd_then_exit(void *info)
587{
588 char *sz_command;
589 static int res = 4444;
590
591 res = 999;
592 sz_command = (char *) info;
593 mr_msg(4, "sz_command = '%s'", sz_command);
594 res = system(sz_command);
595 if (res > 256 && res != 4444) {
596 res = res / 256;
597 }
598 mr_msg(4, "child res = %d", res);
599 sz_command[0] = '\0';
600 pthread_exit((void *) (&res));
601}
602
603
604int run_external_binary_with_percentage_indicator_NEW(char *tt, char *cmd)
605{
606
607 /*@ int *************************************************************** */
608 int res = 0;
609 int percentage = 0;
610 int maxpc = 100;
611 int pcno = 0;
612 int last_pcno = 0;
613 int counter = 0;
614
615 /*@ buffers *********************************************************** */
616 char *command = NULL;
617 char *title;
618 /*@ pointers ********************************************************** */
619 static int chldres = 0;
620 int *pchild_result;
621 pthread_t childthread;
622
623 pchild_result = &chldres;
624 assert_string_is_neither_NULL_nor_zerolength(cmd);
625 assert_string_is_neither_NULL_nor_zerolength(tt);
626 *pchild_result = 999;
627
628 malloc_string(title);
629 strcpy(title, tt);
630 mr_asprintf(&command, "%s 2>> %s", cmd, MONDO_LOGFILE);
631 mr_msg(3, "command = '%s'", command);
632 if ((res =
633 pthread_create(&childthread, NULL, run_prog_in_bkgd_then_exit,
634 (void *) command))) {
635 fatal_error("Unable to create an archival thread");
636 }
637
638 mr_msg(8, "Parent running");
639 open_evalcall_form(title);
640 for (sleep(1); command[0] != '\0'; sleep(1)) {
641 pcno = grab_percentage_from_last_line_of_file(MONDO_LOGFILE);
642 if (pcno <= 0 || pcno > 100) {
643 mr_msg(8, "Weird pc#");
644 continue;
645 }
646 percentage = pcno * 100 / maxpc;
647 if (pcno <= 5 && last_pcno >= 40) {
648 close_evalcall_form();
649 strcpy(title, "Verifying...");
650 open_evalcall_form(title);
651 }
652 if (counter++ >= 5) {
653 counter = 0;
654 log_file_end_to_screen(MONDO_LOGFILE, "");
655 }
656 last_pcno = pcno;
657 update_evalcall_form(percentage);
658 }
659 mr_free(command);
660
661 log_file_end_to_screen(MONDO_LOGFILE, "");
662 close_evalcall_form();
663 pthread_join(childthread, (void *) (&pchild_result));
664 if (pchild_result) {
665 res = *pchild_result;
666 } else {
667 res = 666;
668 }
669 mr_msg(3, "Parent res = %d", res);
670 mr_free(title);
671 return (res);
672}
673
674
675/**
676 * Feed @p input_fifo through ntfsclone (restore) to @p output_device.
677 * @param input_fifo The ntfsclone file to read.
678 * @param output_device Where to put the output.
679 * @return The return value of ntfsclone (0 for success).
680 */
681int feed_outfrom_ntfsprog(char *output_device, char *input_fifo)
682{
683// RESTORE
684 int res = -1;
685 char *command = NULL;
686
687 if ( !find_home_of_exe("ntfsclone")) {
688 fatal_error("ntfsclone not found");
689 }
690 mr_asprintf(&command, "ntfsclone --force --restore-image --overwrite %s %s", output_device, input_fifo);
691 res = run_program_and_log_output(command, 5);
692 mr_free(command);
693 return (res);
694}
Note: See TracBrowser for help on using the repository browser.