Changeset 296 in MondoRescue for branches/2.06


Ignore:
Timestamp:
Jan 11, 2006, 10:10:31 AM (18 years ago)
Author:
andree
Message:

Replaced partimagehack with ntfsclone from ntfsprogs package. Replaced
all occurrences of strings 'partimagehack' and 'partimage' with 'ntfsprog'.

Location:
branches/2.06/mondo
Files:
15 edited

Legend:

Unmodified
Added
Removed
  • branches/2.06/mondo/ChangeLog

    r294 r296  
    1212- Abort|Warn when one of the include|exclude dirs (-I|-E) does not exist
    1313  (Bruno Cornec/Jeffs)
     14- Replaced partimagehack with ntfsclone from ntfsprogs package.
     15  (Andree Leidenfrost)
    1416
    1517v2.06 (2005-12-23)
  • branches/2.06/mondo/mondo/common/libmondo-archive-EXT.h

    r259 r296  
    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);
  • branches/2.06/mondo/mondo/common/libmondo-archive.c

    r260 r296  
    21622162    char *bigfile_fname;
    21632163    char *sz_devfile;
    2164     char *partimagehack_fifo = NULL;
     2164    char *ntfsprog_fifo = NULL;
    21652165    /*@ long *********************************************** */
    21662166    long biggie_file_number = 0;
     
    21742174    FILE *ftmp = NULL;
    21752175    bool delete_when_done;
    2176     bool use_partimagehack;
     2176    bool use_ntfsprog;
    21772177    /*@ long long ****************************************** */
    21782178    long long biggie_fsize;
     
    22092209    for (fgets(bigfile_fname, MAX_STR_LEN, fin); !feof(fin);
    22102210         fgets(bigfile_fname, MAX_STR_LEN, fin), biggie_file_number++) {
    2211         use_partimagehack = FALSE;
     2211        use_ntfsprog = FALSE;
    22122212        if (bigfile_fname[strlen(bigfile_fname) - 1] < 32) {
    22132213            bigfile_fname[strlen(bigfile_fname) - 1] = '\0';
     
    22232223            delete_when_done = TRUE;
    22242224        } else {
    2225 // Call partimagehack if it's a /dev entry (i.e. a partition to be imaged)
     2225// Call ntfsclone (formerly partimagehack) if it's a /dev entry (i.e. a partition to be imaged)
    22262226            log_msg(2, "bigfile_fname = %s", bigfile_fname);
    2227             use_partimagehack = FALSE;
     2227            use_ntfsprog = FALSE;
    22282228            if (!strncmp(bigfile_fname, "/dev/", 5)
    22292229                && is_dev_an_NTFS_dev(bigfile_fname)) {
    2230                 use_partimagehack = TRUE;
     2230                use_ntfsprog = TRUE;
    22312231                log_msg(2,
    2232                         "Calling partimagehack in background because %s is an NTFS partition",
     2232                        "Calling ntfsclone in background because %s is an NTFS partition",
    22332233                        bigfile_fname);
    22342234                sprintf(sz_devfile, "/tmp/%d.%d.000",
     
    22362236                        (int) (random() % 32768));
    22372237                mkfifo(sz_devfile, 0x770);
    2238                 partimagehack_fifo = sz_devfile;
     2238                ntfsprog_fifo = sz_devfile;
    22392239                switch (pid = fork()) {
    22402240                case -1:
     
    22422242                case 0:
    22432243                    log_msg(2,
    2244                             "CHILD - fip - calling feed_into_partimage(%s, %s)",
     2244                            "CHILD - fip - calling feed_into_ntfsprog(%s, %s)",
    22452245                            bigfile_fname, sz_devfile);
    2246                     res = feed_into_partimage(bigfile_fname, sz_devfile);
     2246                    res = feed_into_ntfsprog(bigfile_fname, sz_devfile);
    22472247                    exit(res);
    22482248                    break;
    22492249                default:
    22502250                    log_msg(2,
    2251                             "feed_into_partimage() called in background --- pid=%ld",
     2251                            "feed_into_ntfsprog() called in background --- pid=%ld",
    22522252                            (long int) (pid));
    22532253                }
     
    22562256            else {
    22572257                sz_devfile[0] = '\0';
    2258                 partimagehack_fifo = NULL;
     2258                ntfsprog_fifo = NULL;
    22592259            }
    22602260
     
    22652265            if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    22662266                write_header_block_to_stream(biggie_fsize, bigfile_fname,
    2267                                              use_partimagehack ?
     2267                                             use_ntfsprog ?
    22682268                                             BLK_START_A_PIHBIGGIE :
    22692269                                             BLK_START_A_NORMBIGGIE);
     
    22712271            res =
    22722272                slice_up_file_etc(bkpinfo, bigfile_fname,
    2273                                   partimagehack_fifo, biggie_file_number,
    2274                                   noof_biggie_files, use_partimagehack);
     2273                                  ntfsprog_fifo, biggie_file_number,
     2274                                  noof_biggie_files, use_ntfsprog);
    22752275            if (IS_THIS_A_STREAMING_BACKUP(bkpinfo->backup_media_type)) {
    22762276                write_header_block_to_stream(0,
     
    32703270 *
    32713271 * @param biggie_filename The file to chop up.
    3272  * @param partimagehack_fifo The FIFO to partimagehack if this is an imagedev, NULL otherwise.
     3272 * @param ntfsprog_fifo The FIFO to ntfsclone if this is an imagedev, NULL otherwise.
    32733273 * @param biggie_file_number The sequence number of this biggie file (starting from 0).
    32743274 * @param noof_biggie_files The number of biggie files there are total.
     
    32793279int
    32803280slice_up_file_etc(struct s_bkpinfo *bkpinfo, char *biggie_filename,
    3281                   char *partimagehack_fifo, long biggie_file_number,
    3282                   long noof_biggie_files, bool use_partimagehack)
     3281                  char *ntfsprog_fifo, long biggie_file_number,
     3282                  long noof_biggie_files, bool use_ntfsprog)
    32833283{
    32843284
     
    33293329
    33303330    biggiestruct.for_backward_compatibility = '\n';
    3331     biggiestruct.use_partimagehack = use_partimagehack;
     3331    biggiestruct.use_ntfsprog = use_ntfsprog;
    33323332    if (!(tempblock = (char *) malloc(256 * 1024))) {
    33333333        fatal_error("malloc error 256*1024");
     
    33473347        fatal_error("bkpinfo->optimal_set_size is insanely small");
    33483348    }
    3349     if (partimagehack_fifo) {
    3350         file_to_openin = partimagehack_fifo;
     3349    if (ntfsprog_fifo) {
     3350        file_to_openin = ntfsprog_fifo;
    33513351        strcpy(checksum_line, "IGNORE");
    33523352        log_msg(2,
    33533353                "Not calculating checksum for %s: it would take too long",
    33543354                biggie_filename);
    3355         totallength = get_phys_size_of_drive(biggie_filename)*1024*1024LL;
     3355        if ( !find_home_of_exe("ntfsresize")) {
     3356            fatal_error("ntfsresize not found");
     3357        }
     3358        sprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename);
     3359        log_it("command = %s", command);
     3360        strcpy (tmp, call_program_and_get_last_line_of_output(command));
     3361        log_it("res of it = %s", tmp);
     3362        totallength = atoll(tmp);
    33563363    } else {
    33573364        file_to_openin = biggie_filename;
  • branches/2.06/mondo/mondo/common/libmondo-archive.h

    r259 r296  
    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);
  • branches/2.06/mondo/mondo/common/libmondo-files.c

    r273 r296  
    865865    char *biggielist;
    866866    char *comment;
     867    char *tmp;
     868    char *command;
    867869
    868870    /*@ long ******************************************************** */
     
    878880    malloc_string(biggielist);
    879881    malloc_string(comment);
     882    malloc_string(tmp);
     883    malloc_string(command);
    880884    log_it("Calculating size of all biggiefiles (in total)");
    881885    sprintf(biggielist, "%s/biggielist.txt", bkpinfo->tmpdir);
     
    892896            }
    893897            if (0 == strncmp(fname, "/dev/", 5)) {
    894                 file_len_K = get_phys_size_of_drive(fname) * 1024L;
     898                if (is_dev_an_NTFS_dev(fname)) {
     899                    if ( !find_home_of_exe("ntfsresize")) {
     900                        fatal_error("ntfsresize not found");
     901                    }
     902                    sprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", fname);
     903                    log_it("command = %s", command);
     904                    strcpy (tmp, call_program_and_get_last_line_of_output(command));
     905                    log_it("res of it = %s", tmp);
     906                    file_len_K = atoll(tmp) / 1024L;
     907                } else {
     908                    file_len_K = get_phys_size_of_drive(fname) * 1024L;
     909                }
    895910            } else {
    896911                file_len_K = (long) (length_of_file(fname) / 1024);
     
    915930    paranoid_free(biggielist);
    916931    paranoid_free(comment);
     932    paranoid_free(tmp);
     933    paranoid_free(command);
    917934    return (scratchL);
    918935}
  • branches/2.06/mondo/mondo/common/libmondo-fork-EXT.h

    r128 r296  
    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);
  • branches/2.06/mondo/mondo/common/libmondo-fork.c

    r154 r296  
    44- subroutines for handling forking/pthreads/etc.
    55
     6
     701/20/2006
     8- replaced partimagehack with ntfsclone
    69
    71006/20/2004
     
    493496
    494497
    495 
    496 /**
    497  * Thread callback to run a command (partimage) in the background.
    498  * @param xfb A transfer block of @c char, containing:
    499  * - xfb:[0] A marker, should be set to 2. Decremented to 1 while the command is running and 0 when it's finished.
    500  * - xfb:[1] The command's return value, if xfb:[0] is 0.
    501  * - xfb+2:  A <tt>NULL</tt>-terminated string containing the command to be run.
    502  * @return NULL to pthread_join.
    503  */
    504 void *call_partimage_in_bkgd(void *xfb)
    505 {
    506     char *transfer_block;
    507     int retval = 0;
    508 
    509     g_buffer_pid = getpid();
    510     unlink("/tmp/null");
    511     log_msg(1, "starting");
    512     transfer_block = (char *) xfb;
    513     transfer_block[0]--;        // should now be 1
    514     retval = system(transfer_block + 2);
    515     if (retval) {
    516         log_OS_error("partimage returned an error");
    517     }
    518     transfer_block[1] = retval;
    519     transfer_block[0]--;        // should now be 0
    520     g_buffer_pid = 0;
    521     log_msg(1, "returning");
    522     pthread_exit(NULL);
    523 }
    524 
    525 
    526 /**
    527  * File to touch if we want partimage to wait for us.
    528  */
    529 #define PAUSE_PARTIMAGE_FNAME "/tmp/PAUSE-PARTIMAGE-FOR-MONDO"
    530 
    531498/**
    532499 * Apparently unused. @bug This has a purpose, but what?
     
    535502#define PIMP_END_SZ "ENDENDEND0xBBC10xBBC2T231hc81h42vws89ff3kff9a82gv34r7fghbka"
    536503
    537 /**
    538  * Marker to start the next subvolume for Partimage.
    539  */
    540 #define NEXT_SUBVOL_PLEASE "I-grew-up-on-the-crime-side,-the-New-York-Times-side,-where-staying-alive-was-no-jive"
    541 
    542 /**
    543  * Marker to end the partimage file.
    544  */
    545 #define NO_MORE_SUBVOLS "On-second-hand,momma-bounced-on-old-man,-and-so-we-moved-to-Shaolin-Land."
     504
     505
    546506
    547507int copy_from_src_to_dest(FILE * f_orig, FILE * f_archived, char direction)
     
    674634
    675635
     636
     637
    676638/**
    677  * Call partimage from @p input_device to @p output_fname.
    678  * @param input_device The device to read.
    679  * @param output_fname The file to write.
    680  * @return 0 for success, nonzero for failure.
    681  */
    682 int dynamically_create_pipes_and_copy_from_them_to_output_file(char
    683                                                                *input_device,
    684                                                                char
    685                                                                *output_fname)
    686 {
    687     char *curr_fifo;
    688     char *prev_fifo;
    689     char *next_fifo;
    690     char *command;
    691     char *sz_call_to_partimage;
    692     int fifo_number = 0;
    693     struct stat buf;
    694     pthread_t partimage_thread;
    695     int res = 0;
    696     char *tmpstub;
    697     FILE *fout;
    698     FILE *fin;
    699     char *tmp;
    700 
    701     malloc_string(tmpstub);
    702     malloc_string(curr_fifo);
    703     malloc_string(prev_fifo);
    704     malloc_string(next_fifo);
    705     malloc_string(command);
    706     malloc_string(sz_call_to_partimage);
    707     malloc_string(tmp);
    708 
    709     log_msg(1, "g_tmpfs_mountpt = %s", g_tmpfs_mountpt);
    710     if (g_tmpfs_mountpt && g_tmpfs_mountpt[0]
    711         && does_file_exist(g_tmpfs_mountpt)) {
    712         strcpy(tmpstub, g_tmpfs_mountpt);
    713     } else {
    714         strcpy(tmpstub, "/tmp");
    715     }
    716     paranoid_system("rm -f /tmp/*PARTIMAGE*");
    717     sprintf(command, "rm -Rf %s/pih-fifo-*", tmpstub);
    718     paranoid_system(command);
    719     sprintf(tmpstub + strlen(tmpstub), "/pih-fifo-%ld",
    720             (long int) random());
    721     mkfifo(tmpstub, S_IRWXU | S_IRWXG); // never used, though...
    722     sprintf(curr_fifo, "%s.%03d", tmpstub, fifo_number);
    723     sprintf(next_fifo, "%s.%03d", tmpstub, fifo_number + 1);
    724     mkfifo(curr_fifo, S_IRWXU | S_IRWXG);
    725     mkfifo(next_fifo, S_IRWXU | S_IRWXG);   // make sure _next_ fifo already exists before we call partimage
    726     sz_call_to_partimage[0] = 2;
    727     sz_call_to_partimage[1] = 0;
    728     sprintf(sz_call_to_partimage + 2,
    729             "partimagehack " PARTIMAGE_PARAMS
    730             " save %s %s > /tmp/stdout 2> /tmp/stderr", input_device,
    731             tmpstub);
    732     log_msg(5, "curr_fifo   = %s", curr_fifo);
    733     log_msg(5, "next_fifo   = %s", next_fifo);
    734     log_msg(5, "sz_call_to_partimage call is '%s'",
    735             sz_call_to_partimage + 2);
    736     if (!lstat(output_fname, &buf) && S_ISREG(buf.st_mode)) {
    737         log_msg(5, "Deleting %s", output_fname);
    738         unlink(output_fname);
    739     }
    740     if (!(fout = fopen(output_fname, "w"))) {
    741         fatal_error("Unable to openout to output_fname");
    742     }
    743     res =
    744         pthread_create(&partimage_thread, NULL, call_partimage_in_bkgd,
    745                        (void *) sz_call_to_partimage);
    746     if (res) {
    747         fatal_error("Failed to create thread to call partimage");
    748     }
    749     log_msg(1, "Running fore/back at same time");
    750     log_to_screen("Working with partimagehack...");
    751     while (sz_call_to_partimage[0] > 0) {
    752         sprintf(tmp, "%s\n", NEXT_SUBVOL_PLEASE);
    753         if (fwrite(tmp, 1, 128, fout) != 128) {
    754             fatal_error("Cannot write interim block");
    755         }
    756         log_msg(5, "fifo_number=%d", fifo_number);
    757         log_msg(4, "Cat'ting %s", curr_fifo);
    758         if (!(fin = fopen(curr_fifo, "r"))) {
    759             fatal_error("Unable to openin from fifo");
    760         }
    761 //      if (!sz_call_to_partimage[0]) { break; }
    762         log_msg(5, "Deleting %s", prev_fifo);
    763         unlink(prev_fifo);      // just in case
    764         copy_from_src_to_dest(fin, fout, 'w');
    765         paranoid_fclose(fin);
    766         fifo_number++;
    767         strcpy(prev_fifo, curr_fifo);
    768         strcpy(curr_fifo, next_fifo);
    769         log_msg(5, "Creating %s", next_fifo);
    770         sprintf(next_fifo, "%s.%03d", tmpstub, fifo_number + 1);
    771         mkfifo(next_fifo, S_IRWXU | S_IRWXG);   // make sure _next_ fifo exists before we cat this one
    772         system("sync");
    773         sleep(5);
    774     }
    775     sprintf(tmp, "%s\n", NO_MORE_SUBVOLS);
    776     if (fwrite(tmp, 1, 128, fout) != 128) {
    777         fatal_error("Cannot write interim block");
    778     }
    779     if (fwrite(tmp, 1, 128, fout) != 128) {
    780         fatal_error("Cannot write interim block");
    781     }
    782     if (fwrite(tmp, 1, 128, fout) != 128) {
    783         fatal_error("Cannot write interim block");
    784     }
    785     if (fwrite(tmp, 1, 128, fout) != 128) {
    786         fatal_error("Cannot write interim block");
    787     }
    788     paranoid_fclose(fout);
    789     log_to_screen("Cleaning up after partimagehack...");
    790     log_msg(3, "Final fifo_number=%d", fifo_number);
    791     paranoid_system("sync");
    792     unlink(next_fifo);
    793     unlink(curr_fifo);
    794     unlink(prev_fifo);
    795     log_to_screen("Finished cleaning up.");
    796 
    797 //  if (!lstat(sz_wait_for_this_file, &statbuf))
    798 //    { log_msg(3, "WARNING! %s was not processed.", sz_wait_for_this_file); }
    799     log_msg(2, "Waiting for pthread_join() to join.");
    800     pthread_join(partimage_thread, NULL);
    801     res = sz_call_to_partimage[1];
    802     log_msg(2, "pthread_join() joined OK.");
    803     log_msg(1, "Partimagehack(save) returned %d", res);
    804     unlink(tmpstub);
    805     paranoid_free(curr_fifo);
    806     paranoid_free(prev_fifo);
    807     paranoid_free(next_fifo);
    808     paranoid_free(tmpstub);
    809     paranoid_free(tmp);
    810     paranoid_free(command);
    811     return (res);
    812 }
    813 
    814 
    815 /**
    816  * Feed @p input_device through partimage to @p output_fname.
     639 * Feed @p input_device through ntfsclone to @p output_fname.
    817640 * @param input_device The device to image.
    818641 * @param output_fname The file to write.
    819642 * @return 0 for success, nonzero for failure.
    820643 */
    821 int feed_into_partimage(char *input_device, char *output_fname)
     644int feed_into_ntfsprog(char *input_device, char *output_fname)
    822645{
    823646// BACKUP
    824     int res;
     647    int res = -1;
     648    char*command;
    825649
    826650    if (!does_file_exist(input_device)) {
    827651        fatal_error("input device does not exist");
    828652    }
    829     if (!find_home_of_exe("partimagehack")) {
    830         fatal_error("partimagehack not found");
    831     }
    832     res =
    833         dynamically_create_pipes_and_copy_from_them_to_output_file
    834         (input_device, output_fname);
     653    if ( !find_home_of_exe("ntfsclone")) {
     654        fatal_error("ntfsclone not found");
     655    }
     656    malloc_string(command);
     657    sprintf(command, "ntfsclone --force --save-image --overwrite %s %s", output_fname, input_device);
     658    res = run_program_and_log_output(command, 5);
     659    paranoid_free(command);
    835660    return (res);
    836661}
     
    1000825
    1001826
    1002 #define PIH_LOG "/var/log/partimage-debug.log"
    1003 
    1004827
    1005828/**
    1006  * Feed @p input_fifo through partimage (restore) to @p output_device.
    1007  * @param input_fifo The partimage file to read.
     829 * Feed @p input_fifo through ntfsclone (restore) to @p output_device.
     830 * @param input_fifo The ntfsclone file to read.
    1008831 * @param output_device Where to put the output.
    1009  * @return The return value of partimagehack (0 for success).
    1010  * @bug Probably unnecessary, as the partimage is just a sparse file. We could use @c dd to restore it.
     832 * @return The return value of ntfsclone (0 for success).
    1011833 */
    1012 int feed_outfrom_partimage(char *output_device, char *input_fifo)
     834int feed_outfrom_ntfsprog(char *output_device, char *input_fifo)
    1013835{
    1014836// RESTORE
    1015     char *tmp;
    1016 //  char *command;
    1017     char *stuff;
    1018     char *sz_call_to_partimage;
    1019     pthread_t partimage_thread;
    1020     int res;
    1021     char *curr_fifo;
    1022     char *prev_fifo;
    1023     char *oldest_fifo;
    1024     char *next_fifo;
    1025     char *afternxt_fifo;
    1026     int fifo_number = 0;
    1027     char *tmpstub;
    1028     FILE *fin;
    1029     FILE *fout;
    1030 
    1031     malloc_string(curr_fifo);
    1032     malloc_string(prev_fifo);
    1033     malloc_string(next_fifo);
    1034     malloc_string(afternxt_fifo);
    1035     malloc_string(oldest_fifo);
    1036     malloc_string(tmp);
    1037     sz_call_to_partimage = malloc(1000);
    1038     malloc_string(stuff);
    1039     malloc_string(tmpstub);
    1040 
    1041     log_msg(1, "output_device=%s", output_device);
    1042     log_msg(1, "input_fifo=%s", input_fifo);
    1043 /* I don't trust g_tmpfs_mountpt
    1044   if (g_tmpfs_mountpt[0])
    1045     {
    1046       strcpy(tmpstub, g_tmpfs_mountpt);
    1047     }
    1048   else
    1049     {
    1050 */
    1051     strcpy(tmpstub, "/tmp");
    1052 //    }
    1053     log_msg(1, "tmpstub was %s", tmpstub);
    1054     strcpy(stuff, tmpstub);
    1055     sprintf(tmpstub, "%s/pih-fifo-%ld", stuff, (long int) random());
    1056     log_msg(1, "tmpstub is now %s", tmpstub);
    1057     unlink("/tmp/PARTIMAGEHACK-POSITION");
    1058     unlink(PAUSE_PARTIMAGE_FNAME);
    1059     paranoid_system("rm -f /tmp/*PARTIMAGE*");
    1060     sprintf(curr_fifo, "%s.%03d", tmpstub, fifo_number);
    1061     sprintf(next_fifo, "%s.%03d", tmpstub, fifo_number + 1);
    1062     sprintf(afternxt_fifo, "%s.%03d", tmpstub, fifo_number + 2);
    1063     mkfifo(PIH_LOG, S_IRWXU | S_IRWXG);
    1064     mkfifo(curr_fifo, S_IRWXU | S_IRWXG);
    1065     mkfifo(next_fifo, S_IRWXU | S_IRWXG);   // make sure _next_ fifo already exists before we call partimage
    1066     mkfifo(afternxt_fifo, S_IRWXU | S_IRWXG);
    1067     system("cat " PIH_LOG " > /dev/null &");
    1068     log_msg(3, "curr_fifo   = %s", curr_fifo);
    1069     log_msg(3, "next_fifo   = %s", next_fifo);
    1070     if (!does_file_exist(input_fifo)) {
    1071         fatal_error("input fifo does not exist");
    1072     }
    1073     if (!(fin = fopen(input_fifo, "r"))) {
    1074         fatal_error("Unable to openin from input_fifo");
    1075     }
    1076     if (!find_home_of_exe("partimagehack")) {
    1077         fatal_error("partimagehack not found");
    1078     }
    1079     sz_call_to_partimage[0] = 2;
    1080     sz_call_to_partimage[1] = 0;
    1081     sprintf(sz_call_to_partimage + 2,
    1082             "partimagehack " PARTIMAGE_PARAMS
    1083             " restore %s %s > /dev/null 2>> %s", output_device, curr_fifo,
    1084             MONDO_LOGFILE);
    1085     log_msg(1, "output_device = %s", output_device);
    1086     log_msg(1, "curr_fifo = %s", curr_fifo);
    1087     log_msg(1, "sz_call_to_partimage+2 = %s", sz_call_to_partimage + 2);
    1088     res =
    1089         pthread_create(&partimage_thread, NULL, call_partimage_in_bkgd,
    1090                        (void *) sz_call_to_partimage);
    1091     if (res) {
    1092         fatal_error("Failed to create thread to call partimage");
    1093     }
    1094     log_msg(1, "Running fore/back at same time");
    1095     log_msg(2, " Trying to openin %s", input_fifo);
    1096     if (!does_file_exist(input_fifo)) {
    1097         log_msg(2, "Warning - %s does not exist", input_fifo);
    1098     }
    1099     while (!does_file_exist("/tmp/PARTIMAGEHACK-POSITION")) {
    1100         log_msg(6, "Waiting for partimagehack (restore) to start");
    1101         sleep(1);
    1102     }
    1103     while (sz_call_to_partimage[0] > 0) {
    1104         if (fread(tmp, 1, 128, fin) != 128) {
    1105             fatal_error("Cannot read introductory block");
    1106         }
    1107         if (strstr(tmp, NEXT_SUBVOL_PLEASE)) {
    1108             log_msg(2, "Great. Next subvol coming up.");
    1109         } else if (strstr(tmp, NO_MORE_SUBVOLS)) {
    1110             log_msg(2, "Great. That was the last subvol.");
    1111             break;
    1112         } else {
    1113             log_msg(2, "WTF is this? '%s'", tmp);
    1114             fatal_error("Unknown interim block");
    1115         }
    1116         if (feof(fin)) {
    1117             log_msg(1, "Eof(fin) detected. Breaking.");
    1118             break;
    1119         }
    1120         log_msg(3, "Processing subvol %d", fifo_number);
    1121         log_msg(5, "fifo_number=%d", fifo_number);
    1122         if (!(fout = fopen(curr_fifo, "w"))) {
    1123             fatal_error("Cannot openout to curr_fifo");
    1124         }
    1125         log_msg(6, "Deleting %s", oldest_fifo);
    1126         copy_from_src_to_dest(fout, fin, 'r');
    1127         paranoid_fclose(fout);
    1128         fifo_number++;
    1129         unlink(oldest_fifo);    // just in case
    1130         strcpy(oldest_fifo, prev_fifo);
    1131         strcpy(prev_fifo, curr_fifo);
    1132         strcpy(curr_fifo, next_fifo);
    1133         strcpy(next_fifo, afternxt_fifo);
    1134         sprintf(afternxt_fifo, "%s.%03d", tmpstub, fifo_number + 2);
    1135         log_msg(6, "Creating %s", afternxt_fifo);
    1136         mkfifo(afternxt_fifo, S_IRWXU | S_IRWXG);   // make sure _next_ fifo already exists before we access current fifo
    1137         fflush(fin);
    1138 //      system("sync");
    1139         usleep(1000L * 100L);
    1140     }
    1141     paranoid_fclose(fin);
    1142     paranoid_system("sync");
    1143     log_msg(1, "Partimagehack has finished. Great. Fin-closing.");
    1144     log_msg(1, "Waiting for pthread_join");
    1145     pthread_join(partimage_thread, NULL);
    1146     res = sz_call_to_partimage[1];
    1147     log_msg(1, "Yay. Partimagehack (restore) returned %d", res);
    1148     unlink(prev_fifo);
    1149     unlink(curr_fifo);
    1150     unlink(next_fifo);
    1151     unlink(afternxt_fifo);
    1152     unlink(PIH_LOG);
    1153     paranoid_free(tmp);
    1154     paranoid_free(sz_call_to_partimage);
    1155     paranoid_free(stuff);
    1156     paranoid_free(prev_fifo);
    1157     paranoid_free(curr_fifo);
    1158     paranoid_free(next_fifo);
    1159     paranoid_free(afternxt_fifo);
    1160     paranoid_free(oldest_fifo);
    1161     paranoid_free(tmpstub);
     837    int res = -1;
     838    char *command;
     839
     840    if ( !find_home_of_exe("ntfsclone")) {
     841        fatal_error("ntfsclone not found");
     842    }
     843    malloc_string(command);
     844    sprintf(command, "ntfsclone --force --restore-image --overwrite %s %s", output_device, input_fifo);
     845    res = run_program_and_log_output(command, 5);
     846    paranoid_free(command);
    1162847    return (res);
    1163848}
  • branches/2.06/mondo/mondo/common/libmondo-fork.h

    r128 r296  
    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);
  • branches/2.06/mondo/mondo/common/libmondo-verify.c

    r273 r296  
    433433                if (res && !strncmp(biggiestruct.filename, " /dev/", 5)) {
    434434                    log_msg(3,
    435                             "Ignoring differences between %s and live filesystem because it's a device and therefore the archives are stored via partimagehack, not dd.",
     435                            "Ignoring differences between %s and live filesystem because it's a device and therefore the archives are stored via ntfsclone, not dd.",
    436436                            biggiestruct.filename);
    437437                    log_msg(3,
  • branches/2.06/mondo/mondo/common/mondostructures.h

    r128 r296  
    359359   *
    360360   * This is useful for backing up NTFS partitions.
    361    * @c partimage is used to back up only the used sectors, so the space tradeoff is not bad.
     361   * @c ntfsclone is used to back up only the used sectors, so the space tradeoff is not bad.
    362362   * However, several caveats apply to such a partition:
    363363   * - It must not be mounted during the backup
    364    * - It must be in a format that partimage knows how to handle
     364   * - It must be in a format that ntfsclone knows how to handle, i.e. NTFS
    365365   * - It cannot be verified during the verify or compare phase
    366366   * - It may not be resized or selectively restored at restore-time (all or nothing)
     
    678678     */
    679679    struct stat properties;
    680     bool use_partimagehack;
     680    bool use_ntfsprog;
    681681};
    682682
  • branches/2.06/mondo/mondo/common/my-stuff.h

    r237 r296  
    277277#define BLK_STOP_BIGGIEFILES    39  ///< Marker block: stop the biggiefile section.
    278278#define BLK_START_A_NORMBIGGIE  40  ///< Marker block: start a normal biggiefile.
    279 #define BLK_START_A_PIHBIGGIE   41  ///< Marker block: start a partimagehack'd biggiefile
     279#define BLK_START_A_PIHBIGGIE   41  ///< Marker block: start a ntfsprog'd biggiefile
    280280#define BLK_START_EXTENDED_ATTRIBUTES 45    ///< Marker block: start xattr/acl info
    281281#define BLK_STOP_EXTENDED_ATTRIBUTES 46 ///< Marker block: stop xattr/acl info
     
    518518#define DEFAULT_DEBUG_LEVEL 4   ///< By default, don't log messages with a loglevel higher than this.
    519519
    520 #define SZ_PARTIMAGE_VOLSIZE "1048576"  // was 4096
    521 #define PARTIMAGE_PARAMS "-z0 -V" SZ_PARTIMAGE_VOLSIZE " -o -b -d -g1"
     520#define SZ_NTFSPROG_VOLSIZE "1048576"   // was 4096
     521#define NTFSPROG_PARAMS "-z0 -V" SZ_NTFSPROG_VOLSIZE " -o -b -d -g1"
    522522
    523523#define MNT_CDROM "/mnt/cdrom"
  • branches/2.06/mondo/mondo/common/newt-specific.c

    r273 r296  
    394394        kill_anything_like_this("/mondo/do-not");
    395395        kill_anything_like_this("tmp.mondo");
    396         kill_anything_like_this("partimagehack");
     396        kill_anything_like_this("ntfsclone");
    397397        sync();
    398398        sprintf(tmp, "umount %s", g_tmpfs_mountpt);
  • branches/2.06/mondo/mondo/mondoarchive/main.c

    r259 r296  
    275275    diffs = 0;
    276276    say_at_end[0] = '\0';
    277     unlink("/var/log/partimagehack-debug.log");
    278277    printf("Initializing...\n");
    279278    if (!(bkpinfo = malloc(sizeof(struct s_bkpinfo)))) {
  • branches/2.06/mondo/mondo/mondoarchive/mondo-cli.c

    r289 r296  
    711711    if (flag_set['x']) {
    712712        strncpy(bkpinfo->image_devs, flag_val['x'], MAX_STR_LEN / 4);
    713         if (run_program_and_log_output("which partimagehack", 2)) {
    714             fatal_error("Please install partimagehack RPM/tarball.");
     713        if (run_program_and_log_output("which ntfsclone", 2)) {
     714            fatal_error("Please install ntfsprogs package/tarball.");
    715715        }
    716716    }
  • branches/2.06/mondo/mondo/mondorestore/mondo-restore.c

    r273 r296  
    13651365  /** malloc ***/
    13661366    char *checksum, *outfile_fname, *tmp, *bzip2_command,
    1367         *partimagehack_command, *suffix, *sz_devfile;
     1367        *ntfsprog_command, *suffix, *sz_devfile;
    13681368    char *bigblk;
    13691369    char *p;
     
    13721372    long sliceno;
    13731373    long siz;
    1374     char partimagehack_fifo[MAX_STR_LEN];
     1374    char ntfsprog_fifo[MAX_STR_LEN];
    13751375    char *file_to_openout = NULL;
    13761376    struct s_filename_and_lstat_info biggiestruct;
    13771377    struct utimbuf the_utime_buf, *ubuf;
    1378     bool use_partimage_hack = FALSE;
     1378    bool use_ntfsprog_hack = FALSE;
    13791379    pid_t pid;
    13801380    int res = 0;
     
    13911391    malloc_string(tmp);
    13921392    malloc_string(bzip2_command);
    1393     malloc_string(partimagehack_command);
     1393    malloc_string(ntfsprog_command);
    13941394    malloc_string(suffix);
    13951395    malloc_string(sz_devfile);
     
    14481448
    14491449    log_msg(1, "DEFINITELY restoring %s", biggiestruct.filename);
    1450     if (biggiestruct.use_partimagehack) {
     1450    if (biggiestruct.use_ntfsprog) {
    14511451        if (strncmp(biggiestruct.filename, "/dev/", 5)) {
    14521452            log_msg(1,
    1453                     "I was in error when I set biggiestruct.use_partimagehack to TRUE.");
     1453                    "I was in error when I set biggiestruct.use_ntfsprog to TRUE.");
    14541454            log_msg(1, "%s isn't even in /dev", biggiestruct.filename);
    1455             biggiestruct.use_partimagehack = FALSE;
    1456         }
    1457     }
    1458 
    1459     if (biggiestruct.use_partimagehack) // if it's an NTFS device
     1455            biggiestruct.use_ntfsprog = FALSE;
     1456        }
     1457    }
     1458
     1459    if (biggiestruct.use_ntfsprog)  // if it's an NTFS device
    14601460//  if (!strncmp ( biggiestruct.filename, "/dev/", 5))
    14611461    {
    14621462        g_loglevel = 4;
    1463         use_partimage_hack = TRUE;
     1463        use_ntfsprog_hack = TRUE;
    14641464        log_msg(2,
    1465                 "Calling partimagehack in background because %s is an NTFS /dev entry",
     1465                "Calling ntfsclone in background because %s is an NTFS /dev entry",
    14661466                outfile_fname);
    14671467        sprintf(sz_devfile, "/tmp/%d.%d.000", (int) (random() % 32768),
    14681468                (int) (random() % 32768));
    14691469        mkfifo(sz_devfile, 0x770);
    1470         strcpy(partimagehack_fifo, sz_devfile);
    1471         file_to_openout = partimagehack_fifo;
     1470        strcpy(ntfsprog_fifo, sz_devfile);
     1471        file_to_openout = ntfsprog_fifo;
    14721472        switch (pid = fork()) {
    14731473        case -1:
     
    14751475        case 0:
    14761476            log_msg(3,
    1477                     "CHILD - fip - calling feed_outfrom_partimage(%s, %s)",
    1478                     biggiestruct.filename, partimagehack_fifo);
     1477                    "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)",
     1478                    biggiestruct.filename, ntfsprog_fifo);
    14791479            res =
    1480                 feed_outfrom_partimage(biggiestruct.filename,
    1481                                        partimagehack_fifo);
     1480                feed_outfrom_ntfsprog(biggiestruct.filename,
     1481                                       ntfsprog_fifo);
    14821482//          log_msg(3, "CHILD - fip - exiting");
    14831483            exit(res);
     
    14851485        default:
    14861486            log_msg(3,
    1487                     "feed_into_partimage() called in background --- pid=%ld",
     1487                    "feed_into_ntfsprog() called in background --- pid=%ld",
    14881488                    (long int) (pid));
    14891489        }
    14901490    } else {
    1491         use_partimage_hack = FALSE;
    1492         partimagehack_fifo[0] = '\0';
     1491        use_ntfsprog_hack = FALSE;
     1492        ntfsprog_fifo[0] = '\0';
    14931493        file_to_openout = outfile_fname;
    14941494        if (!does_file_exist(outfile_fname))    // yes, it looks weird with the '!' but it's correct that way
     
    15171517        return (1);
    15181518    }
    1519     log_msg(3, "Opened out to %s", outfile_fname);  // CD/DVD --> mondorestore --> partimagehack --> hard disk itself
     1519    log_msg(3, "Opened out to %s", outfile_fname);  // CD/DVD --> mondorestore --> ntfsclone --> hard disk itself
    15201520
    15211521    for (sliceno = 1, finished = FALSE; !finished;) {
     
    16261626    g_loglevel = old_loglevel;
    16271627
    1628     if (use_partimage_hack) {
    1629         log_msg(3, "Waiting for partimage to finish");
     1628    if (use_ntfsprog_hack) {
     1629        log_msg(3, "Waiting for ntfsclone to finish");
    16301630        sprintf(tmp,
    1631                 " ps ax | grep \" partimagehack \" | grep -v grep > /dev/null 2> /dev/null");
     1631                " ps ax | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null");
    16321632        while (system(tmp) == 0) {
    16331633            sleep(1);
    16341634        }
    1635         log_it("OK, partimage has really finished");
     1635        log_it("OK, ntfsclone has really finished");
    16361636    }
    16371637
     
    16491649    paranoid_free(tmp);
    16501650    paranoid_free(bzip2_command);
    1651     paranoid_free(partimagehack_command);
     1651    paranoid_free(ntfsprog_command);
    16521652    paranoid_free(suffix);
    16531653    paranoid_free(sz_devfile);
     
    16791679                                     long long biggiefile_size, //UNUSED
    16801680                                     struct s_node *filelist,
    1681                                      int use_partimagehack,
     1681                                     int use_ntfsprog,
    16821682                                     char *pathname_of_last_file_restored)
    16831683{
     
    16891689    char *command;
    16901690    char *outfile_fname;
    1691     char *partimagehack_command;
     1691    char *ntfsprog_command;
    16921692    char *sz_devfile;
    1693     char *partimagehack_fifo;
     1693    char *ntfsprog_fifo;
    16941694    char *file_to_openout = NULL;
    16951695
     
    17031703    long long slice_siz;
    17041704    bool dummy_restore = FALSE;
    1705     bool use_partimage_hack = FALSE;
     1705    bool use_ntfsprog_hack = FALSE;
    17061706    pid_t pid;
    17071707    struct s_filename_and_lstat_info biggiestruct;
     
    17101710
    17111711    malloc_string(tmp);
    1712     malloc_string(partimagehack_fifo);
     1712    malloc_string(ntfsprog_fifo);
    17131713    malloc_string(outfile_fname);
    17141714    malloc_string(command);
    17151715    malloc_string(sz_devfile);
    1716     malloc_string(partimagehack_command);
     1716    malloc_string(ntfsprog_command);
    17171717    old_loglevel = g_loglevel;
    17181718    assert(bkpinfo != NULL);
     
    17211721
    17221722    pathname_of_last_file_restored[0] = '\0';
    1723     if (use_partimagehack == BLK_START_A_PIHBIGGIE) {
    1724         use_partimagehack = 1;
     1723    if (use_ntfsprog == BLK_START_A_PIHBIGGIE) {
     1724        use_ntfsprog = 1;
    17251725        log_msg(1, "%s --- pih=YES", orig_bf_fname);
    1726     } else if (use_partimagehack == BLK_START_A_NORMBIGGIE) {
    1727         use_partimagehack = 0;
     1726    } else if (use_ntfsprog == BLK_START_A_NORMBIGGIE) {
     1727        use_ntfsprog = 0;
    17281728        log_msg(1, "%s --- pih=NO", orig_bf_fname);
    17291729    } else {
    1730         use_partimagehack = 0;
     1730        use_ntfsprog = 0;
    17311731        log_msg(1, "%s --- pih=NO (weird marker though)", orig_bf_fname);
    17321732    }
     
    17541754    }
    17551755
    1756     if (use_partimagehack) {
     1756    if (use_ntfsprog) {
    17571757        if (strncmp(orig_bf_fname, "/dev/", 5)) {
    17581758            log_msg(1,
    1759                     "I was in error when I set use_partimagehack to TRUE.");
     1759                    "I was in error when I set use_ntfsprog to TRUE.");
    17601760            log_msg(1, "%s isn't even in /dev", orig_bf_fname);
    1761             use_partimagehack = FALSE;
    1762         }
    1763     }
    1764 
    1765     if (use_partimagehack) {
     1761            use_ntfsprog = FALSE;
     1762        }
     1763    }
     1764
     1765    if (use_ntfsprog) {
    17661766        g_loglevel = 4;
    17671767        strcpy(outfile_fname, orig_bf_fname);
    1768         use_partimage_hack = TRUE;
     1768        use_ntfsprog_hack = TRUE;
    17691769        log_msg(2,
    1770                 "Calling partimagehack in background because %s is a /dev entry",
     1770                "Calling ntfsclone in background because %s is a /dev entry",
    17711771                outfile_fname);
    17721772        sprintf(sz_devfile, "/tmp/%d.%d.000", (int) (random() % 32768),
    17731773                (int) (random() % 32768));
    17741774        mkfifo(sz_devfile, 0x770);
    1775         strcpy(partimagehack_fifo, sz_devfile);
    1776         file_to_openout = partimagehack_fifo;
     1775        strcpy(ntfsprog_fifo, sz_devfile);
     1776        file_to_openout = ntfsprog_fifo;
    17771777        switch (pid = fork()) {
    17781778        case -1:
     
    17801780        case 0:
    17811781            log_msg(3,
    1782                     "CHILD - fip - calling feed_outfrom_partimage(%s, %s)",
    1783                     outfile_fname, partimagehack_fifo);
     1782                    "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)",
     1783                    outfile_fname, ntfsprog_fifo);
    17841784            res =
    1785                 feed_outfrom_partimage(outfile_fname, partimagehack_fifo);
     1785                feed_outfrom_ntfsprog(outfile_fname, ntfsprog_fifo);
    17861786//          log_msg(3, "CHILD - fip - exiting");
    17871787            exit(res);
     
    17891789        default:
    17901790            log_msg(3,
    1791                     "feed_into_partimage() called in background --- pid=%ld",
     1791                    "feed_into_ntfsprog() called in background --- pid=%ld",
    17921792                    (long int) (pid));
    17931793        }
     
    18011801                    orig_bf_fname);
    18021802        }
    1803         use_partimage_hack = FALSE;
    1804         partimagehack_fifo[0] = '\0';
     1803        use_ntfsprog_hack = FALSE;
     1804        ntfsprog_fifo[0] = '\0';
    18051805        file_to_openout = outfile_fname;
    18061806        if (!does_file_exist(outfile_fname))    // yes, it looks weird with the '!' but it's correct that way
     
    18791879            pathname_of_last_file_restored);
    18801880
    1881     if (use_partimage_hack) {
    1882         log_msg(3, "Waiting for partimage to finish");
     1881    if (use_ntfsprog_hack) {
     1882        log_msg(3, "Waiting for ntfsclone to finish");
    18831883        sprintf(tmp,
    1884                 " ps ax | grep \" partimagehack \" | grep -v grep > /dev/null 2> /dev/null");
     1884                " ps ax | grep \" ntfsclone \" | grep -v grep > /dev/null 2> /dev/null");
    18851885        while (system(tmp) == 0) {
    18861886            sleep(1);
    18871887        }
    1888         log_msg(3, "OK, partimage has really finished");
     1888        log_msg(3, "OK, ntfsclone has really finished");
    18891889    }
    18901890
     
    19031903    paranoid_free(outfile_fname);
    19041904    paranoid_free(command);
    1905     paranoid_free(partimagehack_command);
     1905    paranoid_free(ntfsprog_command);
    19061906    paranoid_free(sz_devfile);
    1907     paranoid_free(partimagehack_fifo);
     1907    paranoid_free(ntfsprog_fifo);
    19081908    g_loglevel = old_loglevel;
    19091909    return (retval);
Note: See TracChangeset for help on using the changeset viewer.