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

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