source: MondoRescue/branches/3.2/mondo/src/common/libmondo-fork.c@ 3467

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