source: MondoRescue/branches/2.2.10/mondo/src/common/libmondo-fork.c@ 2392

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