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

Last change on this file since 1183 was 1173, checked in by Bruno Cornec, 17 years ago

merges from trunk for memory management for libmondo-mountlist.c mainly

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