Changeset 300 in MondoRescue for trunk/mondo/mondo


Ignore:
Timestamp:
Jan 11, 2006, 2:20:38 PM (18 years ago)
Author:
bcornec
Message:

merge -r295:299 $SVN_M/branches/2.06

Location:
trunk/mondo/mondo
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/mondo/mondo/common/libmondo-archive-EXT.h

    r262 r300  
    2727extern int slice_up_file_etc(struct s_bkpinfo *bkpinfo,
    2828                             char *biggie_filename,
    29                              char *partimagehack_fifo,
     29                             char *ntfsprog_fifo,
    3030                             long biggie_file_number,
    3131                             long noof_biggie_files,
    32                              bool use_partimagehack);
     32                             bool use_ntfsprog);
    3333extern int verify_data(struct s_bkpinfo *bkpinfo);
    3434extern void wipe_archives(char *d);
  • trunk/mondo/mondo/common/libmondo-archive.c

    r262 r300  
    19681968    char *bigfile_fname = NULL;
    19691969    char *sz_devfile;
    1970     char *partimagehack_fifo = NULL;
     1970    char *ntfsprog_fifo = NULL;
    19711971    /*@ long *********************************************** */
    19721972    long biggie_file_number = 0;
     
    19811981    FILE *ftmp = NULL;
    19821982    bool delete_when_done;
    1983     bool use_partimagehack;
     1983    bool use_ntfsprog;
    19841984    /*@ long long ****************************************** */
    19851985    long long biggie_fsize;
     
    20152015    for (getline(&bigfile_fname, &n, fin); !feof(fin);
    20162016         getline(&bigfile_fname, &n, fin), biggie_file_number++) {
    2017         use_partimagehack = FALSE;
     2017        use_ntfsprog = FALSE;
    20182018        if (bigfile_fname[strlen(bigfile_fname) - 1] < 32) {
    20192019            bigfile_fname[strlen(bigfile_fname) - 1] = '\0';
     
    20292029            delete_when_done = TRUE;
    20302030        } else {
    2031             // Call partimagehack if it's a /dev entry (i.e. a partition to be imaged)
     2031            // Call ntfsclone (formerly partimagehack) if it's a /dev entry (i.e. a partition to be imaged)
    20322032            log_msg(2, "bigfile_fname = %s", bigfile_fname);
    2033             use_partimagehack = FALSE;
     2033            use_ntfsprog = FALSE;
    20342034            if (!strncmp(bigfile_fname, "/dev/", 5)
    20352035                && is_dev_an_NTFS_dev(bigfile_fname)) {
    2036                 use_partimagehack = TRUE;
     2036                use_ntfsprog = TRUE;
    20372037                log_msg(2,
    2038                         "Calling partimagehack in background because %s is an NTFS partition",
     2038                        "Calling ntfsclone in background because %s is an NTFS partition",
    20392039                        bigfile_fname);
    20402040                asprintf(&sz_devfile, "/tmp/%d.%d.000",
     
    20422042                         (int) (random() % 32768));
    20432043                mkfifo(sz_devfile, 0x770);
    2044                 partimagehack_fifo = sz_devfile;
     2044                ntfsprog_fifo = sz_devfile;
    20452045                switch (pid = fork()) {
    20462046                case -1:
     
    20482048                case 0:
    20492049                    log_msg(2,
    2050                             "CHILD - fip - calling feed_into_partimage(%s, %s)",
     2050                            "CHILD - fip - calling feed_into_ntfsprog(%s, %s)",
    20512051                            bigfile_fname, sz_devfile);
    2052                     res = feed_into_partimage(bigfile_fname, sz_devfile);
     2052                    res = feed_into_ntfsprog(bigfile_fname, sz_devfile);
    20532053                    exit(res);
    20542054                    break;
    20552055                default:
    20562056                    log_msg(2,
    2057                             "feed_into_partimage() called in background --- pid=%ld",
     2057                            "feed_into_ntfsprog() called in background --- pid=%ld",
    20582058                            (long int) (pid));
    20592059
     
    20632063            // Otherwise, use good old 'dd' and 'bzip2'
    20642064            else {
    2065                 partimagehack_fifo = NULL;
     2065                ntfsprog_fifo = NULL;
    20662066            }
    20672067
     
    20722072            if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    20732073                write_header_block_to_stream(biggie_fsize, bigfile_fname,
    2074                                              use_partimagehack ?
     2074                                             use_ntfsprog ?
    20752075                                             BLK_START_A_PIHBIGGIE :
    20762076                                             BLK_START_A_NORMBIGGIE);
    20772077            }
    2078             res = slice_up_file_etc(bkpinfo, bigfile_fname,
    2079                                     partimagehack_fifo, biggie_file_number,
    2080                                     noof_biggie_files, use_partimagehack);
     2078            res =
     2079                slice_up_file_etc(bkpinfo, bigfile_fname,
     2080                                  ntfsprog_fifo, biggie_file_number,
     2081                                  noof_biggie_files, use_ntfsprog);
    20812082            if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    20822083                tmp = calc_checksum_of_file(bigfile_fname);
     
    29962997 *
    29972998 * @param biggie_filename The file to chop up.
    2998  * @param partimagehack_fifo The FIFO to partimagehack if this is an imagedev, NULL otherwise.
     2999 * @param ntfsprog_fifo The FIFO to ntfsclone if this is an imagedev, NULL otherwise.
    29993000 * @param biggie_file_number The sequence number of this biggie file (starting from 0).
    30003001 * @param noof_biggie_files The number of biggie files there are total.
     
    30053006int
    30063007slice_up_file_etc(struct s_bkpinfo *bkpinfo, char *biggie_filename,
    3007                   char *partimagehack_fifo, long biggie_file_number,
    3008                   long noof_biggie_files, bool use_partimagehack)
     3008                  char *ntfsprog_fifo, long biggie_file_number,
     3009                  long noof_biggie_files, bool use_ntfsprog)
    30093010{
    30103011
     
    30493050
    30503051    biggiestruct.for_backward_compatibility = '\n';
    3051     biggiestruct.use_partimagehack = use_partimagehack;
     3052    biggiestruct.use_ntfsprog = use_ntfsprog;
    30523053    optimal_set_size = bkpinfo->optimal_set_size;
    30533054    if (is_this_file_compressed(biggie_filename)
     
    30643065        fatal_error("bkpinfo->optimal_set_size is insanely small");
    30653066    }
    3066     if (partimagehack_fifo) {
    3067         file_to_openin = partimagehack_fifo;
     3067    if (ntfsprog_fifo) {
     3068        file_to_openin = ntfsprog_fifo;
    30683069        asprintf(&checksum_line, "IGNORE");
    30693070        log_msg(2,
    30703071                "Not calculating checksum for %s: it would take too long",
    30713072                biggie_filename);
    3072         totallength = get_phys_size_of_drive(biggie_filename)*1024*1024LL;
     3073        if ( !find_home_of_exe("ntfsresize")) {
     3074            fatal_error("ntfsresize not found");
     3075        }
     3076        sprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename);
     3077        log_it("command = %s", command);
     3078        strcpy (tmp, call_program_and_get_last_line_of_output(command));
     3079        log_it("res of it = %s", tmp);
     3080        totallength = atoll(tmp);
    30733081    } else {
    30743082        file_to_openin = biggie_filename;
  • trunk/mondo/mondo/common/libmondo-archive.h

    r262 r300  
    2929void set_bit_N_of_array(char *array, int N, bool true_or_false);
    3030int slice_up_file_etc(struct s_bkpinfo *bkpinfo, char *biggie_filename,
    31                       char *partimagehack_fifo,
     31                      char *ntfsprog_fifo,
    3232                      long biggie_file_number, long noof_biggie_files,
    33                       bool use_partimagehack);
     33                      bool use_ntfsprog);
    3434int verify_data(struct s_bkpinfo *bkpinfo);
    3535void wipe_archives(char *d);
  • trunk/mondo/mondo/common/libmondo-files.c

    r236 r300  
    711711    char *biggielist;
    712712    char *comment;
     713    char *tmp;
     714    char *command;
    713715
    714716    /*@ long ******************************************************** */
     
    722724    /*@ end vars *************************************************** */
    723725
     726    malloc_string(tmp);
     727    malloc_string(command);
    724728    log_it("Calculating size of all biggiefiles (in total)");
    725729    asprintf(&biggielist, "%s/biggielist.txt", bkpinfo->tmpdir);
     
    736740            }
    737741            if (0 == strncmp(fname, "/dev/", 5)) {
    738                 file_len_K = get_phys_size_of_drive(fname) * 1024L;
     742                if (is_dev_an_NTFS_dev(fname)) {
     743                    if ( !find_home_of_exe("ntfsresize")) {
     744                        fatal_error("ntfsresize not found");
     745                    }
     746                    sprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", fname);
     747                    log_it("command = %s", command);
     748                    strcpy (tmp, call_program_and_get_last_line_of_output(command));
     749                    log_it("res of it = %s", tmp);
     750                    file_len_K = atoll(tmp) / 1024L;
     751                } else {
     752                    file_len_K = get_phys_size_of_drive(fname) * 1024L;
     753                }
    739754            } else {
    740755                file_len_K = (long) (length_of_file(fname) / 1024);
     
    761776    paranoid_fclose(fin);
    762777    log_it("Finished calculating total size of all biggiefiles");
     778    paranoid_free(tmp);
     779    paranoid_free(command);
    763780    return (scratchL);
    764781}
  • trunk/mondo/mondo/common/libmondo-fork-EXT.h

    r59 r300  
    1414                                                             char *cmd);
    1515extern int copy_from_src_to_dest(FILE *, FILE *, char);
    16 extern int feed_into_partimage(char *input_device, char *output_fname);
    17 extern int feed_outfrom_partimage(char *output_device, char *input_fifo);
     16extern int feed_into_ntfsprog(char *input_device, char *output_fname);
     17extern int feed_outfrom_ntfsprog(char *output_device, char *input_fifo);
  • trunk/mondo/mondo/common/libmondo-fork.c

    r171 r300  
    1 /* $Id$
    2   subroutines for handling forking/pthreads/etc.
     1/* libmondo-fork.c
     2   $Id$
     3
     4- subroutines for handling forking/pthreads/etc.
     5
     6
     701/20/2006
     8- replaced partimagehack with ntfsclone
     9
     1006/20/2004
     11- create fifo /var/log/partimagehack-debug.log and empty it
     12  to keep ramdisk from filling up
     13
     1404/13/2004
     15- >= should be <= g_loglevel
     16
     1711/15/2003
     18- changed a few []s to char*s
     19 
     2010/12
     21- rewrote partimagehack handling (multiple fifos, chunks, etc.)
     22
     2310/11
     24- partimagehack now has debug level of N (set in my-stuff.h)
     25
     2610/08
     27- call to partimagehack when restoring will now log errors to /var/log/....log
     28
     2910/06
     30- cleaned up logging a bit
     31
     3209/30
     33- line 735 - missing char* cmd in sprintf()
     34
     3509/28
     36- added run_external_binary_with_percentage_indicator()
     37- rewritten eval_call_to_make_ISO()
     38
     3909/18
     40- call mkstemp instead of mktemp
     41
     4209/13
     43- major NTFS hackage
     44
     4509/12
     46- paranoid_system("rm -f /tmp/ *PARTIMAGE*") before calling partimagehack
     47
     4809/11
     49- forward-ported unbroken feed_*_partimage() subroutines
     50  from early August 2003
     51
     5209/08
     53- detect & use partimagehack if it exists
     54
     5509/05
     56- finally finished partimagehack hack :)
     57
     5807/04
     59- added subroutines to wrap around partimagehack
     60
     6104/27
     62- don't echo (...res=%d...) at end of log_it()
     63  unnecessarily
     64- replace newtFinished() and newtInit() with
     65  newtSuspend() and newtResume()
     66
     6704/24
     68- added some assert()'s and log_OS_error()'s
     69
     7004/09
     71- cleaned up run_program_and_log_output()
     72
     7304/07
     74- cleaned up code a bit
     75- let run_program_and_log_output() accept -1 (only log if _no error_)
     76
     7701/02/2003
     78- in eval_call_to_make_ISO(), append output to MONDO_LOGFILE
     79  instead of a temporary stderr text file
     80
     8112/10
     82- patch by Heiko Schlittermann to handle % chars in issue.net
     83
     8411/18
     85- if mkisofs in eval_call_to_make_ISO() returns an error then return it,
     86  whether ISO was created or not
     87
     8810/30
     89- if mkisofs in eval_call_to_make_ISO() returns an error then find out if
     90  the output (ISO) file has been created; if it has then return 0 anyway
     91
     9208/01 - 09/30
     93- run_program_and_log_output() now takes boolean operator to specify
     94  whether it will log its activities in the event of _success_
     95- system() now includes 2>/dev/null
     96- enlarged some tmp[]'s
     97- added run_program_and_log_to_screen() and run_program_and_log_output()
     98
     9907/24
     100- created
    3101*/
    4102
     
    370468
    371469/**
    372  * Thread callback to run a command (partimage) in the background.
    373  * @param xfb A transfer block of @c char, containing:
    374  * - xfb:[0] A marker, should be set to 2. Decremented to 1 while the command is running and 0 when it's finished.
    375  * - xfb:[1] The command's return value, if xfb:[0] is 0.
    376  * - xfb+2:  A <tt>NULL</tt>-terminated string containing the command to be run.
    377  * @return NULL to pthread_join.
    378  */
    379 void *call_partimage_in_bkgd(void *xfb)
    380 {
    381     char *transfer_block;
    382     int retval = 0;
    383 
    384     g_buffer_pid = getpid();
    385     unlink("/tmp/null");
    386     log_msg(1, "starting");
    387     transfer_block = (char *) xfb;
    388     transfer_block[0]--;        // should now be 1
    389     retval = system(transfer_block + 2);
    390     if (retval) {
    391         log_OS_error("partimage returned an error");
    392     }
    393     transfer_block[1] = retval;
    394     transfer_block[0]--;        // should now be 0
    395     g_buffer_pid = 0;
    396     log_msg(1, "returning");
    397     pthread_exit(NULL);
    398 }
    399 
    400 
    401 /**
    402  * File to touch if we want partimage to wait for us.
    403  */
    404 #define PAUSE_PARTIMAGE_FNAME "/tmp/PAUSE-PARTIMAGE-FOR-MONDO"
    405 
    406 /**
    407470 * Apparently used. @bug This has a purpose, but what?
    408471 */
     
    410473#define PIMP_END_SZ "ENDENDEND0xBBC10xBBC2T231hc81h42vws89ff3kff9a82gv34r7fghbka"
    411474
    412 /**
    413  * Marker to start the next subvolume for Partimage.
    414  */
    415 #define NEXT_SUBVOL_PLEASE "I-grew-up-on-the-crime-side,-the-New-York-Times-side,-where-staying-alive-was-no-jive"
    416 
    417 /**
    418  * Marker to end the partimage file.
    419  */
    420 #define NO_MORE_SUBVOLS "On-second-hand,momma-bounced-on-old-man,-and-so-we-moved-to-Shaolin-Land."
     475
     476
    421477
    422478int copy_from_src_to_dest(FILE * f_orig, FILE * f_archived, char direction)
     
    559615}
    560616
    561 
    562617/**
    563  * Call partimage from @p input_device to @p output_fname.
    564  * @param input_device The device to read.
    565  * @param output_fname The file to write.
    566  * @return 0 for success, nonzero for failure.
    567  */
    568 int dynamically_create_pipes_and_copy_from_them_to_output_file(char
    569                                                                *input_device, char
    570                                                                *output_fname)
    571 {
    572     char *curr_fifo;
    573     char *prev_fifo = NULL;
    574     char *next_fifo;
    575     char *command;
    576     char *sz_call_to_partimage;
    577     int fifo_number = 0;
    578     struct stat buf;
    579     pthread_t partimage_thread;
    580     int res = 0;
    581     char *tmpstub;
    582     FILE *fout;
    583     FILE *fin;
    584     char *tmp;
    585 
    586     log_msg(1, "g_tmpfs_mountpt = %s", g_tmpfs_mountpt);
    587     if (g_tmpfs_mountpt && g_tmpfs_mountpt[0]
    588         && does_file_exist(g_tmpfs_mountpt)) {
    589         asprintf(&tmpstub, g_tmpfs_mountpt);
    590     } else {
    591         asprintf(&tmpstub, "/tmp");
    592     }
    593     paranoid_system("rm -f /tmp/*PARTIMAGE*");
    594     asprintf(&command, "rm -Rf %s/pih-fifo-*", tmpstub);
    595     paranoid_system(command);
    596     paranoid_free(command);
    597 
    598     asprintf(&tmp, "%s/pih-fifo-%ld", tmpstub, (long int) random());
    599     paranoid_free(tmpstub);
    600     tmpstub = tmp;
    601     paranoid_free(tmp);
    602 
    603     mkfifo(tmpstub, S_IRWXU | S_IRWXG); // never used, though...
    604     asprintf(&curr_fifo, "%s.%03d", tmpstub, fifo_number);
    605     asprintf(&next_fifo, "%s.%03d", tmpstub, fifo_number + 1);
    606     mkfifo(curr_fifo, S_IRWXU | S_IRWXG);
    607     mkfifo(next_fifo, S_IRWXU | S_IRWXG);   // make sure _next_ fifo already exists before we call partimage
    608     asprintf(&sz_call_to_partimage,
    609             "%c%cpartimagehack " PARTIMAGE_PARAMS
    610             " save %s %s > /tmp/stdout 2> /tmp/stderr", 2, 0, input_device,
    611             tmpstub);
    612     log_msg(5, "curr_fifo   = %s", curr_fifo);
    613     log_msg(5, "next_fifo   = %s", next_fifo);
    614     log_msg(5, "sz_call_to_partimage call is '%s'",
    615             sz_call_to_partimage + 2);
    616     if (!lstat(output_fname, &buf) && S_ISREG(buf.st_mode)) {
    617         log_msg(5, "Deleting %s", output_fname);
    618         unlink(output_fname);
    619     }
    620     if (!(fout = fopen(output_fname, "w"))) {
    621         fatal_error("Unable to openout to output_fname");
    622     }
    623     res =
    624         pthread_create(&partimage_thread, NULL, call_partimage_in_bkgd,
    625                        (void *) sz_call_to_partimage);
    626     if (res) {
    627         fatal_error("Failed to create thread to call partimage");
    628     }
    629     log_msg(1, "Running fore/back at same time");
    630     log_to_screen("Working with partimagehack...");
    631     while (sz_call_to_partimage[0] > 0) {
    632         asprintf(&tmp, "%s\n", NEXT_SUBVOL_PLEASE);
    633         if (fwrite(tmp, 1, 128, fout) != 128) {
    634             fatal_error("Cannot write interim block");
    635         }
    636         paranoid_free(tmp);
    637 
    638         log_msg(5, "fifo_number=%d", fifo_number);
    639         log_msg(4, "Cat'ting %s", curr_fifo);
    640         if (!(fin = fopen(curr_fifo, "r"))) {
    641             fatal_error("Unable to openin from fifo");
    642         }
    643         if (prev_fifo !=  NULL) {
    644             log_msg(5, "Deleting %s", prev_fifo);
    645             unlink(prev_fifo);      // just in case
    646             paranoid_free(prev_fifo);
    647         }
    648         copy_from_src_to_dest(fin, fout, 'w');
    649         paranoid_fclose(fin);
    650         fifo_number++;
    651 
    652         prev_fifo = curr_fifo;
    653         curr_fifo = next_fifo;
    654         log_msg(5, "Creating %s", next_fifo);
    655         asprintf(&next_fifo, "%s.%03d", tmpstub, fifo_number + 1);
    656         mkfifo(next_fifo, S_IRWXU | S_IRWXG);   // make sure _next_ fifo exists before we cat this one
    657         system("sync");
    658         sleep(5);
    659     }
    660     asprintf(&tmp, "%s\n", NO_MORE_SUBVOLS);
    661     if (fwrite(tmp, 1, 128, fout) != 128) {
    662         fatal_error("Cannot write interim block");
    663     }
    664     if (fwrite(tmp, 1, 128, fout) != 128) {
    665         fatal_error("Cannot write interim block");
    666     }
    667     if (fwrite(tmp, 1, 128, fout) != 128) {
    668         fatal_error("Cannot write interim block");
    669     }
    670     if (fwrite(tmp, 1, 128, fout) != 128) {
    671         fatal_error("Cannot write interim block");
    672     }
    673     paranoid_free(tmp);
    674     paranoid_fclose(fout);
    675     log_to_screen("Cleaning up after partimagehack...");
    676     log_msg(3, "Final fifo_number=%d", fifo_number);
    677     paranoid_system("sync");
    678     unlink(next_fifo);
    679     paranoid_free(next_fifo);
    680 
    681     unlink(curr_fifo);
    682     paranoid_free(curr_fifo);
    683 
    684     unlink(prev_fifo);
    685     paranoid_free(prev_fifo);
    686 
    687     log_to_screen("Finished cleaning up.");
    688 
    689 //  if (!lstat(sz_wait_for_this_file, &statbuf))
    690 //    { log_msg(3, "WARNING! %s was not processed.", sz_wait_for_this_file); }
    691     log_msg(2, "Waiting for pthread_join() to join.");
    692     pthread_join(partimage_thread, NULL);
    693     res = sz_call_to_partimage[1];
    694     paranoid_free(sz_call_to_partimage);
    695     log_msg(2, "pthread_join() joined OK.");
    696     log_msg(1, "Partimagehack(save) returned %d", res);
    697     unlink(tmpstub);
    698     paranoid_free(tmpstub);
    699 
    700     return (res);
    701 }
    702 
    703 
    704 /**
    705  * Feed @p input_device through partimage to @p output_fname.
     618 * Feed @p input_device through ntfsclone to @p output_fname.
    706619 * @param input_device The device to image.
    707620 * @param output_fname The file to write.
    708621 * @return 0 for success, nonzero for failure.
    709622 */
    710 int feed_into_partimage(char *input_device, char *output_fname)
     623int feed_into_ntfsprog(char *input_device, char *output_fname)
    711624{
    712625// BACKUP
    713     int res;
     626    int res = -1;
     627    char*command;
    714628
    715629    if (!does_file_exist(input_device)) {
    716630        fatal_error("input device does not exist");
    717631    }
    718     if (!find_home_of_exe("partimagehack")) {
    719         fatal_error("partimagehack not found");
    720     }
    721     res =
    722         dynamically_create_pipes_and_copy_from_them_to_output_file
    723         (input_device, output_fname);
     632    if ( !find_home_of_exe("ntfsclone")) {
     633        fatal_error("ntfsclone not found");
     634    }
     635    malloc_string(command);
     636    sprintf(command, "ntfsclone --force --save-image --overwrite %s %s", output_fname, input_device);
     637    res = run_program_and_log_output(command, 5);
     638    paranoid_free(command);
    724639    return (res);
    725640}
     
    871786}
    872787
    873 #define PIH_LOG "/var/log/partimage-debug.log"
    874788
    875789/**
    876  * Feed @p input_fifo through partimage (restore) to @p output_device.
    877  * @param input_fifo The partimage file to read.
     790 * Feed @p input_fifo through ntfsclone (restore) to @p output_device.
     791 * @param input_fifo The ntfsclone file to read.
    878792 * @param output_device Where to put the output.
    879  * @return The return value of partimagehack (0 for success).
    880  * @bug Probably unnecessary, as the partimage is just a sparse file. We could use @c dd to restore it.
     793 * @return The return value of ntfsclone (0 for success).
    881794 */
    882 int feed_outfrom_partimage(char *output_device, char *input_fifo)
     795int feed_outfrom_ntfsprog(char *output_device, char *input_fifo)
    883796{
    884797// RESTORE
    885     char *tmp;
    886     char *stuff;
    887     char *sz_call_to_partimage;
    888     pthread_t partimage_thread;
    889     int res;
    890     char *curr_fifo;
    891     char *prev_fifo = NULL;
    892     char *oldest_fifo = NULL;
    893     char *next_fifo;
    894     char *afternxt_fifo;
    895     int fifo_number = 0;
    896     char *tmpstub;
    897     FILE *fin;
    898     FILE *fout;
    899 
    900     log_msg(1, "output_device=%s", output_device);
    901     log_msg(1, "input_fifo=%s", input_fifo);
    902     asprintf(&tmpstub, "/tmp");
    903 
    904     log_msg(1, "tmpstub was %s", tmpstub);
    905     asprintf(&stuff, tmpstub);
    906     paranoid_free(tmpstub);
    907 
    908     asprintf(&tmpstub, "%s/pih-fifo-%ld", stuff, (long int) random());
    909     paranoid_free(stuff);
    910 
    911     log_msg(1, "tmpstub is now %s", tmpstub);
    912     unlink("/tmp/PARTIMAGEHACK-POSITION");
    913     unlink(PAUSE_PARTIMAGE_FNAME);
    914     paranoid_system("rm -f /tmp/*PARTIMAGE*");
    915     asprintf(&curr_fifo, "%s.%03d", tmpstub, fifo_number);
    916     asprintf(&next_fifo, "%s.%03d", tmpstub, fifo_number + 1);
    917     asprintf(&afternxt_fifo, "%s.%03d", tmpstub, fifo_number + 2);
    918     mkfifo(PIH_LOG, S_IRWXU | S_IRWXG);
    919     mkfifo(curr_fifo, S_IRWXU | S_IRWXG);
    920     mkfifo(next_fifo, S_IRWXU | S_IRWXG);   // make sure _next_ fifo already exists before we call partimage
    921     mkfifo(afternxt_fifo, S_IRWXU | S_IRWXG);
    922     system("cat " PIH_LOG " > /dev/null &");
    923     log_msg(3, "curr_fifo   = %s", curr_fifo);
    924     log_msg(3, "next_fifo   = %s", next_fifo);
    925     if (!does_file_exist(input_fifo)) {
    926         fatal_error("input fifo does not exist");
    927     }
    928     if (!(fin = fopen(input_fifo, "r"))) {
    929         fatal_error("Unable to openin from input_fifo");
    930     }
    931     if (!find_home_of_exe("partimagehack")) {
    932         fatal_error("partimagehack not found");
    933     }
    934     asprintf(&sz_call_to_partimage,
    935             "%c%cpartimagehack " PARTIMAGE_PARAMS
    936             " restore %s %s > /dev/null 2>> %s", 2, 0, output_device, curr_fifo,
    937             MONDO_LOGFILE);
    938     log_msg(1, "output_device = %s", output_device);
    939     log_msg(1, "curr_fifo = %s", curr_fifo);
    940     log_msg(1, "sz_call_to_partimage+2 = %s", sz_call_to_partimage + 2);
    941     res =
    942         pthread_create(&partimage_thread, NULL, call_partimage_in_bkgd,
    943                        (void *) sz_call_to_partimage);
    944     if (res) {
    945         fatal_error("Failed to create thread to call partimage");
    946     }
    947     log_msg(1, "Running fore/back at same time");
    948     log_msg(2, " Trying to openin %s", input_fifo);
    949     if (!does_file_exist(input_fifo)) {
    950         log_msg(2, "Warning - %s does not exist", input_fifo);
    951     }
    952     while (!does_file_exist("/tmp/PARTIMAGEHACK-POSITION")) {
    953         log_msg(6, "Waiting for partimagehack (restore) to start");
    954         sleep(1);
    955     }
    956 
    957     if (!(tmp = malloc(128))) {
    958         fatal_error("Failed to malloc() tmp");
    959     }
    960     while (sz_call_to_partimage[0] > 0) {
    961         if (fread(tmp, 1, 128, fin) != 128) {
    962             fatal_error("Cannot read introductory block");
    963         }
    964         if (strstr(tmp, NEXT_SUBVOL_PLEASE)) {
    965             log_msg(2, "Great. Next subvol coming up.");
    966         } else if (strstr(tmp, NO_MORE_SUBVOLS)) {
    967             log_msg(2, "Great. That was the last subvol.");
    968             break;
    969         } else {
    970             log_msg(2, "WTF is this? '%s'", tmp);
    971             fatal_error("Unknown interim block");
    972         }
    973         if (feof(fin)) {
    974             log_msg(1, "Eof(fin) detected. Breaking.");
    975             break;
    976         }
    977         log_msg(3, "Processing subvol %d", fifo_number);
    978         log_msg(5, "fifo_number=%d", fifo_number);
    979         if (!(fout = fopen(curr_fifo, "w"))) {
    980             fatal_error("Cannot openout to curr_fifo");
    981         }
    982         copy_from_src_to_dest(fout, fin, 'r');
    983         paranoid_fclose(fout);
    984         fifo_number++;
    985         if (oldest_fifo != NULL) {
    986             log_msg(6, "Deleting %s", oldest_fifo);
    987             unlink(oldest_fifo);    // just in case
    988             paranoid_free(oldest_fifo);
    989         }
    990         oldest_fifo = prev_fifo;
    991         prev_fifo = curr_fifo;
    992         curr_fifo = next_fifo;
    993         next_fifo = afternxt_fifo;
    994         asprintf(&afternxt_fifo, "%s.%03d", tmpstub, fifo_number + 2);
    995         log_msg(6, "Creating %s", afternxt_fifo);
    996         mkfifo(afternxt_fifo, S_IRWXU | S_IRWXG);   // make sure _next_ fifo already exists before we access current fifo
    997         fflush(fin);
    998 //      system("sync");
    999         usleep(1000L * 100L);
    1000     }
    1001     paranoid_free(tmp);
    1002     paranoid_free(tmpstub);
    1003 
    1004     paranoid_fclose(fin);
    1005     paranoid_system("sync");
    1006     log_msg(1, "Partimagehack has finished. Great. Fin-closing.");
    1007     log_msg(1, "Waiting for pthread_join");
    1008     pthread_join(partimage_thread, NULL);
    1009     res = sz_call_to_partimage[1];
    1010     paranoid_free(sz_call_to_partimage);
    1011 
    1012     log_msg(1, "Yay. Partimagehack (restore) returned %d", res);
    1013     unlink(prev_fifo);
    1014     paranoid_free(prev_fifo);
    1015 
    1016     unlink(curr_fifo);
    1017     paranoid_free(curr_fifo);
    1018 
    1019     unlink(next_fifo);
    1020     paranoid_free(next_fifo);
    1021 
    1022     unlink(afternxt_fifo);
    1023     paranoid_free(afternxt_fifo);
    1024 
    1025     unlink(PIH_LOG);
    1026     /* BERLIOS : pas de unlink(oldest_fifo) ??? */
    1027     paranoid_free(oldest_fifo);
    1028 
     798    int res = -1;
     799    char *command;
     800
     801    if ( !find_home_of_exe("ntfsclone")) {
     802        fatal_error("ntfsclone not found");
     803    }
     804    asprintf(&command, "ntfsclone --force --restore-image --overwrite %s %s", output_device, input_fifo);
     805    res = run_program_and_log_output(command, 5);
     806    paranoid_free(command);
    1029807    return (res);
    1030808}
  • trunk/mondo/mondo/common/libmondo-fork.h

    r59 r300  
    1515int run_external_binary_with_percentage_indicator_NEW(char *tt, char *cmd);
    1616int copy_from_src_to_dest(FILE *, FILE *, char);
    17 int feed_into_partimage(char *input_device, char *output_fname);
    18 int feed_outfrom_partimage(char *output_device, char *input_fifo);
     17int feed_into_ntfsprog(char *input_device, char *output_fname);
     18int feed_outfrom_ntfsprog(char *output_device, char *input_fifo);
  • trunk/mondo/mondo/common/libmondo-verify.c

    r274 r300  
    339339                if (res && !strncmp(biggiestruct.filename, " /dev/", 5)) {
    340340                    log_msg(3,
    341                             "Ignoring differences between %s and live filesystem because it's a device and therefore the archives are stored via partimagehack, not dd.",
     341                            "Ignoring differences between %s and live filesystem because it's a device and therefore the archives are stored via ntfsclone, not dd.",
    342342                            biggiestruct.filename);
    343343                    log_msg(3,
  • trunk/mondo/mondo/common/mondostructures.h

    r171 r300  
    342342   *
    343343   * This is useful for backing up NTFS partitions.
    344    * @c partimage is used to back up only the used sectors, so the space tradeoff is not bad.
     344   * @c ntfsclone is used to back up only the used sectors, so the space tradeoff is not bad.
    345345   * However, several caveats apply to such a partition:
    346346   * - It must not be mounted during the backup
    347    * - It must be in a format that partimage knows how to handle
     347   * - It must be in a format that ntfsclone knows how to handle, i.e. NTFS
    348348   * - It cannot be verified during the verify or compare phase
    349349   * - It may not be resized or selectively restored at restore-time (all or nothing)
     
    661661     */
    662662    struct stat properties;
    663     bool use_partimagehack;
     663    bool use_ntfsprog;
    664664};
    665665
  • trunk/mondo/mondo/common/my-stuff.h

    r238 r300  
    151151#define BLK_STOP_BIGGIEFILES    39  ///< Marker block: stop the biggiefile section.
    152152#define BLK_START_A_NORMBIGGIE  40  ///< Marker block: start a normal biggiefile.
    153 #define BLK_START_A_PIHBIGGIE   41  ///< Marker block: start a partimagehack'd biggiefile
     153#define BLK_START_A_PIHBIGGIE   41  ///< Marker block: start a ntfsprog'd biggiefile
    154154#define BLK_START_EXTENDED_ATTRIBUTES 45    ///< Marker block: start xattr/acl info
    155155#define BLK_STOP_EXTENDED_ATTRIBUTES 46 ///< Marker block: stop xattr/acl info
     
    389389#define DEFAULT_DEBUG_LEVEL 4   ///< By default, don't log messages with a loglevel higher than this.
    390390
    391 #define SZ_PARTIMAGE_VOLSIZE "1048576"  // was 4096
    392 #define PARTIMAGE_PARAMS "-z0 -V" SZ_PARTIMAGE_VOLSIZE " -o -b -d -g1"
     391#define SZ_NTFSPROG_VOLSIZE "1048576"   // was 4096
     392#define NTFSPROG_PARAMS "-z0 -V" SZ_NTFSPROG_VOLSIZE " -o -b -d -g1"
    393393
    394394#define MNT_CDROM "/mnt/cdrom"
  • trunk/mondo/mondo/common/newt-specific.c

    r219 r300  
    281281        kill_anything_like_this("/mondo/do-not");
    282282        kill_anything_like_this("tmp.mondo");
    283         kill_anything_like_this("partimagehack");
     283        kill_anything_like_this("ntfsclone");
    284284        sync();
    285285        asprintf(&tmp, "umount %s", g_tmpfs_mountpt);
  • trunk/mondo/mondo/mondoarchive/main.c

    r262 r300  
    157157
    158158    diffs = 0;
    159     unlink("/var/log/partimagehack-debug.log");
    160159    printf("Initializing...\n");
    161160    if (!(bkpinfo = malloc(sizeof(struct s_bkpinfo)))) {
  • trunk/mondo/mondo/mondoarchive/mondo-cli.c

    r292 r300  
    572572        asprintf(&tmp, flag_val['x']);
    573573        bkpinfo->image_devs = tmp;
    574         if (run_program_and_log_output("which partimagehack", 2)) {
    575             fatal_error("Please install partimagehack RPM/tarball.");
     574        if (run_program_and_log_output("which ntfsclone", 2)) {
     575            fatal_error("Please install ntfsprogs package/tarball.");
    576576        }
    577577    }
  • trunk/mondo/mondo/mondorestore/mondo-restore.c

    r274 r300  
    13681368  /** malloc ***/
    13691369    char *checksum, *outfile_fname, *tmp, *bzip2_command,
    1370         *partimagehack_command, *suffix, *sz_devfile;
     1370        *ntfsprog_command, *suffix, *sz_devfile;
    13711371    char *bigblk;
    13721372    char *p;
     
    13751375    long sliceno;
    13761376    long siz;
    1377     char partimagehack_fifo[MAX_STR_LEN];
     1377    char ntfsprog_fifo[MAX_STR_LEN];
    13781378    char *file_to_openout = NULL;
    13791379    struct s_filename_and_lstat_info biggiestruct;
    13801380    struct utimbuf the_utime_buf, *ubuf;
    1381     bool use_partimage_hack = FALSE;
     1381    bool use_ntfsprog_hack = FALSE;
    13821382    pid_t pid;
    13831383    int res = 0;
     
    13941394    malloc_string(tmp);
    13951395    malloc_string(bzip2_command);
    1396     malloc_string(partimagehack_command);
     1396    malloc_string(ntfsprog_command);
    13971397    malloc_string(suffix);
    13981398    malloc_string(sz_devfile);
     
    14511451
    14521452    log_msg(1, "DEFINITELY restoring %s", biggiestruct.filename);
    1453     if (biggiestruct.use_partimagehack) {
     1453    if (biggiestruct.use_ntfsprog) {
    14541454        if (strncmp(biggiestruct.filename, "/dev/", 5)) {
    14551455            log_msg(1,
    1456                     "I was in error when I set biggiestruct.use_partimagehack to TRUE.");
     1456                    "I was in error when I set biggiestruct.use_ntfsprog to TRUE.");
    14571457            log_msg(1, "%s isn't even in /dev", biggiestruct.filename);
    1458             biggiestruct.use_partimagehack = FALSE;
    1459         }
    1460     }
    1461 
    1462     if (biggiestruct.use_partimagehack) // if it's an NTFS device
     1458            biggiestruct.use_ntfsprog = FALSE;
     1459        }
     1460    }
     1461
     1462    if (biggiestruct.use_ntfsprog)  // if it's an NTFS device
    14631463//  if (!strncmp ( biggiestruct.filename, "/dev/", 5))
    14641464    {
    14651465        g_loglevel = 4;
    1466         use_partimage_hack = TRUE;
     1466        use_ntfsprog_hack = TRUE;
    14671467        log_msg(2,
    1468                 "Calling partimagehack in background because %s is an NTFS /dev entry",
     1468                "Calling ntfsclone in background because %s is an NTFS /dev entry",
    14691469                outfile_fname);
    14701470        sprintf(sz_devfile, "/tmp/%d.%d.000", (int) (random() % 32768),
    14711471                (int) (random() % 32768));
    14721472        mkfifo(sz_devfile, 0x770);
    1473         strcpy(partimagehack_fifo, sz_devfile);
    1474         file_to_openout = partimagehack_fifo;
     1473        strcpy(ntfsprog_fifo, sz_devfile);
     1474        file_to_openout = ntfsprog_fifo;
    14751475        switch (pid = fork()) {
    14761476        case -1:
     
    14781478        case 0:
    14791479            log_msg(3,
    1480                     "CHILD - fip - calling feed_outfrom_partimage(%s, %s)",
    1481                     biggiestruct.filename, partimagehack_fifo);
     1480                    "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)",
     1481                    biggiestruct.filename, ntfsprog_fifo);
    14821482            res =
    1483                 feed_outfrom_partimage(biggiestruct.filename,
    1484                                        partimagehack_fifo);
     1483                feed_outfrom_ntfsprog(biggiestruct.filename,
     1484                                       ntfsprog_fifo);
    14851485//          log_msg(3, "CHILD - fip - exiting");
    14861486            exit(res);
     
    14881488        default:
    14891489            log_msg(3,
    1490                     "feed_into_partimage() called in background --- pid=%ld",
     1490                    "feed_into_ntfsprog() called in background --- pid=%ld",
    14911491                    (long int) (pid));
    14921492        }
    14931493    } else {
    1494         use_partimage_hack = FALSE;
    1495         partimagehack_fifo[0] = '\0';
     1494        use_ntfsprog_hack = FALSE;
     1495        ntfsprog_fifo[0] = '\0';
    14961496        file_to_openout = outfile_fname;
    14971497        if (!does_file_exist(outfile_fname))    // yes, it looks weird with the '!' but it's correct that way
     
    15201520        return (1);
    15211521    }
    1522     log_msg(3, "Opened out to %s", outfile_fname);  // CD/DVD --> mondorestore --> partimagehack --> hard disk itself
     1522    log_msg(3, "Opened out to %s", outfile_fname);  // CD/DVD --> mondorestore --> ntfsclone --> hard disk itself
    15231523
    15241524    for (sliceno = 1, finished = FALSE; !finished;) {
     
    16291629    g_loglevel = old_loglevel;
    16301630
    1631     if (use_partimage_hack) {
    1632         log_msg(3, "Waiting for partimage to finish");
     1631    if (use_ntfsprog_hack) {
     1632        log_msg(3, "Waiting for ntfsclone to finish");
    16331633        sprintf(tmp,
    1634                 " ps ax | grep \" partimagehack \" | grep -v grep > /dev/null 2> /dev/null");
     1634                " ps ax | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null");
    16351635        while (system(tmp) == 0) {
    16361636            sleep(1);
    16371637        }
    1638         log_it("OK, partimage has really finished");
     1638        log_it("OK, ntfsclone has really finished");
    16391639    }
    16401640
     
    16521652    paranoid_free(tmp);
    16531653    paranoid_free(bzip2_command);
    1654     paranoid_free(partimagehack_command);
     1654    paranoid_free(ntfsprog_command);
    16551655    paranoid_free(suffix);
    16561656    paranoid_free(sz_devfile);
     
    16821682                                     long long biggiefile_size, //UNUSED
    16831683                                     struct s_node *filelist,
    1684                                      int use_partimagehack,
     1684                                     int use_ntfsprog,
    16851685                                     char *pathname_of_last_file_restored)
    16861686{
     
    16921692    char *command;
    16931693    char *outfile_fname;
    1694     char *partimagehack_command;
     1694    char *ntfsprog_command;
    16951695    char *sz_devfile;
    1696     char *partimagehack_fifo;
     1696    char *ntfsprog_fifo;
    16971697    char *file_to_openout = NULL;
    16981698
     
    17061706    long long slice_siz;
    17071707    bool dummy_restore = FALSE;
    1708     bool use_partimage_hack = FALSE;
     1708    bool use_ntfsprog_hack = FALSE;
    17091709    pid_t pid;
    17101710    struct s_filename_and_lstat_info biggiestruct;
     
    17131713
    17141714    malloc_string(tmp);
    1715     malloc_string(partimagehack_fifo);
     1715    malloc_string(ntfsprog_fifo);
    17161716    malloc_string(outfile_fname);
    17171717    malloc_string(command);
    17181718    malloc_string(sz_devfile);
    1719     malloc_string(partimagehack_command);
     1719    malloc_string(ntfsprog_command);
    17201720    old_loglevel = g_loglevel;
    17211721    assert(bkpinfo != NULL);
     
    17241724
    17251725    pathname_of_last_file_restored[0] = '\0';
    1726     if (use_partimagehack == BLK_START_A_PIHBIGGIE) {
    1727         use_partimagehack = 1;
     1726    if (use_ntfsprog == BLK_START_A_PIHBIGGIE) {
     1727        use_ntfsprog = 1;
    17281728        log_msg(1, "%s --- pih=YES", orig_bf_fname);
    1729     } else if (use_partimagehack == BLK_START_A_NORMBIGGIE) {
    1730         use_partimagehack = 0;
     1729    } else if (use_ntfsprog == BLK_START_A_NORMBIGGIE) {
     1730        use_ntfsprog = 0;
    17311731        log_msg(1, "%s --- pih=NO", orig_bf_fname);
    17321732    } else {
    1733         use_partimagehack = 0;
     1733        use_ntfsprog = 0;
    17341734        log_msg(1, "%s --- pih=NO (weird marker though)", orig_bf_fname);
    17351735    }
     
    17571757    }
    17581758
    1759     if (use_partimagehack) {
     1759    if (use_ntfsprog) {
    17601760        if (strncmp(orig_bf_fname, "/dev/", 5)) {
    17611761            log_msg(1,
    1762                     "I was in error when I set use_partimagehack to TRUE.");
     1762                    "I was in error when I set use_ntfsprog to TRUE.");
    17631763            log_msg(1, "%s isn't even in /dev", orig_bf_fname);
    1764             use_partimagehack = FALSE;
    1765         }
    1766     }
    1767 
    1768     if (use_partimagehack) {
     1764            use_ntfsprog = FALSE;
     1765        }
     1766    }
     1767
     1768    if (use_ntfsprog) {
    17691769        g_loglevel = 4;
    17701770        strcpy(outfile_fname, orig_bf_fname);
    1771         use_partimage_hack = TRUE;
     1771        use_ntfsprog_hack = TRUE;
    17721772        log_msg(2,
    1773                 "Calling partimagehack in background because %s is a /dev entry",
     1773                "Calling ntfsclone in background because %s is a /dev entry",
    17741774                outfile_fname);
    17751775        sprintf(sz_devfile, "/tmp/%d.%d.000", (int) (random() % 32768),
    17761776                (int) (random() % 32768));
    17771777        mkfifo(sz_devfile, 0x770);
    1778         strcpy(partimagehack_fifo, sz_devfile);
    1779         file_to_openout = partimagehack_fifo;
     1778        strcpy(ntfsprog_fifo, sz_devfile);
     1779        file_to_openout = ntfsprog_fifo;
    17801780        switch (pid = fork()) {
    17811781        case -1:
     
    17831783        case 0:
    17841784            log_msg(3,
    1785                     "CHILD - fip - calling feed_outfrom_partimage(%s, %s)",
    1786                     outfile_fname, partimagehack_fifo);
     1785                    "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)",
     1786                    outfile_fname, ntfsprog_fifo);
    17871787            res =
    1788                 feed_outfrom_partimage(outfile_fname, partimagehack_fifo);
     1788                feed_outfrom_ntfsprog(outfile_fname, ntfsprog_fifo);
    17891789//          log_msg(3, "CHILD - fip - exiting");
    17901790            exit(res);
     
    17921792        default:
    17931793            log_msg(3,
    1794                     "feed_into_partimage() called in background --- pid=%ld",
     1794                    "feed_into_ntfsprog() called in background --- pid=%ld",
    17951795                    (long int) (pid));
    17961796        }
     
    18041804                    orig_bf_fname);
    18051805        }
    1806         use_partimage_hack = FALSE;
    1807         partimagehack_fifo[0] = '\0';
     1806        use_ntfsprog_hack = FALSE;
     1807        ntfsprog_fifo[0] = '\0';
    18081808        file_to_openout = outfile_fname;
    18091809        if (!does_file_exist(outfile_fname))    // yes, it looks weird with the '!' but it's correct that way
     
    18821882            pathname_of_last_file_restored);
    18831883
    1884     if (use_partimage_hack) {
    1885         log_msg(3, "Waiting for partimage to finish");
     1884    if (use_ntfsprog_hack) {
     1885        log_msg(3, "Waiting for ntfsclone to finish");
    18861886        sprintf(tmp,
    1887                 " ps ax | grep \" partimagehack \" | grep -v grep > /dev/null 2> /dev/null");
     1887                " ps ax | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null");
    18881888        while (system(tmp) == 0) {
    18891889            sleep(1);
    18901890        }
    1891         log_msg(3, "OK, partimage has really finished");
     1891        log_msg(3, "OK, ntfsclone has really finished");
    18921892    }
    18931893
     
    19061906    paranoid_free(outfile_fname);
    19071907    paranoid_free(command);
    1908     paranoid_free(partimagehack_command);
     1908    paranoid_free(ntfsprog_command);
    19091909    paranoid_free(sz_devfile);
    1910     paranoid_free(partimagehack_fifo);
     1910    paranoid_free(ntfsprog_fifo);
    19111911    g_loglevel = old_loglevel;
    19121912    return (retval);
Note: See TracChangeset for help on using the changeset viewer.