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

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

Fix the latest pb with mr_rs_conf and compilation works

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