Changeset 116 for branches/2.05


Ignore:
Timestamp:
Nov 8, 2005, 11:54:46 PM (14 years ago)
Author:
bcornec
Message:

merge -r103:115 of branch 2.04_berlios (andree patches)

Location:
branches/2.05
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/2.05/mindi/rootfs/sbin/init

    r47 r116  
    622622#    HandleCDROMorFloppies
    623623#el
    624 if [ "`cat /tmp/mondo-restore.cfg | grep "tape"`" ] || [ "`cat /tmp/mondo-restore.cfg | grep udev`" ] ; then
     624if [ "`cat /tmp/mondo-restore.cfg | grep "tape "`" ] || [ "`cat /tmp/mondo-restore.cfg | grep udev`" ] ; then
    625625    HandleTape
    626626else
  • branches/2.05/mindi/rootfs/sbin/install-additional-tools

    r30 r116  
    111111# Was disabled in mid-March 2002 (?). Dunno why. Re-enabled July 11th, 2002.
    112112for path in /sbin /bin /usr/bin /usr/sbin /lib /usr/lib /lib/* /usr/lib/* ; do
    113     mkdir -p $path
     113    [ ! -e "$path" ] && mkdir -p "$path"
    114114    for i in `ls $mountdir/$path 2> /dev/null` ; do
    115115    rm -f $path/$i 2> /dev/null
  • branches/2.05/mondo/mondo/common/libmondo-files.c

    r30 r116  
    11/* libmondo-files.c                                  file manipulation
    2    $Id: libmondo-files.c,v 1.5 2004/06/10 15:29:12 hugo Exp $
     2   $Id$
    33.
    44
     
    9797
    9898/*@unused@*/
    99 //static char cvsid[] = "$Id: libmondo-files.c,v 1.5 2004/06/10 15:29:12 hugo Exp $";
     99//static char cvsid[] = "$Id$";
    100100
    101101extern char err_log_lines[NOOF_ERR_LINES][MAX_STR_LEN];
     
    114114 * @note The returned string points to static storage that will be overwritten with each call.
    115115 */
    116 char *
    117 calc_checksum_of_file (char *filename)
    118 {
    119     /*@ buffers ******************************************************/
    120   static char output[MAX_STR_LEN];
    121   char command[MAX_STR_LEN*2];
    122   char tmp[MAX_STR_LEN];
    123 
    124     /*@ pointers *****************************************************/
    125   char *p;
    126   FILE *fin;
    127 
    128     /*@ initialize pointers ******************************************/
    129 
    130   p = output;
    131 
    132     /*@***************************************************************/
    133 
    134   assert_string_is_neither_NULL_nor_zerolength(filename);
    135   if (does_file_exist (filename))
    136     {
    137       sprintf (command, "md5sum \"%s\"", filename);
    138       fin = popen (command, "r");
    139       if (fin)
    140     {
    141       (void) fgets (output, MAX_STR_LEN, fin);
    142       p = strchr (output, ' ');
    143       paranoid_pclose (fin);
    144     }
    145     }
    146   else
    147     {
    148       sprintf (tmp, "File '%s' not found; cannot calc checksum", filename);
    149       log_it (tmp);
    150     }
    151   if (p)
    152     {
    153       *p = '\0';
    154     }
    155   return (output);
     116char *calc_checksum_of_file(char *filename)
     117{
     118    /*@ buffers ***************************************************** */
     119    static char output[MAX_STR_LEN];
     120    char command[MAX_STR_LEN * 2];
     121    char tmp[MAX_STR_LEN];
     122
     123    /*@ pointers **************************************************** */
     124    char *p;
     125    FILE *fin;
     126
     127    /*@ initialize pointers ***************************************** */
     128
     129    p = output;
     130
     131    /*@************************************************************** */
     132
     133    assert_string_is_neither_NULL_nor_zerolength(filename);
     134    if (does_file_exist(filename)) {
     135        sprintf(command, "md5sum \"%s\"", filename);
     136        fin = popen(command, "r");
     137        if (fin) {
     138            (void) fgets(output, MAX_STR_LEN, fin);
     139            p = strchr(output, ' ');
     140            paranoid_pclose(fin);
     141        }
     142    } else {
     143        sprintf(tmp, "File '%s' not found; cannot calc checksum",
     144                filename);
     145        log_it(tmp);
     146    }
     147    if (p) {
     148        *p = '\0';
     149    }
     150    return (output);
    156151}
    157152
     
    164159 * @note The returned string points to static storage that will be overwritten with each call.
    165160 */
    166 char *
    167 calc_file_ugly_minichecksum (char *curr_fname)
    168 {
    169 
    170     /*@ buffers ******************************************************/
    171   static char curr_cksum[1000];
    172 
    173     /*@ pointers *****************************************************/
    174 
    175     /*@ structures ***************************************************/
    176   struct stat buf;
    177 
    178   /*@ initialize data ****************************************************/
    179   curr_cksum[0] = '\0';
    180 
    181     /*@***************************************************************/
    182 
    183   assert_string_is_neither_NULL_nor_zerolength(curr_fname);
    184   if (lstat (curr_fname, &buf))
    185     {
    186       return (curr_cksum); // empty
    187     }
    188 
    189   sprintf (curr_cksum, "%ld-%ld-%ld", (long) (buf.st_size),
    190        (long) (buf.st_mtime), (long) (buf.st_ctime));
    191   return (curr_cksum);
     161char *calc_file_ugly_minichecksum(char *curr_fname)
     162{
     163
     164    /*@ buffers ***************************************************** */
     165    static char curr_cksum[1000];
     166
     167    /*@ pointers **************************************************** */
     168
     169    /*@ structures ************************************************** */
     170    struct stat buf;
     171
     172    /*@ initialize data *************************************************** */
     173    curr_cksum[0] = '\0';
     174
     175    /*@************************************************************** */
     176
     177    assert_string_is_neither_NULL_nor_zerolength(curr_fname);
     178    if (lstat(curr_fname, &buf)) {
     179        return (curr_cksum);    // empty
     180    }
     181
     182    sprintf(curr_cksum, "%ld-%ld-%ld", (long) (buf.st_size),
     183            (long) (buf.st_mtime), (long) (buf.st_ctime));
     184    return (curr_cksum);
    192185}
    193186
     
    200193 * @bug This function uses the shell and "wc -l"; it should probably be rewritten in C.
    201194 */
    202 long
    203 count_lines_in_file (char *filename)
    204 {
    205 
    206     /*@ buffers ******************************************************/
    207   char command[MAX_STR_LEN*2];
    208   char incoming[MAX_STR_LEN];
    209   char tmp[MAX_STR_LEN];
    210 
    211     /*@ long *********************************************************/
    212   long noof_lines = -1L;
    213 
    214     /*@ pointers *****************************************************/
    215   FILE *fin;
    216 
    217   /*@ initialize [0] to null *********************************************/
    218   incoming[0] = '\0';
    219 
    220   assert_string_is_neither_NULL_nor_zerolength(filename);
    221   if (!does_file_exist (filename))
    222     {
    223       sprintf (tmp,
    224            "%s does not exist, so I cannot found the number of lines in it",
    225            filename);
    226       log_it (tmp);
    227       return (0);
    228     }
    229   sprintf (command, "cat %s | wc -l", filename);
    230   if (!does_file_exist(filename)) { return(-1); }
    231   fin = popen (command, "r");
    232   if (fin)
    233     {
    234       if (feof (fin))
    235     {
    236       noof_lines = 0;
    237     }
    238       else
    239     {
    240       (void) fgets (incoming, MAX_STR_LEN - 1, fin);
    241       while (strlen (incoming) > 0
    242          && incoming[strlen (incoming) - 1] < 32)
    243         {
    244           incoming[strlen (incoming) - 1] = '\0';
    245         }
    246       noof_lines = atol (incoming);
    247     }
    248       paranoid_pclose (fin);
    249     }
    250   return (noof_lines);
     195long count_lines_in_file(char *filename)
     196{
     197
     198    /*@ buffers ***************************************************** */
     199    char command[MAX_STR_LEN * 2];
     200    char incoming[MAX_STR_LEN];
     201    char tmp[MAX_STR_LEN];
     202
     203    /*@ long ******************************************************** */
     204    long noof_lines = -1L;
     205
     206    /*@ pointers **************************************************** */
     207    FILE *fin;
     208
     209    /*@ initialize [0] to null ******************************************** */
     210    incoming[0] = '\0';
     211
     212    assert_string_is_neither_NULL_nor_zerolength(filename);
     213    if (!does_file_exist(filename)) {
     214        sprintf(tmp,
     215                "%s does not exist, so I cannot found the number of lines in it",
     216                filename);
     217        log_it(tmp);
     218        return (0);
     219    }
     220    sprintf(command, "cat %s | wc -l", filename);
     221    if (!does_file_exist(filename)) {
     222        return (-1);
     223    }
     224    fin = popen(command, "r");
     225    if (fin) {
     226        if (feof(fin)) {
     227            noof_lines = 0;
     228        } else {
     229            (void) fgets(incoming, MAX_STR_LEN - 1, fin);
     230            while (strlen(incoming) > 0
     231                   && incoming[strlen(incoming) - 1] < 32) {
     232                incoming[strlen(incoming) - 1] = '\0';
     233            }
     234            noof_lines = atol(incoming);
     235        }
     236        paranoid_pclose(fin);
     237    }
     238    return (noof_lines);
    251239}
    252240
     
    257245 * @return TRUE if it exists, FALSE otherwise.
    258246 */
    259 bool
    260 does_file_exist (char *filename)
    261 {
    262 
    263     /*@ structures ***************************************************/
    264   struct stat buf;
    265 
    266     /*@***************************************************************/
    267 
    268   assert(filename!=NULL);
    269   //  assert_string_is_neither_NULL_nor_zerolength(filename);
    270   if (lstat (filename, &buf))
    271     {
    272       log_msg(20, "%s does not exist", filename);
    273       return (FALSE);
    274     }
    275   else
    276     {
    277       log_msg(20, "%s exists", filename);
    278       return (TRUE);
    279     }
     247bool does_file_exist(char *filename)
     248{
     249
     250    /*@ structures ************************************************** */
     251    struct stat buf;
     252
     253    /*@************************************************************** */
     254
     255    assert(filename != NULL);
     256    //  assert_string_is_neither_NULL_nor_zerolength(filename);
     257    if (lstat(filename, &buf)) {
     258        log_msg(20, "%s does not exist", filename);
     259        return (FALSE);
     260    } else {
     261        log_msg(20, "%s exists", filename);
     262        return (TRUE);
     263    }
    280264}
    281265
     
    292276 * while the modification is in progress.
    293277 */
    294 void
    295 exclude_nonexistent_files (char *inout)
    296 {
    297   char infname[MAX_STR_LEN];
    298   char outfname[MAX_STR_LEN];
    299   char tmp[MAX_STR_LEN];
    300   char incoming[MAX_STR_LEN];
    301 
    302     /*@ int **********************************************************/
    303   int i;
    304 
    305     /*@ pointers *****************************************************/
    306   FILE *fin, *fout;
    307 
    308 
    309  /*@ end vars ************************************************************/
    310 
    311   assert_string_is_neither_NULL_nor_zerolength(inout);
    312   sprintf (infname, "%s.in", inout);
    313   sprintf (outfname, "%s", inout);
    314   sprintf (tmp, "cp -f %s %s", inout, infname);
    315   run_program_and_log_output (tmp, FALSE);
    316   if (!(fin = fopen (infname, "r"))) { log_OS_error("Unable to openin infname"); return; }
    317   if (!(fout = fopen (outfname, "w"))){log_OS_error("Unable to openout outfname"); return; }
    318   for (fgets (incoming, MAX_STR_LEN, fin); !feof (fin);
    319        fgets (incoming, MAX_STR_LEN, fin))
    320     {
    321       i = strlen (incoming) - 1;
    322       if (i >= 0 && incoming[i] < 32)
    323     {
    324       incoming[i] = '\0';
    325     }
    326       if (does_file_exist (incoming))
    327     {
    328       fprintf (fout, "%s\n", incoming);
    329     }
    330       else
    331     {
    332       sprintf (tmp, "Excluding '%s'-nonexistent\n", incoming);
    333       log_it (tmp);
    334     }
    335     }
    336   paranoid_fclose (fout);
    337   paranoid_fclose (fin);
    338   unlink (infname);
     278void exclude_nonexistent_files(char *inout)
     279{
     280    char infname[MAX_STR_LEN];
     281    char outfname[MAX_STR_LEN];
     282    char tmp[MAX_STR_LEN];
     283    char incoming[MAX_STR_LEN];
     284
     285    /*@ int ********************************************************* */
     286    int i;
     287
     288    /*@ pointers **************************************************** */
     289    FILE *fin, *fout;
     290
     291
     292    /*@ end vars *********************************************************** */
     293
     294    assert_string_is_neither_NULL_nor_zerolength(inout);
     295    sprintf(infname, "%s.in", inout);
     296    sprintf(outfname, "%s", inout);
     297    sprintf(tmp, "cp -f %s %s", inout, infname);
     298    run_program_and_log_output(tmp, FALSE);
     299    if (!(fin = fopen(infname, "r"))) {
     300        log_OS_error("Unable to openin infname");
     301        return;
     302    }
     303    if (!(fout = fopen(outfname, "w"))) {
     304        log_OS_error("Unable to openout outfname");
     305        return;
     306    }
     307    for (fgets(incoming, MAX_STR_LEN, fin); !feof(fin);
     308         fgets(incoming, MAX_STR_LEN, fin)) {
     309        i = strlen(incoming) - 1;
     310        if (i >= 0 && incoming[i] < 32) {
     311            incoming[i] = '\0';
     312        }
     313        if (does_file_exist(incoming)) {
     314            fprintf(fout, "%s\n", incoming);
     315        } else {
     316            sprintf(tmp, "Excluding '%s'-nonexistent\n", incoming);
     317            log_it(tmp);
     318        }
     319    }
     320    paranoid_fclose(fout);
     321    paranoid_fclose(fin);
     322    unlink(infname);
    339323}
    340324
     
    354338 * @return 0 for success, 1 for failure.
    355339 */
    356 int figure_out_kernel_path_interactively_if_necessary(char*kernel)
    357 {
    358   char tmp[MAX_STR_LEN];
    359 
    360       if (!kernel[0])
    361         { strcpy(kernel, call_program_and_get_last_line_of_output("mindi --findkernel 2> /dev/null")); }
    362       log_it("Calling Mindi with kernel path of '%s'", kernel);
    363       while(!kernel[0])
    364         {
    365           if (!ask_me_yes_or_no("Kernel not found or invalid. Choose another?"))
    366             { return(1); }
    367           if (!popup_and_get_string("Kernel path", "What is the full path and filename of your kernel, please?", kernel, MAX_STR_LEN/4))
    368             { fatal_error("Kernel not found. Please specify with the '-k' flag."); }
    369           sprintf(tmp, "User says kernel is at %s", kernel);
    370           log_it(tmp);
    371         }
    372       return(0);
     340int figure_out_kernel_path_interactively_if_necessary(char *kernel)
     341{
     342    char tmp[MAX_STR_LEN];
     343
     344    if (!kernel[0]) {
     345        strcpy(kernel,
     346               call_program_and_get_last_line_of_output
     347               ("mindi --findkernel 2> /dev/null"));
     348    }
     349    log_it("Calling Mindi with kernel path of '%s'", kernel);
     350    while (!kernel[0]) {
     351        if (!ask_me_yes_or_no
     352            ("Kernel not found or invalid. Choose another?")) {
     353            return (1);
     354        }
     355        if (!popup_and_get_string
     356            ("Kernel path",
     357             "What is the full path and filename of your kernel, please?",
     358             kernel, MAX_STR_LEN / 4)) {
     359            fatal_error
     360                ("Kernel not found. Please specify with the '-k' flag.");
     361        }
     362        sprintf(tmp, "User says kernel is at %s", kernel);
     363        log_it(tmp);
     364    }
     365    return (0);
    373366}
    374367
     
    387380 * to nothing.
    388381 */
    389 char *
    390 find_home_of_exe (char *fname)
    391 {
    392     /*@ buffers **********************/
    393   static char output[MAX_STR_LEN];
    394   char *incoming;
    395   char *command;
    396 
    397   malloc_string(incoming);
    398   malloc_string(command);
    399   incoming[0] = '\0';
    400  /*@********************************/
    401 
    402   assert_string_is_neither_NULL_nor_zerolength(fname);
    403   sprintf (command, "which %s 2> /dev/null", fname);
    404   strcpy (incoming, call_program_and_get_last_line_of_output (command));
    405   if (incoming[0] == '\0')
    406     {
    407       if (system("which file > /dev/null 2> /dev/null"))
     382char *find_home_of_exe(char *fname)
     383{
     384    /*@ buffers ********************* */
     385    static char output[MAX_STR_LEN];
     386    char *incoming;
     387    char *command;
     388
     389    malloc_string(incoming);
     390    malloc_string(command);
     391    incoming[0] = '\0';
     392    /*@******************************* */
     393
     394    assert_string_is_neither_NULL_nor_zerolength(fname);
     395    sprintf(command, "which %s 2> /dev/null", fname);
     396    strcpy(incoming, call_program_and_get_last_line_of_output(command));
     397    if (incoming[0] == '\0') {
     398        if (system("which file > /dev/null 2> /dev/null")) {
     399            paranoid_free(incoming);
     400            paranoid_free(command);
     401            output[0] = '\0';
     402            return (NULL);      // forget it :)
     403        }
     404        sprintf(command,
     405                "file %s 2> /dev/null | cut -d':' -f1 2> /dev/null",
     406                incoming);
     407        strcpy(incoming,
     408               call_program_and_get_last_line_of_output(command));
     409    }
     410    if (incoming[0] == '\0')    // yes, it is == '\0' twice, not once :)
    408411    {
    409       paranoid_free(incoming);
    410       paranoid_free(command);
    411       output[0] = '\0'; return(NULL); // forget it :)
    412     }
    413       sprintf (command, "file %s 2> /dev/null | cut -d':' -f1 2> /dev/null", incoming);
    414       strcpy (incoming, call_program_and_get_last_line_of_output (command));
    415     }
    416   if (incoming[0] == '\0') // yes, it is == '\0' twice, not once :)
    417     {
    418       sprintf (command, "dirname %s 2> /dev/null", incoming);
    419       strcpy (incoming, call_program_and_get_last_line_of_output (command));
    420     }
    421   strcpy (output, incoming);
    422   if (output[0] != '\0' && does_file_exist(output))
    423     { log_msg(4, "find_home_of_exe () --- Found %s at %s", fname, incoming); }
    424   else
    425     { output[0]='\0'; log_msg(4, "find_home_of_exe() --- Could not find %s", fname); }
    426   paranoid_free(incoming);
    427   paranoid_free(command);
    428   if (!output[0]) { return(NULL); } else { return (output); }
     412        sprintf(command, "dirname %s 2> /dev/null", incoming);
     413        strcpy(incoming,
     414               call_program_and_get_last_line_of_output(command));
     415    }
     416    strcpy(output, incoming);
     417    if (output[0] != '\0' && does_file_exist(output)) {
     418        log_msg(4, "find_home_of_exe () --- Found %s at %s", fname,
     419                incoming);
     420    } else {
     421        output[0] = '\0';
     422        log_msg(4, "find_home_of_exe() --- Could not find %s", fname);
     423    }
     424    paranoid_free(incoming);
     425    paranoid_free(command);
     426    if (!output[0]) {
     427        return (NULL);
     428    } else {
     429        return (output);
     430    }
    429431}
    430432
     
    442444 * @return The number found, or 0 if none.
    443445 */
    444 int
    445 get_trackno_from_logfile (char *logfile)
    446 {
    447 
    448     /*@ pointers **********************************************************/
    449   FILE *fin;
    450 
    451     /*@ int ***************************************************************/
    452   int trackno   = 0;
    453   size_t len    = 0;
    454 
    455     /*@ buffer *************************************************************/
    456   char datablock[32701];
    457 
    458   assert_string_is_neither_NULL_nor_zerolength(logfile);
    459   if (!(fin = fopen (logfile, "r"))) { log_OS_error("Unable to open logfile"); fatal_error("Unable to open logfile to read trackno"); }
    460   len = fread (datablock, 1, 32700, fin);
    461   paranoid_fclose (fin);
    462   if (len <= 0)
    463     {
    464       return (0);
    465     }
    466   for (; len > 0 && !isdigit (datablock[len - 1]); len--);
    467   datablock[len--] = '\0';
    468   for (; len > 0 && isdigit (datablock[len - 1]); len--);
    469   trackno = atoi (datablock + len);
    470   /*
    471      sprintf(tmp,"datablock=%s; trackno=%d",datablock+len, trackno);
    472      log_it(tmp);
    473    */
    474   return (trackno);
     446int get_trackno_from_logfile(char *logfile)
     447{
     448
     449    /*@ pointers ********************************************************* */
     450    FILE *fin;
     451
     452    /*@ int ************************************************************** */
     453    int trackno = 0;
     454    size_t len = 0;
     455
     456    /*@ buffer ************************************************************ */
     457    char datablock[32701];
     458
     459    assert_string_is_neither_NULL_nor_zerolength(logfile);
     460    if (!(fin = fopen(logfile, "r"))) {
     461        log_OS_error("Unable to open logfile");
     462        fatal_error("Unable to open logfile to read trackno");
     463    }
     464    len = fread(datablock, 1, 32700, fin);
     465    paranoid_fclose(fin);
     466    if (len <= 0) {
     467        return (0);
     468    }
     469    for (; len > 0 && !isdigit(datablock[len - 1]); len--);
     470    datablock[len--] = '\0';
     471    for (; len > 0 && isdigit(datablock[len - 1]); len--);
     472    trackno = atoi(datablock + len);
     473    /*
     474       sprintf(tmp,"datablock=%s; trackno=%d",datablock+len, trackno);
     475       log_it(tmp);
     476     */
     477    return (trackno);
    475478}
    476479
     
    487490 * @return The percentage found, or 0 for error.
    488491 */
    489 int
    490 grab_percentage_from_last_line_of_file (char *filename)
    491 {
    492 
    493     /*@ buffers ******************************************************/
    494   char tmp[MAX_STR_LEN];
    495   char lastline[MAX_STR_LEN];
    496   char command[MAX_STR_LEN];
    497     /*@ pointers *****************************************************/
    498   char *p;
    499 
    500     /*@ int's ********************************************************/
    501   int i;
    502 
    503   for(i=NOOF_ERR_LINES-1; i>=0 && !strstr(err_log_lines[i], "% Done") && !strstr(err_log_lines[i], "% done"); i--);
    504   if (i<0)
    505     {
    506       sprintf(command, "tail -n3 %s | fgrep -i \"%c\" | tail -n1 | awk '{print $0;}'", filename, '%');
    507       strcpy(lastline, call_program_and_get_last_line_of_output(command));
    508       if (!lastline[0])
    509     {
    510       return(0);
    511     }
    512     }
    513   else
    514     {
    515       strcpy(lastline, err_log_lines[i]);
    516     }
    517 
    518   p = strrchr(lastline, '%');
    519   if (p) { *p='\0'; }
     492int grab_percentage_from_last_line_of_file(char *filename)
     493{
     494
     495    /*@ buffers ***************************************************** */
     496    char tmp[MAX_STR_LEN];
     497    char lastline[MAX_STR_LEN];
     498    char command[MAX_STR_LEN];
     499    /*@ pointers **************************************************** */
     500    char *p;
     501
     502    /*@ int's ******************************************************* */
     503    int i;
     504
     505    for (i = NOOF_ERR_LINES - 1;
     506         i >= 0 && !strstr(err_log_lines[i], "% Done")
     507         && !strstr(err_log_lines[i], "% done"); i--);
     508    if (i < 0) {
     509        sprintf(command,
     510                "tail -n3 %s | fgrep -i \"%c\" | tail -n1 | awk '{print $0;}'",
     511                filename, '%');
     512        strcpy(lastline,
     513               call_program_and_get_last_line_of_output(command));
     514        if (!lastline[0]) {
     515            return (0);
     516        }
     517    } else {
     518        strcpy(lastline, err_log_lines[i]);
     519    }
     520
     521    p = strrchr(lastline, '%');
     522    if (p) {
     523        *p = '\0';
     524    }
    520525//  log_msg(2, "lastline='%s', ", p, lastline);
    521   if (!p)
    522     {
    523       return (0);
    524     }
    525   *p = '\0';
    526   for (p --; *p != ' ' && p != lastline; p--);
    527   if (p != lastline)
    528     {
    529       p++;
    530     }
    531   i = atoi (p);
    532 
    533      sprintf(tmp,"'%s' --> %d",p,i);
     526    if (!p) {
     527        return (0);
     528    }
     529    *p = '\0';
     530    for (p--; *p != ' ' && p != lastline; p--);
     531    if (p != lastline) {
     532        p++;
     533    }
     534    i = atoi(p);
     535
     536    sprintf(tmp, "'%s' --> %d", p, i);
    534537//     log_to_screen(tmp);
    535538
    536   return (i);
     539    return (i);
    537540}
    538541
     
    547550 * @note The returned string points to static storage that will be overwritten with each call.
    548551 */
    549 char *
    550 last_line_of_file (char *filename)
    551 {
    552     /*@ buffers ******************************************************/
    553   static char output[MAX_STR_LEN];
    554   static char command[MAX_STR_LEN*2];
    555   static char tmp[MAX_STR_LEN];
    556 
    557     /*@ pointers *****************************************************/
    558   FILE *fin;
    559 
    560     /*@ end vars *****************************************************/
    561 
    562   if (!does_file_exist (filename))
    563     {
    564       sprintf (tmp, "Tring to get last line of nonexistent file (%s)",
    565            filename);
    566       log_it (tmp);
    567       output[0] = '\0';
    568       return (output);
    569     }
    570   sprintf (command, "cat %s | tail -n1", filename);
    571   fin = popen (command, "r");
    572   (void) fgets (output, MAX_STR_LEN, fin);
    573   paranoid_pclose (fin);
    574   while (strlen (output) > 0 && output[strlen (output) - 1] < 32)
    575     {
    576       output[strlen (output) - 1] = '\0';
    577     }
    578   return (output);
     552char *last_line_of_file(char *filename)
     553{
     554    /*@ buffers ***************************************************** */
     555    static char output[MAX_STR_LEN];
     556    static char command[MAX_STR_LEN * 2];
     557    static char tmp[MAX_STR_LEN];
     558
     559    /*@ pointers **************************************************** */
     560    FILE *fin;
     561
     562    /*@ end vars **************************************************** */
     563
     564    if (!does_file_exist(filename)) {
     565        sprintf(tmp, "Tring to get last line of nonexistent file (%s)",
     566                filename);
     567        log_it(tmp);
     568        output[0] = '\0';
     569        return (output);
     570    }
     571    sprintf(command, "cat %s | tail -n1", filename);
     572    fin = popen(command, "r");
     573    (void) fgets(output, MAX_STR_LEN, fin);
     574    paranoid_pclose(fin);
     575    while (strlen(output) > 0 && output[strlen(output) - 1] < 32) {
     576        output[strlen(output) - 1] = '\0';
     577    }
     578    return (output);
    579579}
    580580
     
    584584 * @return The length of the file, or -1 for error.
    585585 */
    586 long long
    587 length_of_file (char *filename)
    588 {
    589     /*@ pointers ****************************************************/
    590   FILE *fin;
    591 
    592     /*@ long long **************************************************/
    593   long long length;
    594 
    595   fin = fopen (filename, "r");
    596   if (!fin)
    597     {
    598       log_it("filename=%s", filename);
    599       log_OS_error("Unable to openin filename");
    600       return (-1);
    601     }
    602   fseek (fin, 0, SEEK_END);
    603   length = ftell (fin);
    604   paranoid_fclose (fin);
    605   return (length);
     586long long length_of_file(char *filename)
     587{
     588    /*@ pointers *************************************************** */
     589    FILE *fin;
     590
     591    /*@ long long ************************************************* */
     592    long long length;
     593
     594    fin = fopen(filename, "r");
     595    if (!fin) {
     596        log_it("filename=%s", filename);
     597        log_OS_error("Unable to openin filename");
     598        return (-1);
     599    }
     600    fseek(fin, 0, SEEK_END);
     601    length = ftell(fin);
     602    paranoid_fclose(fin);
     603    return (length);
    606604}
    607605
     
    613611 */
    614612int
    615 make_checksum_list_file (char *filelist, char *cksumlist, char *comppath)
    616 {
    617     /*@ pointers *****************************************************/
    618   FILE *fin;
    619   FILE *fout;
    620 
    621     /*@ int   ********************************************************/
    622   int percentage;
    623   int i;
    624   int counter = 0;
    625 
    626     /*@ buffer *******************************************************/
    627   char stub_fname[1000];
    628   char curr_fname[1000];
    629   char curr_cksum[1000];
    630   char tmp[1000];
    631 
    632         /*@ long [long] **************************************************/
    633   long long filelist_length;
    634   long curr_pos;
    635   long start_time;
    636   long current_time;
    637   long time_taken;
    638   long time_remaining;
    639 
    640     /*@ end vars ****************************************************/
    641 
    642   start_time = get_time ();
    643   filelist_length = length_of_file (filelist);
    644   sprintf (tmp, "filelist = %s; cksumlist = %s", filelist, cksumlist);
    645   log_it (tmp);
    646   fin = fopen (filelist, "r");
    647   if (fin == NULL)
    648     {
    649       log_OS_error ("Unable to fopen-in filelist");
    650       log_to_screen ("Can't open filelist");
    651       return (1);
    652     }
    653   fout = fopen (cksumlist, "w");
    654   if (fout == NULL)
    655     {
    656       log_OS_error ("Unable to openout cksumlist");
    657       paranoid_fclose (fin);
    658       log_to_screen ("Can't open checksum list");
    659       return (1);
    660     }
    661   for (fgets (stub_fname, 999, fin); !feof (fin);
    662        fgets (stub_fname, 999, fin))
    663     {
    664       if (stub_fname[(i = strlen (stub_fname) - 1)] < 32)
    665     {
    666       stub_fname[i] = '\0';
    667     }
    668       sprintf (tmp, "%s%s", comppath, stub_fname);
    669       strcpy (curr_fname, tmp + 1);
    670       strcpy (curr_cksum, calc_file_ugly_minichecksum (curr_fname));
    671       fprintf (fout, "%s\t%s\n", curr_fname, curr_cksum);
    672       if (counter++ > 12)
    673     {
    674       current_time = get_time ();
    675       counter = 0;
    676       curr_fname[37] = '\0';
    677       curr_pos = ftell (fin) / 1024;
    678       percentage = (int) (curr_pos * 100 / filelist_length);
    679       time_taken = current_time - start_time;
    680       if (percentage == 0)
    681         {
    682           /*              printf("%0d%% done      \r",percentage); */
    683         }
    684       else
    685         {
    686           time_remaining =
    687         time_taken * 100 / (long) (percentage) - time_taken;
    688           sprintf (tmp,
    689                "%02d%% done   %02d:%02d taken   %02d:%02d remaining  %-37s\r",
    690                percentage, (int) (time_taken / 60),
    691                (int) (time_taken % 60), (int) (time_remaining / 60),
    692                (int) (time_remaining % 60), curr_fname);
    693           log_to_screen (tmp);
    694         }
    695       sync ();
    696     }
    697     }
    698   paranoid_fclose (fout);
    699   paranoid_fclose (fin);
    700   log_it ("Done.");
    701   return (0);
     613make_checksum_list_file(char *filelist, char *cksumlist, char *comppath)
     614{
     615    /*@ pointers **************************************************** */
     616    FILE *fin;
     617    FILE *fout;
     618
     619    /*@ int   ******************************************************* */
     620    int percentage;
     621    int i;
     622    int counter = 0;
     623
     624    /*@ buffer ****************************************************** */
     625    char stub_fname[1000];
     626    char curr_fname[1000];
     627    char curr_cksum[1000];
     628    char tmp[1000];
     629
     630    /*@ long [long] ************************************************* */
     631    long long filelist_length;
     632    long curr_pos;
     633    long start_time;
     634    long current_time;
     635    long time_taken;
     636    long time_remaining;
     637
     638    /*@ end vars *************************************************** */
     639
     640    start_time = get_time();
     641    filelist_length = length_of_file(filelist);
     642    sprintf(tmp, "filelist = %s; cksumlist = %s", filelist, cksumlist);
     643    log_it(tmp);
     644    fin = fopen(filelist, "r");
     645    if (fin == NULL) {
     646        log_OS_error("Unable to fopen-in filelist");
     647        log_to_screen("Can't open filelist");
     648        return (1);
     649    }
     650    fout = fopen(cksumlist, "w");
     651    if (fout == NULL) {
     652        log_OS_error("Unable to openout cksumlist");
     653        paranoid_fclose(fin);
     654        log_to_screen("Can't open checksum list");
     655        return (1);
     656    }
     657    for (fgets(stub_fname, 999, fin); !feof(fin);
     658         fgets(stub_fname, 999, fin)) {
     659        if (stub_fname[(i = strlen(stub_fname) - 1)] < 32) {
     660            stub_fname[i] = '\0';
     661        }
     662        sprintf(tmp, "%s%s", comppath, stub_fname);
     663        strcpy(curr_fname, tmp + 1);
     664        strcpy(curr_cksum, calc_file_ugly_minichecksum(curr_fname));
     665        fprintf(fout, "%s\t%s\n", curr_fname, curr_cksum);
     666        if (counter++ > 12) {
     667            current_time = get_time();
     668            counter = 0;
     669            curr_fname[37] = '\0';
     670            curr_pos = ftell(fin) / 1024;
     671            percentage = (int) (curr_pos * 100 / filelist_length);
     672            time_taken = current_time - start_time;
     673            if (percentage == 0) {
     674                /*              printf("%0d%% done      \r",percentage); */
     675            } else {
     676                time_remaining =
     677                    time_taken * 100 / (long) (percentage) - time_taken;
     678                sprintf(tmp,
     679                        "%02d%% done   %02d:%02d taken   %02d:%02d remaining  %-37s\r",
     680                        percentage, (int) (time_taken / 60),
     681                        (int) (time_taken % 60),
     682                        (int) (time_remaining / 60),
     683                        (int) (time_remaining % 60), curr_fname);
     684                log_to_screen(tmp);
     685            }
     686            sync();
     687        }
     688    }
     689    paranoid_fclose(fout);
     690    paranoid_fclose(fin);
     691    log_it("Done.");
     692    return (0);
    702693}
    703694
     
    708699 * @return The return value of @c mkdir.
    709700 */
    710 int make_hole_for_dir (char*outdir_fname)
    711 {
    712   char tmp[MAX_STR_LEN*2];
    713   int res=0;
    714 
    715   assert_string_is_neither_NULL_nor_zerolength(outdir_fname);
    716   sprintf(tmp, "mkdir -p %s", outdir_fname);
    717   res = system(tmp);
    718   return(res);
     701int make_hole_for_dir(char *outdir_fname)
     702{
     703    char tmp[MAX_STR_LEN * 2];
     704    int res = 0;
     705
     706    assert_string_is_neither_NULL_nor_zerolength(outdir_fname);
     707    sprintf(tmp, "mkdir -p %s", outdir_fname);
     708    res = system(tmp);
     709    return (res);
    719710}
    720711
     
    726717 * @bug Return value unnecessary.
    727718 */
    728 int
    729 make_hole_for_file (char *outfile_fname)
    730 {
    731     /*@ buffer *******************************************************/
    732   char command[MAX_STR_LEN*2];
    733 
    734     /*@ int  *********************************************************/
    735   int res = 0;
    736 
    737     /*@ end vars ****************************************************/
    738 
    739   assert_string_is_neither_NULL_nor_zerolength(outfile_fname);
    740   assert(!strstr(outfile_fname, MNT_CDROM));
    741   assert(!strstr(outfile_fname, "/dev/cdrom"));
    742   sprintf (command, "mkdir -p \"%s\" 2> /dev/null", outfile_fname);
    743   res += system (command);
    744   sprintf (command, "rmdir \"%s\" 2> /dev/null", outfile_fname);
    745   res += system (command);
    746       sprintf (command, "rm -f \"%s\" 2> /dev/null", outfile_fname);
    747   res += system (command);
    748   unlink (outfile_fname);
    749   return (0);
     719int make_hole_for_file(char *outfile_fname)
     720{
     721    /*@ buffer ****************************************************** */
     722    char command[MAX_STR_LEN * 2];
     723
     724    /*@ int  ******************************************************** */
     725    int res = 0;
     726
     727    /*@ end vars *************************************************** */
     728
     729    assert_string_is_neither_NULL_nor_zerolength(outfile_fname);
     730    assert(!strstr(outfile_fname, MNT_CDROM));
     731    assert(!strstr(outfile_fname, "/dev/cdrom"));
     732    sprintf(command, "mkdir -p \"%s\" 2> /dev/null", outfile_fname);
     733    res += system(command);
     734    sprintf(command, "rmdir \"%s\" 2> /dev/null", outfile_fname);
     735    res += system(command);
     736    sprintf(command, "rm -f \"%s\" 2> /dev/null", outfile_fname);
     737    res += system(command);
     738    unlink(outfile_fname);
     739    return (0);
    750740}
    751741
     
    759749 * @return The number of lines matched.
    760750 */
    761 long
    762 noof_lines_that_match_wildcard (char *filelist_fname, char *wildcard)
    763 {
    764     /*@ long ********************************************************/
    765   long matches = 0;
    766 
    767     /*@ pointers ****************************************************/
    768   FILE *fin;
    769 
    770     /*@ buffers *****************************************************/
    771   char incoming[MAX_STR_LEN];
    772 
    773     /*@ end vars ****************************************************/
    774 
    775 
    776   fin = fopen (filelist_fname, "r");
    777 
    778   if (!fin)
    779     {
    780       log_OS_error("Unable to openin filelist_fname");
    781       return (0);
    782     }
    783   (void) fgets (incoming, MAX_STR_LEN - 1, fin);
    784   while (!feof (fin))
    785     {
    786       if (strstr (incoming, wildcard))
    787     {
    788       matches++;
    789     }
    790       (void) fgets (incoming, MAX_STR_LEN - 1, fin);
    791     }
    792   paranoid_fclose (fin);
    793   return (matches);
     751long noof_lines_that_match_wildcard(char *filelist_fname, char *wildcard)
     752{
     753    /*@ long ******************************************************* */
     754    long matches = 0;
     755
     756    /*@ pointers *************************************************** */
     757    FILE *fin;
     758
     759    /*@ buffers **************************************************** */
     760    char incoming[MAX_STR_LEN];
     761
     762    /*@ end vars *************************************************** */
     763
     764
     765    fin = fopen(filelist_fname, "r");
     766
     767    if (!fin) {
     768        log_OS_error("Unable to openin filelist_fname");
     769        return (0);
     770    }
     771    (void) fgets(incoming, MAX_STR_LEN - 1, fin);
     772    while (!feof(fin)) {
     773        if (strstr(incoming, wildcard)) {
     774            matches++;
     775        }
     776        (void) fgets(incoming, MAX_STR_LEN - 1, fin);
     777    }
     778    paranoid_fclose(fin);
     779    return (matches);
    794780}
    795781
     
    804790 * @note This function does not provide support against multiple instances, unless you check for that yourself.
    805791 */
    806 void register_pid(pid_t pid, char*name_str)
    807 {
    808   char tmp[MAX_STR_LEN+1], lockfile_fname[MAX_STR_LEN+1];
    809   int res;
    810   FILE*fin;
    811 
    812   sprintf(lockfile_fname, "/var/run/monitas-%s.pid", name_str);
    813   if (!pid)
    814     {
    815       log_it("Unregistering PID");
    816       if (unlink(lockfile_fname)) { log_it( "Error unregistering PID"); }
    817       return;
    818     }
    819   if (does_file_exist(lockfile_fname))
    820     {
    821       tmp[0]='\0';
    822       if ((fin=fopen(lockfile_fname,"r"))) { (void) fgets(tmp, MAX_STR_LEN, fin); paranoid_fclose(fin); }
    823       else { log_OS_error("Unable to openin lockfile_fname"); }
    824       pid = (pid_t) atol(tmp);
    825       sprintf(tmp, "ps %ld > /dev/null 2> /dev/null", (long int)pid);
    826       res = system(tmp);
    827       if (!res)
    828         {
    829           log_it ("I believe the daemon is already running. If it isn't, please delete %s and try again.", lockfile_fname);
    830         }
    831     }
    832   sprintf(tmp, "echo %ld > %s 2> /dev/null", (long int)getpid(), lockfile_fname);
    833   if (system(tmp)) { fatal_error( "Cannot register PID"); }
     792void register_pid(pid_t pid, char *name_str)
     793{
     794    char tmp[MAX_STR_LEN + 1], lockfile_fname[MAX_STR_LEN + 1];
     795    int res;
     796    FILE *fin;
     797
     798    sprintf(lockfile_fname, "/var/run/monitas-%s.pid", name_str);
     799    if (!pid) {
     800        log_it("Unregistering PID");
     801        if (unlink(lockfile_fname)) {
     802            log_it("Error unregistering PID");
     803        }
     804        return;
     805    }
     806    if (does_file_exist(lockfile_fname)) {
     807        tmp[0] = '\0';
     808        if ((fin = fopen(lockfile_fname, "r"))) {
     809            (void) fgets(tmp, MAX_STR_LEN, fin);
     810            paranoid_fclose(fin);
     811        } else {
     812            log_OS_error("Unable to openin lockfile_fname");
     813        }
     814        pid = (pid_t) atol(tmp);
     815        sprintf(tmp, "ps %ld > /dev/null 2> /dev/null", (long int) pid);
     816        res = system(tmp);
     817        if (!res) {
     818            log_it
     819                ("I believe the daemon is already running. If it isn't, please delete %s and try again.",
     820                 lockfile_fname);
     821        }
     822    }
     823    sprintf(tmp, "echo %ld > %s 2> /dev/null", (long int) getpid(),
     824            lockfile_fname);
     825    if (system(tmp)) {
     826        fatal_error("Cannot register PID");
     827    }
    834828}
    835829
     
    842836 * @return The size of the partition in KB.
    843837 */
    844 long size_of_partition_in_mountlist_K(char*tmpdir, char*dev)
    845 {
    846     char command[MAX_STR_LEN];
    847     char mountlist[MAX_STR_LEN];
    848     char sz_res[MAX_STR_LEN];
    849     long file_len_K;
    850            
    851     sprintf(mountlist, "%s/mountlist.txt", tmpdir);
    852     sprintf (command,
    853        "cat %s/mountlist.txt | grep \"%s \" | head -n1 | awk '{print $4;}'",
    854       tmpdir, dev);
    855     log_it (command);
    856     strcpy (sz_res, call_program_and_get_last_line_of_output (command));
    857     file_len_K = atol (sz_res);
    858     log_msg(4, "%s --> %s --> %ld", command, sz_res, file_len_K);
    859     return(file_len_K);
     838long size_of_partition_in_mountlist_K(char *tmpdir, char *dev)
     839{
     840    char command[MAX_STR_LEN];
     841    char mountlist[MAX_STR_LEN];
     842    char sz_res[MAX_STR_LEN];
     843    long file_len_K;
     844
     845    sprintf(mountlist, "%s/mountlist.txt", tmpdir);
     846    sprintf(command,
     847            "cat %s/mountlist.txt | grep \"%s \" | head -n1 | awk '{print $4;}'",
     848            tmpdir, dev);
     849    log_it(command);
     850    strcpy(sz_res, call_program_and_get_last_line_of_output(command));
     851    file_len_K = atol(sz_res);
     852    log_msg(4, "%s --> %s --> %ld", command, sz_res, file_len_K);
     853    return (file_len_K);
    860854}
    861855
     
    865859 * @return The total size of all biggiefiles in KB.
    866860 */
    867 long
    868 size_of_all_biggiefiles_K (struct s_bkpinfo *bkpinfo)
    869 {
    870     /*@ buffers ******************************************************/
    871   char *fname;
    872   char *biggielist;
    873   char *comment;
    874 
    875     /*@ long *********************************************************/
    876   long scratchL = 0;
    877   long file_len_K;
    878 
    879     /*@ pointers ****************************************************/
    880   FILE *fin=NULL;
    881 
    882     /*@ end vars ****************************************************/
    883 
    884   malloc_string(fname);
    885   malloc_string(biggielist);
    886   malloc_string(comment);
    887   log_it ("Calculating size of all biggiefiles (in total)");
    888   sprintf (biggielist, "%s/biggielist.txt", bkpinfo->tmpdir);
    889   log_it("biggielist = %s", biggielist);
    890   if (!(fin = fopen (biggielist, "r")))
    891     {
    892       log_OS_error
    893     ("Cannot open biggielist. OK, so estimate is based on filesets only.");
    894     }
    895   else
    896     {
    897       log_msg(4, "Reading it...");
    898       for (fgets (fname, MAX_STR_LEN, fin); !feof (fin);
    899        fgets (fname, MAX_STR_LEN, fin))
    900     {
    901       if (fname[strlen(fname)-1]<=32) { fname[strlen(fname)-1]='\0'; }
    902       if (0 == strncmp (fname, "/dev/", 5))
    903         {
    904           file_len_K = get_phys_size_of_drive(fname)*1024L;
    905         }
    906       else
    907         {
    908           file_len_K = (long) (length_of_file (fname) / 1024);
    909         }
    910           if (file_len_K > 0)
    911         {
    912           scratchL += file_len_K;
    913           log_msg(4, "%s --> %ld K", fname, file_len_K);
    914         }
    915       sprintf (comment, "After adding %s, scratchL+%ld now equals %ld",
    916            fname, file_len_K, scratchL);
    917       log_msg(4, comment);
    918           if (feof(fin)) { break; }
    919     }
    920     }
    921   log_it ("Closing...");
    922   paranoid_fclose (fin);
    923   log_it ("Finished calculating total size of all biggiefiles");
    924   paranoid_free(fname);
    925   paranoid_free(biggielist);
    926   paranoid_free(comment);
    927   return (scratchL);
     861long size_of_all_biggiefiles_K(struct s_bkpinfo *bkpinfo)
     862{
     863    /*@ buffers ***************************************************** */
     864    char *fname;
     865    char *biggielist;
     866    char *comment;
     867
     868    /*@ long ******************************************************** */
     869    long scratchL = 0;
     870    long file_len_K;
     871
     872    /*@ pointers *************************************************** */
     873    FILE *fin = NULL;
     874
     875    /*@ end vars *************************************************** */
     876
     877    malloc_string(fname);
     878    malloc_string(biggielist);
     879    malloc_string(comment);
     880    log_it("Calculating size of all biggiefiles (in total)");
     881    sprintf(biggielist, "%s/biggielist.txt", bkpinfo->tmpdir);
     882    log_it("biggielist = %s", biggielist);
     883    if (!(fin = fopen(biggielist, "r"))) {
     884        log_OS_error
     885            ("Cannot open biggielist. OK, so estimate is based on filesets only.");
     886    } else {
     887        log_msg(4, "Reading it...");
     888        for (fgets(fname, MAX_STR_LEN, fin); !feof(fin);
     889             fgets(fname, MAX_STR_LEN, fin)) {
     890            if (fname[strlen(fname) - 1] <= 32) {
     891                fname[strlen(fname) - 1] = '\0';
     892            }
     893            if (0 == strncmp(fname, "/dev/", 5)) {
     894                file_len_K = get_phys_size_of_drive(fname) * 1024L;
     895            } else {
     896                file_len_K = (long) (length_of_file(fname) / 1024);
     897            }
     898            if (file_len_K > 0) {
     899                scratchL += file_len_K;
     900                log_msg(4, "%s --> %ld K", fname, file_len_K);
     901            }
     902            sprintf(comment,
     903                    "After adding %s, scratchL+%ld now equals %ld", fname,
     904                    file_len_K, scratchL);
     905            log_msg(4, comment);
     906            if (feof(fin)) {
     907                break;
     908            }
     909        }
     910    }
     911    log_it("Closing...");
     912    paranoid_fclose(fin);
     913    log_it("Finished calculating total size of all biggiefiles");
     914    paranoid_free(fname);
     915    paranoid_free(biggielist);
     916    paranoid_free(comment);
     917    return (scratchL);
    928918}
    929919
     
    934924 * @return The amount of space occupied in KB.
    935925 */
    936 long long
    937 space_occupied_by_cd (char *mountpt)
    938 {
    939     /*@ buffer *******************************************************/
    940   char tmp[MAX_STR_LEN];
    941   char command[MAX_STR_LEN*2];
    942   long long llres;
    943     /*@ pointers *****************************************************/
    944   char *p;
    945   FILE *fin;
    946 
    947     /*@ end vars ****************************************************/
    948 
    949   sprintf (command, "du -sk %s", mountpt);
    950   fin = popen (command, "r");
    951   (void) fgets (tmp, MAX_STR_LEN, fin);
    952   paranoid_pclose (fin);
    953   p = strchr (tmp, '\t');
    954   if (p)
    955     {
    956       *p = '\0';
    957     }
    958   for(p=tmp,llres=0; *p!='\0'; p++)
    959     {
    960       llres*=10;
    961       llres+=(int)(*p - '0');
    962     }
    963   return (llres);
     926long long space_occupied_by_cd(char *mountpt)
     927{
     928    /*@ buffer ****************************************************** */
     929    char tmp[MAX_STR_LEN];
     930    char command[MAX_STR_LEN * 2];
     931    long long llres;
     932    /*@ pointers **************************************************** */
     933    char *p;
     934    FILE *fin;
     935
     936    /*@ end vars *************************************************** */
     937
     938    sprintf(command, "du -sk %s", mountpt);
     939    fin = popen(command, "r");
     940    (void) fgets(tmp, MAX_STR_LEN, fin);
     941    paranoid_pclose(fin);
     942    p = strchr(tmp, '\t');
     943    if (p) {
     944        *p = '\0';
     945    }
     946    for (p = tmp, llres = 0; *p != '\0'; p++) {
     947        llres *= 10;
     948        llres += (int) (*p - '0');
     949    }
     950    return (llres);
    964951}
    965952
     
    972959 * @ingroup utilityGroup
    973960 */
    974 unsigned int
    975 updcrc (unsigned int crc, unsigned int c)
    976 {
    977   unsigned int tmp;
    978   tmp = (crc >> 8) ^ c;
    979   crc = (crc << 8) ^ crctttab[tmp & 255];
    980   return crc;
     961unsigned int updcrc(unsigned int crc, unsigned int c)
     962{
     963    unsigned int tmp;
     964    tmp = (crc >> 8) ^ c;
     965    crc = (crc << 8) ^ crctttab[tmp & 255];
     966    return crc;
    981967}
    982968
     
    988974 * @ingroup utilityGroup
    989975 */
    990 unsigned int
    991 updcrcr (unsigned int crc, unsigned int c)
    992 {
    993   unsigned int tmp;
    994   tmp = crc ^ c;
    995   crc = (crc >> 8) ^ crc16tab[tmp & 0xff];
    996   return crc;
     976unsigned int updcrcr(unsigned int crc, unsigned int c)
     977{
     978    unsigned int tmp;
     979    tmp = crc ^ c;
     980    crc = (crc >> 8) ^ crc16tab[tmp & 0xff];
     981    return crc;
    997982}
    998983
     
    1006991 * @return 0 if it's found, nonzero if not.
    1007992 */
    1008 int
    1009 whine_if_not_found (char *fname)
    1010 {
    1011     /*@ buffers ****/
    1012   char command[MAX_STR_LEN*2];
    1013   char errorstr[MAX_STR_LEN];
    1014 
    1015 
    1016   sprintf (command, "which %s > /dev/null 2> /dev/null", fname);
    1017   sprintf (errorstr, "Please install '%s'. I cannot find it on your system.",
    1018        fname);
    1019   if (system (command))
    1020     {
    1021       log_to_screen (errorstr);
    1022       log_to_screen
    1023     ("There may be hyperlink at http://www.mondorescue.com which");
    1024       log_to_screen ("will take you to the relevant (missing) package.");
    1025       return (1);
    1026     }
    1027   else
    1028     {
    1029       return (0);
    1030     }
     993int whine_if_not_found(char *fname)
     994{
     995    /*@ buffers *** */
     996    char command[MAX_STR_LEN * 2];
     997    char errorstr[MAX_STR_LEN];
     998
     999
     1000    sprintf(command, "which %s > /dev/null 2> /dev/null", fname);
     1001    sprintf(errorstr,
     1002            "Please install '%s'. I cannot find it on your system.",
     1003            fname);
     1004    if (system(command)) {
     1005        log_to_screen(errorstr);
     1006        log_to_screen
     1007            ("There may be hyperlink at http://www.mondorescue.com which");
     1008        log_to_screen("will take you to the relevant (missing) package.");
     1009        return (1);
     1010    } else {
     1011        return (0);
     1012    }
    10311013}
    10321014
     
    10431025 * @return 0 for success, 1 for failure.
    10441026 */
    1045 int
    1046 write_one_liner_data_file (char *fname, char *contents)
    1047 {
    1048     /*@ pointers ****************************************************/
    1049   FILE *fout;
    1050   int res=0;
    1051 
    1052     /*@ end vars ****************************************************/
    1053 
    1054   assert_string_is_neither_NULL_nor_zerolength(fname);
    1055   if (!contents) { log_it("%d: Warning - writing NULL to %s", __LINE__, fname); }
    1056   if (!(fout = fopen (fname, "w")))
    1057     {
    1058       log_it("fname=%s");
    1059       log_OS_error("Unable to openout fname");
    1060       return (1);
    1061     }
    1062   fprintf (fout, "%s\n", contents);
    1063   paranoid_fclose (fout);
    1064   return (res);
     1027int write_one_liner_data_file(char *fname, char *contents)
     1028{
     1029    /*@ pointers *************************************************** */
     1030    FILE *fout;
     1031    int res = 0;
     1032
     1033    /*@ end vars *************************************************** */
     1034
     1035    assert_string_is_neither_NULL_nor_zerolength(fname);
     1036    if (!contents) {
     1037        log_it("%d: Warning - writing NULL to %s", __LINE__, fname);
     1038    }
     1039    if (!(fout = fopen(fname, "w"))) {
     1040        log_it("fname=%s");
     1041        log_OS_error("Unable to openout fname");
     1042        return (1);
     1043    }
     1044    fprintf(fout, "%s\n", contents);
     1045    paranoid_fclose(fout);
     1046    return (res);
    10651047}
    10661048
     
    10731055 * @return 0 for success, nonzero for failure.
    10741056 */
    1075 int
    1076 read_one_liner_data_file (char *fname, char *contents)
    1077 {
    1078     /*@ pointers ****************************************************/
    1079   FILE *fin;
    1080   int res=0;
    1081   int i;
    1082 
    1083     /*@ end vars ****************************************************/
    1084 
    1085   assert_string_is_neither_NULL_nor_zerolength(fname);
    1086   if (!contents) { log_it("%d: Warning - reading NULL from %s", __LINE__, fname); }
    1087   if (!(fin = fopen (fname, "r")))
    1088     {
    1089       log_it("fname=%s", fname);
    1090       log_OS_error("Unable to openin fname");
    1091       return (1);
    1092     }
    1093   fscanf (fin, "%s\n", contents);
    1094   i = strlen(contents);
    1095   if (i>0 && contents[i-1] < 32) { contents[i-1] = '\0'; }
    1096   paranoid_fclose (fin);
    1097   return (res);
     1057int read_one_liner_data_file(char *fname, char *contents)
     1058{
     1059    /*@ pointers *************************************************** */
     1060    FILE *fin;
     1061    int res = 0;
     1062    int i;
     1063
     1064    /*@ end vars *************************************************** */
     1065
     1066    assert_string_is_neither_NULL_nor_zerolength(fname);
     1067    if (!contents) {
     1068        log_it("%d: Warning - reading NULL from %s", __LINE__, fname);
     1069    }
     1070    if (!(fin = fopen(fname, "r"))) {
     1071        log_it("fname=%s", fname);
     1072        log_OS_error("Unable to openin fname");
     1073        return (1);
     1074    }
     1075    fscanf(fin, "%s\n", contents);
     1076    i = strlen(contents);
     1077    if (i > 0 && contents[i - 1] < 32) {
     1078        contents[i - 1] = '\0';
     1079    }
     1080    paranoid_fclose(fin);
     1081    return (res);
    10981082}
    10991083
     
    11161100 * - @c bkpinfo->tmpdir
    11171101 */
    1118 void
    1119 copy_mondo_and_mindi_stuff_to_scratchdir (struct s_bkpinfo *bkpinfo)
    1120 {
    1121     /*@ Char buffers ***/
    1122   char command[MAX_STR_LEN*2];
    1123   char tmp[MAX_STR_LEN];
    1124   char old_pwd[MAX_STR_LEN];
    1125 
    1126   mvaddstr_and_log_it (g_currentY, 0,
    1127                "Copying Mondo's core files to the scratch directory");
    1128 
    1129   log_msg(4, "g_mondo_home='%s'", g_mondo_home);
    1130   if (strlen(g_mondo_home)<2)
    1131     { find_and_store_mondoarchives_home(g_mondo_home); }
    1132   sprintf (command, CP_BIN " --parents -pRdf %s %s", g_mondo_home,
    1133        bkpinfo->scratchdir);
    1134 
    1135   log_msg(4, "command = %s", command);
    1136   if (run_program_and_log_output (command, 1))
    1137     {
    1138       fatal_error ("Failed to copy Mondo's stuff to scratchdir");
    1139     }
    1140 
    1141   sprintf(tmp, "%s/payload.tgz", g_mondo_home);
    1142   if (does_file_exist(tmp))
    1143     {
    1144       log_it("Untarring payload %s to scratchdir %s", tmp, bkpinfo->scratchdir);
    1145       (void) getcwd (old_pwd, MAX_STR_LEN -1);
    1146       chdir (bkpinfo->scratchdir);
    1147       sprintf(command, "tar -zxvf %s", tmp);
    1148       if (run_program_and_log_output(command, FALSE))
    1149         { fatal_error ("Failed to untar payload"); }
    1150       chdir (old_pwd);
    1151     }
    1152 
    1153   sprintf (command, "cp -f %s/LAST-FILELIST-NUMBER %s", bkpinfo->tmpdir,
    1154        bkpinfo->scratchdir);
    1155 
    1156   if (run_program_and_log_output (command, FALSE))
    1157     {
    1158       fatal_error ("Failed to copy LAST-FILELIST-NUMBER to scratchdir");
    1159     }
    1160 
    1161   strcpy (tmp,
    1162       call_program_and_get_last_line_of_output ("which mondorestore"));
    1163   if (!tmp[0]) { fatal_error("'which mondorestore' returned null. Where's your mondorestore? `which` can't find it. That's odd. Did you install mondorestore?"); }
    1164   sprintf (command, "cp -f %s %s", tmp, bkpinfo->tmpdir);
    1165   if (run_program_and_log_output (command, FALSE))
    1166     {
    1167       fatal_error ("Failed to copy mondorestore to tmpdir");
    1168     }
    1169 
    1170   sprintf (command, "hostname > %s/HOSTNAME", bkpinfo->scratchdir);
    1171   paranoid_system (command);
    1172 
    1173   if (bkpinfo->postnuke_tarball[0])
    1174     {
    1175       sprintf (command, "cp -f %s %s/post-nuke.tgz", bkpinfo->postnuke_tarball, bkpinfo->tmpdir);
    1176       if (run_program_and_log_output (command, FALSE))
    1177         { fatal_error("Unable to copy post-nuke tarball to tmpdir"); }
    1178     }
    1179 
    1180 
    1181   mvaddstr_and_log_it (g_currentY++, 74, "Done.");
     1102void copy_mondo_and_mindi_stuff_to_scratchdir(struct s_bkpinfo *bkpinfo)
     1103{
     1104    /*@ Char buffers ** */
     1105    char command[MAX_STR_LEN * 2];
     1106    char tmp[MAX_STR_LEN];
     1107    char old_pwd[MAX_STR_LEN];
     1108
     1109    mvaddstr_and_log_it(g_currentY, 0,
     1110                        "Copying Mondo's core files to the scratch directory");
     1111
     1112    log_msg(4, "g_mondo_home='%s'", g_mondo_home);
     1113    if (strlen(g_mondo_home) < 2) {
     1114        find_and_store_mondoarchives_home(g_mondo_home);
     1115    }
     1116    sprintf(command, CP_BIN " --parents -pRdf %s %s", g_mondo_home,
     1117            bkpinfo->scratchdir);
     1118
     1119    log_msg(4, "command = %s", command);
     1120    if (run_program_and_log_output(command, 1)) {
     1121        fatal_error("Failed to copy Mondo's stuff to scratchdir");
     1122    }
     1123
     1124    sprintf(tmp, "%s/payload.tgz", g_mondo_home);
     1125    if (does_file_exist(tmp)) {
     1126        log_it("Untarring payload %s to scratchdir %s", tmp,
     1127               bkpinfo->scratchdir);
     1128        (void) getcwd(old_pwd, MAX_STR_LEN - 1);
     1129        chdir(bkpinfo->scratchdir);
     1130        sprintf(command, "tar -zxvf %s", tmp);
     1131        if (run_program_and_log_output(command, FALSE)) {
     1132            fatal_error("Failed to untar payload");
     1133        }
     1134        chdir(old_pwd);
     1135    }
     1136
     1137    sprintf(command, "cp -f %s/LAST-FILELIST-NUMBER %s", bkpinfo->tmpdir,
     1138            bkpinfo->scratchdir);
     1139
     1140    if (run_program_and_log_output(command, FALSE)) {
     1141        fatal_error("Failed to copy LAST-FILELIST-NUMBER to scratchdir");
     1142    }
     1143
     1144    strcpy(tmp,
     1145           call_program_and_get_last_line_of_output("which mondorestore"));
     1146    if (!tmp[0]) {
     1147        fatal_error
     1148            ("'which mondorestore' returned null. Where's your mondorestore? `which` can't find it. That's odd. Did you install mondorestore?");
     1149    }
     1150    sprintf(command, "cp -f %s %s", tmp, bkpinfo->tmpdir);
     1151    if (run_program_and_log_output(command, FALSE)) {
     1152        fatal_error("Failed to copy mondorestore to tmpdir");
     1153    }
     1154
     1155    sprintf(command, "hostname > %s/HOSTNAME", bkpinfo->scratchdir);
     1156    paranoid_system(command);
     1157
     1158    if (bkpinfo->postnuke_tarball[0]) {
     1159        sprintf(command, "cp -f %s %s/post-nuke.tgz",
     1160                bkpinfo->postnuke_tarball, bkpinfo->tmpdir);
     1161        if (run_program_and_log_output(command, FALSE)) {
     1162            fatal_error("Unable to copy post-nuke tarball to tmpdir");
     1163        }
     1164    }
     1165
     1166
     1167    mvaddstr_and_log_it(g_currentY++, 74, "Done.");
    11821168}
    11831169
     
    11941180 * - @c tmpdir
    11951181 */
    1196 void
    1197 store_nfs_config (struct s_bkpinfo *bkpinfo)
    1198 {
    1199 
    1200     /*@ buffers *********/
    1201   char outfile[MAX_STR_LEN];
    1202   char nfs_dev[MAX_STR_LEN];
    1203   char nfs_mount[MAX_STR_LEN];
    1204   char nfs_client_ipaddr[MAX_STR_LEN];
    1205   char nfs_server_ipaddr[MAX_STR_LEN];
    1206   char tmp[MAX_STR_LEN];
    1207   char command[MAX_STR_LEN*2];
    1208 
    1209     /*@ pointers ******/
    1210   char *p;
    1211   FILE *fout;
    1212 
    1213 
    1214 
    1215   log_it ("Storing NFS configuration");
    1216   strcpy (tmp, bkpinfo->nfs_mount);
    1217   p = strchr (tmp, ':');
    1218   if (!p)
    1219     {
    1220       fatal_error
    1221     ("NFS mount doesn't have a colon in it, e.g. 192.168.1.4:/home/nfs");
    1222     }
    1223   *(p++) = '\0';
    1224   strcpy (nfs_server_ipaddr, tmp);
    1225   strcpy (nfs_mount, p);
    1226   sprintf (command,
    1227        "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\n' | head -n1 | cut -d' ' -f1");
    1228   strcpy (nfs_dev, call_program_and_get_last_line_of_output (command));
    1229   sprintf (command,
    1230        "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f7 | cut -d':' -f2");
    1231   strcpy (nfs_client_ipaddr,
    1232       call_program_and_get_last_line_of_output (command));
    1233   sprintf (tmp, "nfs_client_ipaddr=%s; nfs_server_ipaddr=%s; nfs_mount=%s",
    1234        nfs_client_ipaddr, nfs_server_ipaddr, nfs_mount);
    1235   if (strlen (nfs_dev) < 2)
    1236     {
    1237       fatal_error
    1238     ("Unable to find ethN (eth0, eth1, ...) adapter via NFS mount you specified.");
    1239     }
    1240   sprintf (outfile, "%s/start-nfs", bkpinfo->tmpdir);
    1241   sprintf (tmp, "outfile = %s", outfile);
    1242   log_it (tmp);
    1243   if (!(fout = fopen (outfile, "w")))
    1244     {
    1245       fatal_error ("Cannot store NFS config");
    1246     }
    1247   fprintf (fout, "ifconfig lo 127.0.0.1  # config loopback\n");
    1248   fprintf (fout, "ifconfig %s %s; # config client\n", nfs_dev,
    1249        nfs_client_ipaddr);
    1250   fprintf (fout, "ping -c1 %s; # ping server\n", nfs_server_ipaddr);
    1251   fprintf (fout, "mount -t nfs -o nolock %s /tmp/isodir\n", bkpinfo->nfs_mount);
    1252   fprintf (fout, "exit 0\n");
    1253   paranoid_fclose (fout);
    1254   chmod (outfile, 0777);
    1255   make_hole_for_dir( "/var/cache/mondo-archive");
     1182void store_nfs_config(struct s_bkpinfo *bkpinfo)
     1183{
     1184
     1185    /*@ buffers ******** */
     1186    char outfile[MAX_STR_LEN];
     1187    char nfs_dev[MAX_STR_LEN];
     1188    char nfs_mount[MAX_STR_LEN];
     1189    char nfs_client_ipaddr[MAX_STR_LEN];
     1190    char nfs_server_ipaddr[MAX_STR_LEN];
     1191    char tmp[MAX_STR_LEN];
     1192    char command[MAX_STR_LEN * 2];
     1193
     1194    /*@ pointers ***** */
     1195    char *p;
     1196    FILE *fout;
     1197
     1198
     1199
     1200    log_it("Storing NFS configuration");
     1201    strcpy(tmp, bkpinfo->nfs_mount);
     1202    p = strchr(tmp, ':');
     1203    if (!p) {
     1204        fatal_error
     1205            ("NFS mount doesn't have a colon in it, e.g. 192.168.1.4:/home/nfs");
     1206    }
     1207    *(p++) = '\0';
     1208    strcpy(nfs_server_ipaddr, tmp);
     1209    strcpy(nfs_mount, p);
     1210    sprintf(command,
     1211            "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\n' | head -n1 | cut -d' ' -f1");
     1212    strcpy(nfs_dev, call_program_and_get_last_line_of_output(command));
     1213    sprintf(command,
     1214            "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f7 | cut -d':' -f2");
     1215    strcpy(nfs_client_ipaddr,
     1216           call_program_and_get_last_line_of_output(command));
     1217    sprintf(tmp,
     1218            "nfs_client_ipaddr=%s; nfs_server_ipaddr=%s; nfs_mount=%s",
     1219            nfs_client_ipaddr, nfs_server_ipaddr, nfs_mount);
     1220    if (strlen(nfs_dev) < 2) {
     1221        fatal_error
     1222            ("Unable to find ethN (eth0, eth1, ...) adapter via NFS mount you specified.");
     1223    }
     1224    sprintf(outfile, "%s/start-nfs", bkpinfo->tmpdir);
     1225    sprintf(tmp, "outfile = %s", outfile);
     1226    log_it(tmp);
     1227    if (!(fout = fopen(outfile, "w"))) {
     1228        fatal_error("Cannot store NFS config");
     1229    }
     1230    fprintf(fout, "ifconfig lo 127.0.0.1  # config loopback\n");
     1231    fprintf(fout, "ifconfig %s %s; # config client\n", nfs_dev,
     1232            nfs_client_ipaddr);
     1233    fprintf(fout, "ping -c 1 %s; # ping server\n", nfs_server_ipaddr);
     1234    fprintf(fout, "mount -t nfs -o nolock %s /tmp/isodir\n",
     1235            bkpinfo->nfs_mount);
     1236    fprintf(fout, "exit 0\n");
     1237    paranoid_fclose(fout);
     1238    chmod(outfile, 0777);
     1239    make_hole_for_dir("/var/cache/mondo-archive");
    12561240
    12571241//  paranoid_system ("mkdir -p /var/cache/mondo-archive 2> /dev/null");
    12581242
    1259   sprintf (tmp, "cp -f %s /var/cache/mondo-archive", outfile);
    1260   run_program_and_log_output(tmp, FALSE);
    1261 
    1262   sprintf (tmp, "%s/NFS-DEV", bkpinfo->tmpdir);
    1263   write_one_liner_data_file (tmp, nfs_dev);
    1264 
    1265   sprintf (tmp, "%s/NFS-CLIENT-IPADDR", bkpinfo->tmpdir);
    1266   write_one_liner_data_file (tmp, nfs_client_ipaddr);
    1267   sprintf (tmp, "%s/NFS-SERVER-IPADDR", bkpinfo->tmpdir);
    1268   write_one_liner_data_file (tmp, nfs_server_ipaddr);
    1269   sprintf (tmp, "%s/NFS-SERVER-MOUNT", bkpinfo->tmpdir);
    1270   write_one_liner_data_file (tmp, bkpinfo->nfs_mount);
    1271   sprintf (tmp, "%s/NFS-SERVER-PATH", bkpinfo->tmpdir);
    1272   write_one_liner_data_file (tmp, bkpinfo->nfs_remote_dir);
    1273   log_it ("Finished storing NFS configuration");
     1243    sprintf(tmp, "cp -f %s /var/cache/mondo-archive", outfile);
     1244    run_program_and_log_output(tmp, FALSE);
     1245
     1246    sprintf(tmp, "%s/NFS-DEV", bkpinfo->tmpdir);
     1247    write_one_liner_data_file(tmp, nfs_dev);
     1248
     1249    sprintf(tmp, "%s/NFS-CLIENT-IPADDR", bkpinfo->tmpdir);
     1250    write_one_liner_data_file(tmp, nfs_client_ipaddr);
     1251    sprintf(tmp, "%s/NFS-SERVER-IPADDR", bkpinfo->tmpdir);
     1252    write_one_liner_data_file(tmp, nfs_server_ipaddr);
     1253    sprintf(tmp, "%s/NFS-SERVER-MOUNT", bkpinfo->tmpdir);
     1254    write_one_liner_data_file(tmp, bkpinfo->nfs_mount);
     1255    sprintf(tmp, "%s/NFS-SERVER-PATH", bkpinfo->tmpdir);
     1256    write_one_liner_data_file(tmp, bkpinfo->nfs_remote_dir);
     1257    log_it("Finished storing NFS configuration");
    12741258}
    12751259
     
    12961280 */
    12971281void
    1298 estimate_noof_media_required (struct s_bkpinfo *bkpinfo, long noof_sets)
    1299 {
    1300     /*@ buffers ****************/
    1301   char tmp[MAX_STR_LEN];
    1302 
    1303     /*@ long long **************/
    1304   long long scratchLL;
    1305 
    1306   if (bkpinfo->media_size[1]<=0 || bkpinfo->backup_media_type == nfs)
    1307     {
    1308       log_to_screen("Number of media required: UNKNOWN");
    1309       return;
    1310     }
    1311 
    1312   log_it ("Estimating number of media required...");
    1313   scratchLL = (long long)(noof_sets) * (long long)(bkpinfo->optimal_set_size)
    1314     + (long long)(size_of_all_biggiefiles_K (bkpinfo));
    1315   scratchLL = (scratchLL / 1024) / bkpinfo->media_size[1];
    1316   scratchLL++;
    1317   if (bkpinfo->use_lzo)
    1318     {
    1319       scratchLL = (scratchLL * 2) / 3;
    1320     }
    1321   else
    1322     {
    1323       scratchLL = scratchLL / 2;
    1324     }
    1325   if (!scratchLL)
    1326     {
    1327       scratchLL++;
    1328     }
    1329   if (scratchLL <= 1)
    1330     {
    1331       sprintf (tmp,
    1332            "Your backup will probably occupy a single CD/tape/ISO. Maybe two.");
    1333     }
    1334   else if (scratchLL > 4)
    1335     {
    1336       sprintf(tmp, "Your backup will occupy one meeeeellion media! (maybe %s)",
    1337            number_to_text ((int) (scratchLL + 1)));
    1338     }
    1339   else
    1340     {
    1341       sprintf (tmp, "Your backup will occupy approximately %s media.",
    1342            number_to_text ((int) (scratchLL + 1)));
    1343     }
    1344   if (!bkpinfo->image_devs[0] && (scratchLL<50))
    1345     {
    1346       log_to_screen (tmp);
    1347     }
     1282estimate_noof_media_required(struct s_bkpinfo *bkpinfo, long noof_sets)
     1283{
     1284    /*@ buffers *************** */
     1285    char tmp[MAX_STR_LEN];
     1286
     1287    /*@ long long ************* */
     1288    long long scratchLL;
     1289
     1290    if (bkpinfo->media_size[1] <= 0 || bkpinfo->backup_media_type == nfs) {
     1291        log_to_screen("Number of media required: UNKNOWN");
     1292        return;
     1293    }
     1294
     1295    log_it("Estimating number of media required...");
     1296    scratchLL =
     1297        (long long) (noof_sets) * (long long) (bkpinfo->optimal_set_size)
     1298        + (long long) (size_of_all_biggiefiles_K(bkpinfo));
     1299    scratchLL = (scratchLL / 1024) / bkpinfo->media_size[1];
     1300    scratchLL++;
     1301    if (bkpinfo->use_lzo) {
     1302        scratchLL = (scratchLL * 2) / 3;
     1303    } else {
     1304        scratchLL = scratchLL / 2;
     1305    }
     1306    if (!scratchLL) {
     1307        scratchLL++;
     1308    }
     1309    if (scratchLL <= 1) {
     1310        sprintf(tmp,
     1311                "Your backup will probably occupy a single CD/tape/ISO. Maybe two.");
     1312    } else if (scratchLL > 4) {
     1313        sprintf(tmp,
     1314                "Your backup will occupy one meeeeellion media! (maybe %s)",
     1315                number_to_text((int) (scratchLL + 1)));
     1316    } else {
     1317        sprintf(tmp, "Your backup will occupy approximately %s media.",
     1318                number_to_text((int) (scratchLL + 1)));
     1319    }
     1320    if (!bkpinfo->image_devs[0] && (scratchLL < 50)) {
     1321        log_to_screen(tmp);
     1322    }
    13481323}
    13491324
     
    13561331 * @note The returned string points to static storage that will be overwritten with each call.
    13571332 */
    1358 char*sz_last_suffix(char*instr)
    1359 {
    1360   static char outstr[MAX_STR_LEN];
    1361   char *p;
    1362 
    1363   p = strrchr(instr,'.');
    1364   if (!p)
    1365     {
    1366       outstr[0]='\0';
    1367     }
    1368   else
    1369     {
    1370       strcpy(outstr, p);
    1371     }
    1372   return(outstr);
     1333char *sz_last_suffix(char *instr)
     1334{
     1335    static char outstr[MAX_STR_LEN];
     1336    char *p;
     1337
     1338    p = strrchr(instr, '.');
     1339    if (!p) {
     1340        outstr[0] = '\0';
     1341    } else {
     1342        strcpy(outstr, p);
     1343    }
     1344    return (outstr);
    13731345}
    13741346
     
    13801352 * @return TRUE if it's compressed, FALSE if not.
    13811353 */
    1382 bool is_this_file_compressed(char*filename)
    1383 {
    1384   char do_not_compress_these[MAX_STR_LEN];
    1385   char tmp[MAX_STR_LEN];
    1386   char *p;
    1387 
    1388   sprintf(tmp, "%s/do-not-compress-these", g_mondo_home);
    1389   if (!does_file_exist(tmp)) { return(FALSE); }
    1390   strcpy(do_not_compress_these, last_line_of_file(tmp));
    1391   for(p=do_not_compress_these; p!=NULL; p++)
    1392     {
    1393       strcpy(tmp, p);
    1394       if (strchr(tmp, ' ')) { *(strchr(tmp, ' ')) ='\0'; }
    1395       if (!strcmp(sz_last_suffix(filename), tmp))
    1396     { /*printf("MATCH\n");*/ return(TRUE); }
    1397       if (!(p = strchr(p, ' '))) { break; }
    1398     }
    1399   return(FALSE);
    1400 }
    1401 
    1402 
    1403 
    1404 int mode_of_file(char*fname)
    1405 {
    1406   struct stat buf;
    1407 
    1408   if (lstat(fname, &buf))
    1409     { return(-1); } // error
    1410   else
    1411     { return(buf.st_mode); }
     1354bool is_this_file_compressed(char *filename)
     1355{
     1356    char do_not_compress_these[MAX_STR_LEN];
     1357    char tmp[MAX_STR_LEN];
     1358    char *p;
     1359
     1360    sprintf(tmp, "%s/do-not-compress-these", g_mondo_home);
     1361    if (!does_file_exist(tmp)) {
     1362        return (FALSE);
     1363    }
     1364    strcpy(do_not_compress_these, last_line_of_file(tmp));
     1365    for (p = do_not_compress_these; p != NULL; p++) {
     1366        strcpy(tmp, p);
     1367        if (strchr(tmp, ' ')) {
     1368            *(strchr(tmp, ' ')) = '\0';
     1369        }
     1370        if (!strcmp(sz_last_suffix(filename), tmp)) {   /*printf("MATCH\n"); */
     1371            return (TRUE);
     1372        }
     1373        if (!(p = strchr(p, ' '))) {
     1374            break;
     1375        }
     1376    }
     1377    return (FALSE);
     1378}
     1379
     1380
     1381
     1382int mode_of_file(char *fname)
     1383{
     1384    struct stat buf;
     1385
     1386    if (lstat(fname, &buf)) {
     1387        return (-1);
     1388    }                           // error
     1389    else {
     1390        return (buf.st_mode);
     1391    }
    14121392}
    14131393
     
    14201400 * @return 0 for success, 1 for failure.
    14211401 */
    1422 int make_grub_install_scriptlet(char*outfile)
    1423 {
    1424   FILE*fout;
    1425   char *tmp;
    1426   int retval=0;
    1427 
    1428   malloc_string(tmp);
    1429   if ((fout = fopen( outfile, "w")))
    1430     {
    1431       fprintf(fout, "#!/bin/sh\n\nmount /boot > /dev/null 2> /dev/null\ngrub-install $@\nres=$?\nsync;sync;sync\nexit $res\n");
    1432       paranoid_fclose(fout);
    1433       log_msg(2, "Created %s", outfile);
    1434       sprintf(tmp, "chmod +x %s", outfile);
    1435       paranoid_system(tmp);
    1436       retval=0;
    1437         }
    1438   else
    1439         {
    1440       retval=1;
    1441     }
    1442   paranoid_free(tmp);
    1443   return(retval);
     1402int make_grub_install_scriptlet(char *outfile)
     1403{
     1404    FILE *fout;
     1405    char *tmp;
     1406    int retval = 0;
     1407
     1408    malloc_string(tmp);
     1409    if ((fout = fopen(outfile, "w"))) {
     1410        fprintf(fout,
     1411                "#!/bin/sh\n\nmount /boot > /dev/null 2> /dev/null\ngrub-install $@\nres=$?\nsync;sync;sync\nexit $res\n");
     1412        paranoid_fclose(fout);
     1413        log_msg(2, "Created %s", outfile);
     1414        sprintf(tmp, "chmod +x %s", outfile);
     1415        paranoid_system(tmp);
     1416        retval = 0;
     1417    } else {
     1418        retval = 1;
     1419    }
     1420    paranoid_free(tmp);
     1421    return (retval);
    14441422}
    14451423
  • branches/2.05/mondo/mondo/mondoarchive/mondo-cli.c

    r30 r116  
    77edited by            : by Stan Benoit 4/2002
    88email                : troff@nakedsoul.org
    9 cvsid                : $Id: mondo-cli.c,v 1.11 2004/06/21 20:20:36 hugo Exp $
     9cvsid                : $Id$
    1010 ***************************************************************************/
    1111
     
    175175
    176176
    177 //static char cvsid[] = "$Id: mondo-cli.c,v 1.11 2004/06/21 20:20:36 hugo Exp $";
     177//static char cvsid[] = "$Id$";
    178178
    179179extern int g_loglevel;
    180180extern bool g_text_mode;
    181 extern bool g_skip_floppies; ///< Whether to skip the creation of boot disks
    182 extern char g_startdir[MAX_STR_LEN]; ///< ????? @bug ?????
     181extern bool g_skip_floppies;    ///< Whether to skip the creation of boot disks
     182extern char g_startdir[MAX_STR_LEN];    ///< ????? @bug ?????
    183183extern char g_erase_tmpdir_and_scratchdir[MAX_STR_LEN];
    184184extern char g_tmpfs_mountpt[MAX_STR_LEN];
     
    195195
    196196/*@ bool******** **************************************************/
    197 bool g_debugging = FALSE; ///< ????? @bug ????? @ingroup globalGroup
    198 bool g_running_live = FALSE; ///< ????? @bug ????? @ingroup globalGroup
     197bool g_debugging = FALSE;       ///< ????? @bug ????? @ingroup globalGroup
     198bool g_running_live = FALSE;    ///< ????? @bug ????? @ingroup globalGroup
    199199extern bool g_cd_recovery;
    200200
     
    220220
    221221
    222 extern char*resolve_softlinks_to_get_to_actual_device_file(char*);
     222extern char *resolve_softlinks_to_get_to_actual_device_file(char *);
    223223
    224224
     
    236236 */
    237237int
    238 handle_incoming_parameters (int argc, char *argv[], struct s_bkpinfo *bkpinfo)
     238handle_incoming_parameters(int argc, char *argv[],
     239                           struct s_bkpinfo *bkpinfo)
    239240{
    240     /*@ int ****/
    241   int res = 0;
    242   int retval = 0;
    243   int i = 0, j;
    244 
    245     /*@ buffers ****************/
    246   char *tmp;
    247   char flag_val[128][MAX_STR_LEN];
    248   bool flag_set[128];
    249 
    250   malloc_string(tmp);
    251   sensibly_set_tmpdir_and_scratchdir(bkpinfo);
    252   for (i = 0; i < 128; i++)
    253     {
    254       flag_val[i][0] = '\0';
    255       flag_set[i] = FALSE;
    256     }
    257   //  strcpy (bkpinfo->tmpdir, "/root/images/mondo");
    258   //  strcpy (bkpinfo->scratchdir, "/home");
    259   for(j=1; j<=MAX_NOOF_MEDIA; j++) {bkpinfo->media_size[j] = 650;}  /* default */
    260   res = retrieve_switches_from_command_line (argc, argv, flag_val, flag_set);
    261   retval += res;
    262   if (!retval)
    263     {
    264       res = process_switches (bkpinfo, flag_val, flag_set);
    265       retval += res;
    266     }
     241    /*@ int *** */
     242    int res = 0;
     243    int retval = 0;
     244    int i = 0, j;
     245
     246    /*@ buffers *************** */
     247    char *tmp;
     248    char flag_val[128][MAX_STR_LEN];
     249    bool flag_set[128];
     250
     251    malloc_string(tmp);
     252    sensibly_set_tmpdir_and_scratchdir(bkpinfo);
     253    for (i = 0; i < 128; i++) {
     254        flag_val[i][0] = '\0';
     255        flag_set[i] = FALSE;
     256    }
     257    //  strcpy (bkpinfo->tmpdir, "/root/images/mondo");
     258    //  strcpy (bkpinfo->scratchdir, "/home");
     259    for (j = 1; j <= MAX_NOOF_MEDIA; j++) {
     260        bkpinfo->media_size[j] = 650;
     261    }                           /* default */
     262    res =
     263        retrieve_switches_from_command_line(argc, argv, flag_val,
     264                                            flag_set);
     265    retval += res;
     266    if (!retval) {
     267        res = process_switches(bkpinfo, flag_val, flag_set);
     268        retval += res;
     269    }
    267270/*
    268271  if (!retval)
    269272    {
    270273*/
    271       log_msg (3, "Switches:-");
    272       for (i = 0; i < 128; i++)
    273     {
    274       if (flag_set[i])
    275         {
    276           sprintf (tmp, "-%c %s", i, flag_val[i]);
    277           log_msg (3, tmp);
    278         }
     274    log_msg(3, "Switches:-");
     275    for (i = 0; i < 128; i++) {
     276        if (flag_set[i]) {
     277            sprintf(tmp, "-%c %s", i, flag_val[i]);
     278            log_msg(3, tmp);
     279        }
    279280    }
    280281//    }
    281   sprintf (tmp, "rm -Rf %s/tmp.mondo.*", bkpinfo->tmpdir);
    282   paranoid_system (tmp);
    283   sprintf (tmp, "rm -Rf %s/mondo.scratch.*", bkpinfo->scratchdir);
    284   paranoid_system (tmp);
    285   sprintf (bkpinfo->tmpdir + strlen (bkpinfo->tmpdir), "/tmp.mondo.%ld",
    286        random () % 32767);
    287   sprintf (bkpinfo->scratchdir + strlen (bkpinfo->scratchdir),
    288        "/mondo.scratch.%ld", random () % 32767);
    289   sprintf (tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir);
    290   paranoid_system (tmp);
    291   sprintf (tmp, "mkdir -p %s", bkpinfo->scratchdir);
    292   paranoid_system (tmp);
    293   if (bkpinfo->nfs_mount[0] != '\0')
    294     {
    295       store_nfs_config (bkpinfo);
    296     }
    297   paranoid_free(tmp);
    298   return (retval);
     282    sprintf(tmp, "rm -Rf %s/tmp.mondo.*", bkpinfo->tmpdir);
     283    paranoid_system(tmp);
     284    sprintf(tmp, "rm -Rf %s/mondo.scratch.*", bkpinfo->scratchdir);
     285    paranoid_system(tmp);
     286    sprintf(bkpinfo->tmpdir + strlen(bkpinfo->tmpdir), "/tmp.mondo.%ld",
     287            random() % 32767);
     288    sprintf(bkpinfo->scratchdir + strlen(bkpinfo->scratchdir),
     289            "/mondo.scratch.%ld", random() % 32767);
     290    sprintf(tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir);
     291    paranoid_system(tmp);
     292    sprintf(tmp, "mkdir -p %s", bkpinfo->scratchdir);
     293    paranoid_system(tmp);
     294    if (bkpinfo->nfs_mount[0] != '\0') {
     295        store_nfs_config(bkpinfo);
     296    }
     297    paranoid_free(tmp);
     298    return (retval);
    299299}
    300300
     
    311311int process_the_s_switch(struct s_bkpinfo *bkpinfo, char *value)
    312312{
    313       int j;
    314       char tmp[MAX_STR_LEN], *p, comment[MAX_STR_LEN];
    315 
    316   assert(bkpinfo!=NULL);
    317   assert(value!=NULL);
    318 
    319       bkpinfo->media_size[0] = -1; /* dummy value */
    320       for(j=1, p=value; j<MAX_NOOF_MEDIA && strchr(p,','); j++, p=strchr(p,',')+1)
    321     {
    322       strncpy(tmp, p, MAX_STR_LEN);
    323       *(strchr(tmp,',')) = '\0';
    324       bkpinfo->media_size[j] = friendly_sizestr_to_sizelong (tmp);
    325           sprintf(comment, "media_size[%d] = %ld", j, bkpinfo->media_size[j]);
    326           log_msg(3, comment);
    327     }
    328       for(; j<=MAX_NOOF_MEDIA; j++)
    329     {
    330       bkpinfo->media_size[j] = friendly_sizestr_to_sizelong (p);
     313    int j;
     314    char tmp[MAX_STR_LEN], *p, comment[MAX_STR_LEN];
     315
     316    assert(bkpinfo != NULL);
     317    assert(value != NULL);
     318
     319    bkpinfo->media_size[0] = -1;    /* dummy value */
     320    for (j = 1, p = value; j < MAX_NOOF_MEDIA && strchr(p, ',');
     321         j++, p = strchr(p, ',') + 1) {
     322        strncpy(tmp, p, MAX_STR_LEN);
     323        *(strchr(tmp, ',')) = '\0';
     324        bkpinfo->media_size[j] = friendly_sizestr_to_sizelong(tmp);
     325        sprintf(comment, "media_size[%d] = %ld", j,
     326                bkpinfo->media_size[j]);
     327        log_msg(3, comment);
     328    }
     329    for (; j <= MAX_NOOF_MEDIA; j++) {
     330        bkpinfo->media_size[j] = friendly_sizestr_to_sizelong(p);
    331331    }
    332332//      bkpinfo->media_size[0] = bkpinfo->media_size[MAX_NOOF_MEDIA];
    333       for(j=1; j<=MAX_NOOF_MEDIA; j++)
    334         {
    335           if (bkpinfo->media_size[j]<=0) { log_msg(1, "You gave media #%d an invalid size\n", j); return(-1); }
    336         }
    337       return(0);
     333    for (j = 1; j <= MAX_NOOF_MEDIA; j++) {
     334        if (bkpinfo->media_size[j] <= 0) {
     335            log_msg(1, "You gave media #%d an invalid size\n", j);
     336            return (-1);
     337        }
     338    }
     339    return (0);
    338340}
    339341
     
    351353 */
    352354int
    353 process_switches (struct s_bkpinfo *bkpinfo, char flag_val[128][MAX_STR_LEN],
    354           bool flag_set[128])
     355process_switches(struct s_bkpinfo *bkpinfo,
     356                 char flag_val[128][MAX_STR_LEN], bool flag_set[128])
    355357{
    356358
    357     /*@ ints ****/
    358   int i = 0;
    359   int retval = 0;
    360   int percent = 0;
    361 
    362     /*@ buffers ***/
    363   char *tmp;
    364   char *psz;
    365 
    366   long itbs;
    367 
    368   malloc_string(tmp);
    369   malloc_string(psz);
    370 
    371   assert(bkpinfo!=NULL);
    372   assert(flag_val!=NULL);
    373   assert(flag_set!=NULL);
    374 
    375   bkpinfo->internal_tape_block_size = DEFAULT_INTERNAL_TAPE_BLOCK_SIZE;
     359    /*@ ints *** */
     360    int i = 0;
     361    int retval = 0;
     362    int percent = 0;
     363
     364    /*@ buffers ** */
     365    char *tmp;
     366    char *psz;
     367
     368    long itbs;
     369
     370    malloc_string(tmp);
     371    malloc_string(psz);
     372
     373    assert(bkpinfo != NULL);
     374    assert(flag_val != NULL);
     375    assert(flag_set != NULL);
     376
     377    bkpinfo->internal_tape_block_size = DEFAULT_INTERNAL_TAPE_BLOCK_SIZE;
    376378
    377379/* compulsory */
    378   i =
    379     flag_set['c'] + flag_set['i'] + flag_set['n'] +
    380     flag_set['t'] + flag_set['u'] + flag_set['r'] +
    381     flag_set['w'] + flag_set['C'];
    382   if (i == 0)
    383     {
    384       retval++;
    385       log_to_screen( "You must specify the media type\n");
    386     }
    387   if (i > 1)
    388     {
    389       retval++;
    390       log_to_screen( "Please specify only one media type\n");
    391     }
    392   if (flag_set['K'])
    393     {
    394       g_loglevel = atoi(flag_val['K']);
    395       if (g_loglevel < 3) { g_loglevel = 3; }
    396     }
    397   if (flag_set['L'] && flag_set['0'])
    398     {
    399       retval++;
    400       log_to_screen( "You cannot have 'no compression' _and_ LZOP.\n");
    401     }
    402   bkpinfo->backup_data = flag_set['O'];
    403   bkpinfo->verify_data = flag_set['V'];
    404   if (flag_set['I'] && !bkpinfo->backup_data)
    405     {
    406       log_to_screen ("-I switch is ignored if just verifying");
    407     }
    408   if (flag_set['E'] && !bkpinfo->backup_data)
    409     {
    410       log_to_screen ("-E switch is ignored if just verifying");
    411     }
    412 
    413   if (!find_home_of_exe("afio"))
    414     {
    415       if (find_home_of_exe("star"))
     380    i = flag_set['c'] + flag_set['i'] + flag_set['n'] +
     381        flag_set['t'] + flag_set['u'] + flag_set['r'] +
     382        flag_set['w'] + flag_set['C'];
     383    if (i == 0) {
     384        retval++;
     385        log_to_screen("You must specify the media type\n");
     386    }
     387    if (i > 1) {
     388        retval++;
     389        log_to_screen("Please specify only one media type\n");
     390    }
     391    if (flag_set['K']) {
     392        g_loglevel = atoi(flag_val['K']);
     393        if (g_loglevel < 3) {
     394            g_loglevel = 3;
     395        }
     396    }
     397    if (flag_set['L'] && flag_set['0']) {
     398        retval++;
     399        log_to_screen("You cannot have 'no compression' _and_ LZOP.\n");
     400    }
     401    bkpinfo->backup_data = flag_set['O'];
     402    bkpinfo->verify_data = flag_set['V'];
     403    if (flag_set['I'] && !bkpinfo->backup_data) {
     404        log_to_screen("-I switch is ignored if just verifying");
     405    }
     406    if (flag_set['E'] && !bkpinfo->backup_data) {
     407        log_to_screen("-E switch is ignored if just verifying");
     408    }
     409
     410    if (!find_home_of_exe("afio")) {
     411        if (find_home_of_exe("star")) {
     412            flag_set['R'] = TRUE;
     413            log_msg(1, "Using star instead of afio");
     414        } else {
     415            fatal_error
     416                ("Neither afio nor star is installed. Please install at least one.");
     417        }
     418    }
     419
     420    if (flag_set['R']) {
     421        bkpinfo->use_star = TRUE;
     422        if (flag_set['L']) {
     423            fatal_error("You may not use star and lzop at the same time.");
     424        }
     425        if (!find_home_of_exe("star")) {
     426            fatal_error
     427                ("Please install 'star' RPM or tarball if you are going to use -R. Thanks.");
     428        }
     429    }
     430    if (flag_set['W']) {
     431        bkpinfo->nonbootable_backup = TRUE;
     432        log_to_screen("Warning - you have opted for non-bootable backup");
     433        if (flag_set['f'] || flag_set['l']) {
     434            log_to_screen
     435                ("You don't need to specify bootloader or bootdevice");
     436        }
     437    }
     438    if (flag_set['t'] && flag_set['H']) {
     439        fatal_error
     440            ("Sorry, you may not nuke w/o warning from tape. Drop -H, please.");
     441    }
     442    if (flag_set['I']) {
     443        if (!strcmp(bkpinfo->include_paths, "/")) {
     444            log_msg(2, "'/' is pleonastic.");
     445            bkpinfo->include_paths[0] = '\0';
     446        }
     447        if (bkpinfo->include_paths[0]) {
     448            strcat(bkpinfo->include_paths, " ");
     449        }
     450        strncpy(bkpinfo->include_paths + strlen(bkpinfo->include_paths),
     451                flag_val['I'],
     452                MAX_STR_LEN - strlen(bkpinfo->include_paths));
     453        log_msg(1, "include_paths is now '%s'", bkpinfo->include_paths);
     454        if (bkpinfo->include_paths[0] == '-') {
     455            retval++;
     456            log_to_screen("Please supply a sensible value with '-I'\n");
     457        }
     458    }
     459
     460    if (g_kernel_version >= 2.6 && !flag_set['d']
     461        && (flag_set['c'] || flag_set['w'])) {
     462        fatal_error
     463            ("If you are using the 2.6.x kernel, please specify the CD-R(W) device.");
     464    }
     465
     466
     467    if (flag_set['J']) {
     468        if (flag_set['I']) {
     469            retval++;
     470            log_to_screen
     471                ("Please do not use -J in combination with -I. If you want to make a list of files to backup, that's fine, use -J <filename> but please don't muddy the waters by combining -J with -I. Thanks. :-)");
     472        }
     473        bkpinfo->make_filelist = FALSE;
     474        strcpy(bkpinfo->include_paths, flag_val['J']);
     475    }
     476    if (flag_set['c'] || flag_set['w'] || flag_set['C'] || flag_set['r']) {
     477        if (!flag_set['r'] && g_kernel_version <= 2.5
     478            && strstr(flag_val['d'], "/dev/")) {
     479            fatal_error
     480                ("Please don't give a /dev entry. Give a SCSI node for the parameter of the -d flag.");
     481        }
     482        if (flag_set['r'] && g_kernel_version <= 2.5
     483            && !strstr(flag_val['d'], "/dev/")) {
     484            fatal_error
     485                ("Please give a /dev entry, not a SCSI node, as the parameter of the -d flag.");
     486        }
     487        if (g_kernel_version >= 2.6 && !strstr(flag_val['d'], "/dev/")) {
     488            log_to_screen
     489                ("Linus says 2.6 has a broken ide-scsi module. Proceed at your own risk...");
     490        }
     491
     492        if (system("which cdrecord > /dev/null 2> /dev/null")
     493            && system("which dvdrecord > /dev/null 2> /dev/null")) {
     494            fatal_error
     495                ("Please install dvdrecord/cdrecord and try again.");
     496        }
     497        if (flag_set['C']) {
     498            bkpinfo->cdrw_speed = atoi(flag_val['C']);
     499            if (bkpinfo->cdrw_speed < 1) {
     500                fatal_error
     501                    ("You specified a silly speed for a CD-R[W] drive");
     502            }
     503            if (!flag_set['L']) {
     504                log_to_screen
     505                    ("You must use -L with -C. Therefore I am setting it for you.");
     506                flag_set['L'] = 1;
     507                flag_val['L'][0] = '\0';
     508            }
     509        } else {
     510            log_msg(3, "flag_val['c'] = %s", flag_val['c']);
     511            log_msg(3, "flag_val['w'] = %s", flag_val['w']);
     512//    log_msg(3, "flag_set['r'] = %i", flag_set['r'] );
     513            if (flag_set['c']) {
     514                bkpinfo->cdrw_speed = atoi(flag_val['c']);
     515            } else if (flag_set['w']) {
     516                bkpinfo->cdrw_speed = atoi(flag_val['w']);
     517            } else if (flag_set['r']) {
     518                bkpinfo->cdrw_speed = 1;    /*atoi(flag_val['r']); */
     519            }
     520
     521            if (bkpinfo->cdrw_speed < 1) {
     522                fatal_error
     523                    ("You specified a silly speed for a CD-R[W] drive");
     524            }
     525        }
     526    }
     527    if (flag_set['t'] && !flag_set['d']) {
     528        log_it("Hmm! No tape drive specified. Let's see what we can do.");
     529        if (find_tape_device_and_size(flag_val['d'], tmp)) {
     530            fatal_error
     531                ("Tape device not specified. I couldn't find it either.");
     532        }
     533        flag_set['d'] = TRUE;
     534        sprintf(tmp,
     535                "You didn't specify a tape streamer device. I'm assuming %s",
     536                flag_val['d']);
     537        log_to_screen(tmp);
     538        percent = 0;
     539    }
     540
     541    if (flag_set['r'])          // DVD
    416542    {
    417       flag_set['R'] = TRUE;
    418       log_msg(1, "Using star instead of afio");
    419     }
    420       else
    421     {
    422       fatal_error("Neither afio nor star is installed. Please install at least one.");
    423     }
    424     }
    425 
    426   if (flag_set['R'])
    427     {
    428       bkpinfo->use_star = TRUE;
    429       if (flag_set['L'])
    430         { fatal_error ("You may not use star and lzop at the same time."); }
    431       if (!find_home_of_exe("star"))
    432         { fatal_error ("Please install 'star' RPM or tarball if you are going to use -R. Thanks."); }
    433     }
    434   if (flag_set['W'])
    435     {
    436       bkpinfo->nonbootable_backup = TRUE;
    437       log_to_screen ("Warning - you have opted for non-bootable backup");
    438       if (flag_set['f'] || flag_set['l'])
    439         {
    440           log_to_screen ("You don't need to specify bootloader or bootdevice");
    441         }
    442     }
    443   if (flag_set['t'] && flag_set['H'])
    444     { fatal_error("Sorry, you may not nuke w/o warning from tape. Drop -H, please."); }
    445   if (flag_set['I'])
    446     {
    447       if (!strcmp(bkpinfo->include_paths, "/"))
    448     {
    449       log_msg(2, "'/' is pleonastic.");
    450       bkpinfo->include_paths[0] = '\0';
    451     }
    452       if (bkpinfo->include_paths[0])
    453         { strcat(bkpinfo->include_paths," "); }
    454       strncpy (bkpinfo->include_paths+strlen(bkpinfo->include_paths), flag_val['I'], MAX_STR_LEN - strlen(bkpinfo->include_paths));
    455       log_msg(1, "include_paths is now '%s'", bkpinfo->include_paths);
    456       if (bkpinfo->include_paths[0] == '-')
    457     {
    458       retval++;
    459       log_to_screen( "Please supply a sensible value with '-I'\n");
    460     }
    461     }
    462    
    463   if (g_kernel_version >= 2.6 && !flag_set['d'] && (flag_set['c'] || flag_set['w']))
    464     {
    465       fatal_error("If you are using the 2.6.x kernel, please specify the CD-R(W) device.");
    466     }
    467 
    468 
    469   if (flag_set['J'])
    470     {
    471       if (flag_set['I'])
    472     {
    473       retval++;
    474       log_to_screen( "Please do not use -J in combination with -I. If you want to make a list of files to backup, that's fine, use -J <filename> but please don't muddy the waters by combining -J with -I. Thanks. :-)");
    475     }
    476       bkpinfo->make_filelist = FALSE;
    477       strcpy(bkpinfo->include_paths, flag_val['J']);
    478     }
    479   if (flag_set['c'] || flag_set['w'] || flag_set['C'] || flag_set['r'])
    480     {
    481       if (!flag_set['r'] && g_kernel_version <= 2.5 && strstr(flag_val['d'], "/dev/"))
    482         { fatal_error("Please don't give a /dev entry. Give a SCSI node for the parameter of the -d flag."); }
    483       if (flag_set['r'] && g_kernel_version <= 2.5 && !strstr(flag_val['d'], "/dev/"))
    484         { fatal_error("Please give a /dev entry, not a SCSI node, as the parameter of the -d flag."); }
    485       if (g_kernel_version >= 2.6 && !strstr(flag_val['d'], "/dev/"))
    486     { log_to_screen("Linus says 2.6 has a broken ide-scsi module. Proceed at your own risk..."); }
    487 
    488       if (system ("which cdrecord > /dev/null 2> /dev/null") && system("which dvdrecord > /dev/null 2> /dev/null"))
    489     {
    490       fatal_error ("Please install dvdrecord/cdrecord and try again.");
    491     }
    492       if (flag_set['C'])
    493     {
    494       bkpinfo->cdrw_speed = 2;
    495       if (!flag_set['L'])
    496         {
    497         log_to_screen ("You must use -L with -C. Therefore I am setting it for you.");
    498         flag_set['L'] = 1;
    499         flag_val['L'][0] = '\0';
    500         }
    501     }
    502       else
    503     {
    504       log_msg(3, "flag_val['c'] = %s", flag_val['c'] );
    505       log_msg(3, "flag_val['w'] = %s", flag_val['w'] );
    506 //    log_msg(3, "flag_set['r'] = %i", flag_set['r'] );
    507       if (flag_set['c']) { bkpinfo->cdrw_speed = atoi(flag_val['c']); }
    508       else
    509       if (flag_set['w']) { bkpinfo->cdrw_speed = atoi(flag_val['w']); }
    510       else
    511       if (flag_set['r']) { bkpinfo->cdrw_speed = 1; /*atoi(flag_val['r']);*/ }
    512 
    513       if (bkpinfo->cdrw_speed < 1)
    514         {
    515           fatal_error ("You specified a silly speed for a CD-R[W] drive");
    516         }
    517     }
    518     }
    519   if (flag_set['t'] && !flag_set['d'])
    520     {
    521       log_it("Hmm! No tape drive specified. Let's see what we can do.");
    522       if (find_tape_device_and_size(flag_val['d'], tmp))
    523         { fatal_error("Tape device not specified. I couldn't find it either."); }
    524       flag_set['d'] = TRUE;
    525       sprintf(tmp, "You didn't specify a tape streamer device. I'm assuming %s", flag_val['d']);
    526       log_to_screen(tmp);
    527       percent = 0;
    528     }
    529 
    530   if (flag_set['r']) // DVD
    531     {
    532       if (flag_set['m'])
    533     { fatal_error("Manual CD tray (-m) not yet supported in conjunction w/ DVD drives. Drop -m."); }
    534       if (!flag_set['d'])
    535         {
    536           if (!find_dvd_device(flag_val['d'], FALSE))
    537         {
    538           flag_set['d'] = TRUE;
    539           log_to_screen("I guess DVD drive is at %s", flag_val['d']);
    540         }
    541     }
    542       if (!find_home_of_exe("growisofs"))
    543         { fatal_error("Please install growisofs (probably part of dvd+rw-tools). If you want DVD support, you need it."); }
    544       if (!find_home_of_exe("dvd+rw-format"))
    545         { fatal_error("Please install dvd+rw-format (probably part of dvd+rw-tools). If you want DVD support, you need it."); }
    546       if (strchr(flag_val['d'], ','))
    547         { fatal_error("Please don't give a SCSI node. Give a _device_, preferably a /dev entry, for the parameter of the -d flag."); }
    548       if (!flag_set['s'])
    549         {
    550         sprintf (flag_val['s'], "%d", DEFAULT_DVD_DISK_SIZE); // 4.7 salesman's GB = 4.482 real GB = 4582 MB
    551         strcat ( flag_val['s'], "m");
    552         log_to_screen ("You did not specify a size (-s) for DVD. I'm guessing %s.", flag_val['s']);
    553         flag_set['s'] = 1;
    554     }
     543        if (flag_set['m']) {
     544            fatal_error
     545                ("Manual CD tray (-m) not yet supported in conjunction w/ DVD drives. Drop -m.");
     546        }
     547        if (!flag_set['d']) {
     548            if (!find_dvd_device(flag_val['d'], FALSE)) {
     549                flag_set['d'] = TRUE;
     550                log_to_screen("I guess DVD drive is at %s", flag_val['d']);
     551            }
     552        }
     553        if (!find_home_of_exe("growisofs")) {
     554            fatal_error
     555                ("Please install growisofs (probably part of dvd+rw-tools). If you want DVD support, you need it.");
     556        }
     557        if (!find_home_of_exe("dvd+rw-format")) {
     558            fatal_error
     559                ("Please install dvd+rw-format (probably part of dvd+rw-tools). If you want DVD support, you need it.");
     560        }
     561        if (strchr(flag_val['d'], ',')) {
     562            fatal_error
     563                ("Please don't give a SCSI node. Give a _device_, preferably a /dev entry, for the parameter of the -d flag.");
     564        }
     565        if (!flag_set['s']) {
     566            sprintf(flag_val['s'], "%d", DEFAULT_DVD_DISK_SIZE);    // 4.7 salesman's GB = 4.482 real GB = 4582 MB
     567            strcat(flag_val['s'], "m");
     568            log_to_screen
     569                ("You did not specify a size (-s) for DVD. I'm guessing %s.",
     570                 flag_val['s']);
     571            flag_set['s'] = 1;
     572        }
    555573/*
    556574      if (flag_set['Z']) {
     
    558576      }
    559577*/
    560     }
    561 
    562   if (flag_set['t'] || flag_set['u'])
    563     {               /* tape size */
    564       if (strchr(flag_val['d'], ','))
    565         { fatal_error("Please don't give a SCSI node. Give a _device_, preferably a /dev entry, for the parameter of the -d flag."); }
    566       if (flag_set['O'])
     578    }
     579
     580    if (flag_set['t'] || flag_set['u']) {   /* tape size */
     581        if (strchr(flag_val['d'], ',')) {
     582            fatal_error
     583                ("Please don't give a SCSI node. Give a _device_, preferably a /dev entry, for the parameter of the -d flag.");
     584        }
     585        if (flag_set['O']) {
     586            if (flag_set['s']) {
     587                if (flag_set['t']) {
     588                    fatal_error
     589                        ("For the moment, please don't specify a tape size. Mondo should handle end-of-tape gracefully anyway.");
     590                }
     591                if (process_the_s_switch(bkpinfo, flag_val['s'])) {
     592                    fatal_error("Bad -s switch");
     593                }
     594            } else if (flag_set['u'] || flag_set['t']) {
     595                for (i = 0; i <= MAX_NOOF_MEDIA; i++) {
     596                    bkpinfo->media_size[i] = 0;
     597                }
     598            } else {
     599                retval++;
     600                log_to_screen("Tape size not specified.\n");
     601            }
     602        }
     603    } else {                    /* CD size */
     604        if (flag_set['s']) {
     605            if (process_the_s_switch(bkpinfo, flag_val['s'])) {
     606                fatal_error("Bad -s switch");
     607            }
     608        }
     609        if (flag_set['w']) {
     610            bkpinfo->wipe_media_first = TRUE;
     611        }                       /* CD-RW */
     612    }
     613    if (flag_set['n']) {
     614        strncpy(bkpinfo->nfs_mount, flag_val['n'], MAX_STR_LEN);
     615        if (!flag_set['d']) {
     616            strncpy(bkpinfo->nfs_remote_dir, "/", MAX_STR_LEN);
     617        }
     618        sprintf(tmp, "mount | grep -x \"%s .*\" | cut -d' ' -f3",
     619                bkpinfo->nfs_mount);
     620        strncpy(bkpinfo->isodir,
     621                call_program_and_get_last_line_of_output(tmp),
     622                MAX_STR_LEN / 4);
     623        if (strlen(bkpinfo->isodir) < 3) {
     624            retval++;
     625            log_to_screen("NFS share is not mounted. Please mount it.\n");
     626        }
     627        log_msg(3, "mount = %s", bkpinfo->nfs_mount);
     628        log_msg(3, "isodir= %s", bkpinfo->isodir);
     629    }
     630    if (flag_set['c']) {
     631        bkpinfo->backup_media_type = cdr;
     632    }
     633    if (flag_set['C']) {
     634        bkpinfo->backup_media_type = cdstream;
     635    }
     636    if (flag_set['i']) {
     637        bkpinfo->backup_media_type = iso;
     638    }
     639    if (flag_set['n']) {
     640        bkpinfo->backup_media_type = nfs;
     641    }
     642    if (flag_set['r']) {
     643        bkpinfo->backup_media_type = dvd;
     644    }
     645    if (flag_set['t']) {
     646        bkpinfo->backup_media_type = tape;
     647    }
     648    if (flag_set['u']) {
     649        bkpinfo->backup_media_type = udev;
     650    }
     651    if (flag_set['w']) {
     652        bkpinfo->backup_media_type = cdrw;
     653    }
     654
     655/* optional, popular */
     656    if (flag_set['g']) {
     657        g_text_mode = FALSE;
     658    }
     659    if (flag_set['E']) {
     660        if (bkpinfo->exclude_paths[0]) {
     661            strcat(bkpinfo->exclude_paths, " ");
     662        }
     663        strncpy(bkpinfo->exclude_paths + strlen(bkpinfo->exclude_paths),
     664                flag_val['E'],
     665                MAX_STR_LEN - strlen(bkpinfo->exclude_paths));
     666    }
     667    if (flag_set['e']) {
     668        bkpinfo->please_dont_eject = TRUE;
     669    }
     670    if (flag_set['N'])          // exclude NFS mounts & devices
    567671    {
    568       if (flag_set['s'])
    569         {
    570               if (flag_set['t']) { fatal_error("For the moment, please don't specify a tape size. Mondo should handle end-of-tape gracefully anyway."); }
    571               if (process_the_s_switch(bkpinfo, flag_val['s'])) {fatal_error("Bad -s switch");}
    572             }
    573       else if (flag_set['u'] || flag_set['t'])
    574             {
    575           for(i=0; i<=MAX_NOOF_MEDIA; i++) { bkpinfo->media_size[i] = 0; }
    576         }
    577       else
    578         {
    579           retval++;
    580           log_to_screen( "Tape size not specified.\n");
    581         }
    582     }
    583     }
    584   else
    585     {               /* CD size */
    586       if (flag_set['s'])
    587     {
    588           if (process_the_s_switch(bkpinfo, flag_val['s'])) {fatal_error("Bad -s switch");}
    589     }
    590       if (flag_set['w'])
    591     {
    592       bkpinfo->wipe_media_first = TRUE;
    593     }           /* CD-RW */
    594     }
    595   if (flag_set['n'])
    596     {
    597       strncpy (bkpinfo->nfs_mount, flag_val['n'], MAX_STR_LEN);
    598       if (!flag_set['d'])
    599     {
    600       strncpy (bkpinfo->nfs_remote_dir, "/", MAX_STR_LEN);
    601     }
    602       sprintf (tmp, "mount | grep -x \"%s .*\" | cut -d' ' -f3",
    603            bkpinfo->nfs_mount);
    604       strncpy (bkpinfo->isodir,
    605           call_program_and_get_last_line_of_output (tmp), MAX_STR_LEN/4);
    606       if (strlen (bkpinfo->isodir) < 3)
    607     {
    608       retval++;
    609       log_to_screen( "NFS share is not mounted. Please mount it.\n");
    610     }
    611       log_msg(3, "mount = %s", bkpinfo->nfs_mount);
    612       log_msg(3, "isodir= %s", bkpinfo->isodir);
    613     }     
    614   if (flag_set['c']) { bkpinfo->backup_media_type = cdr; }
    615   if (flag_set['C']) { bkpinfo->backup_media_type = cdstream; }
    616   if (flag_set['i']) { bkpinfo->backup_media_type = iso; }
    617   if (flag_set['n']) { bkpinfo->backup_media_type = nfs; }
    618   if (flag_set['r']) { bkpinfo->backup_media_type = dvd; }
    619   if (flag_set['t']) { bkpinfo->backup_media_type = tape; }
    620   if (flag_set['u']) { bkpinfo->backup_media_type = udev; }
    621   if (flag_set['w']) { bkpinfo->backup_media_type = cdrw; }
    622 
    623 /* optional, popular */
    624   if (flag_set['g'])
    625     {
    626       g_text_mode = FALSE;
    627     }
    628   if (flag_set['E'])
    629     {
    630       if (bkpinfo->exclude_paths[0])
    631         { strcat(bkpinfo->exclude_paths," "); }
    632       strncpy (bkpinfo->exclude_paths+strlen(bkpinfo->exclude_paths), flag_val['E'], MAX_STR_LEN - strlen(bkpinfo->exclude_paths));
    633     }
    634   if (flag_set['e'])
    635     {
    636       bkpinfo->please_dont_eject = TRUE;
    637     }
    638   if (flag_set['N']) // exclude NFS mounts & devices
    639     {
    640672//      strncpy(psz, list_of_NFS_devices_and_mounts(), MAX_STR_LEN);
    641       strncpy(psz, list_of_NFS_mounts_only(), MAX_STR_LEN);
    642       if (bkpinfo->exclude_paths[0]) { strncat(bkpinfo->exclude_paths, " ", MAX_STR_LEN); }
    643       strncat(bkpinfo->exclude_paths, psz, MAX_STR_LEN);
    644       log_msg(3, "-N means we're now excluding %s", bkpinfo->exclude_paths);
    645     }
    646   if (strlen(bkpinfo->exclude_paths) >= MAX_STR_LEN)
    647     {
    648       fatal_error("Your '-E' parameter is too long. Please use '-J'. (See manual.)");
    649     }
    650   if (flag_set['b'])
    651     {
    652       strcpy(psz, flag_val['b']);
    653       log_msg(1, "psz = '%s'", psz);
    654       if (psz[strlen(psz)-1] == 'k')
    655     { psz[strlen(psz)-1] = '\0'; itbs = atol(psz) * 1024L; }
    656       else
    657     { itbs = atol(psz); }
    658       log_msg(1, "'%s' --> %ld", flag_val['b'], itbs);
    659       log_msg(1, "Internal tape block size is now %ld bytes", itbs);
    660       if (itbs%512!=0 || itbs < 256 || itbs > 1024L*1024)
    661     { fatal_error("Are you nuts? Silly, your internal tape block size is. Abort, I shall."); }
    662       bkpinfo->internal_tape_block_size = itbs;
    663     }
    664   if (flag_set['D'])
    665     {
    666       bkpinfo->differential = 1;
     673        strncpy(psz, list_of_NFS_mounts_only(), MAX_STR_LEN);
     674        if (bkpinfo->exclude_paths[0]) {
     675            strncat(bkpinfo->exclude_paths, " ", MAX_STR_LEN);
     676        }
     677        strncat(bkpinfo->exclude_paths, psz, MAX_STR_LEN);
     678        log_msg(3, "-N means we're now excluding %s",
     679                bkpinfo->exclude_paths);
     680    }
     681    if (strlen(bkpinfo->exclude_paths) >= MAX_STR_LEN) {
     682        fatal_error
     683            ("Your '-E' parameter is too long. Please use '-J'. (See manual.)");
     684    }
     685    if (flag_set['b']) {
     686        strcpy(psz, flag_val['b']);
     687        log_msg(1, "psz = '%s'", psz);
     688        if (psz[strlen(psz) - 1] == 'k') {
     689            psz[strlen(psz) - 1] = '\0';
     690            itbs = atol(psz) * 1024L;
     691        } else {
     692            itbs = atol(psz);
     693        }
     694        log_msg(1, "'%s' --> %ld", flag_val['b'], itbs);
     695        log_msg(1, "Internal tape block size is now %ld bytes", itbs);
     696        if (itbs % 512 != 0 || itbs < 256 || itbs > 1024L * 1024) {
     697            fatal_error
     698                ("Are you nuts? Silly, your internal tape block size is. Abort, I shall.");
     699        }
     700        bkpinfo->internal_tape_block_size = itbs;
     701    }
     702    if (flag_set['D']) {
     703        bkpinfo->differential = 1;
    667704//      bkpinfo->differential = atoi (flag_val['D']);
    668       if ((bkpinfo->differential < 1) || (bkpinfo->differential > 9))
    669     {
    670         fatal_error ("The D option should be between 1 and 9 inclusive");
    671     }
    672     }
    673   if (flag_set['x'])
    674     {
    675       strncpy (bkpinfo->image_devs, flag_val['x'], MAX_STR_LEN/4);
    676       if (run_program_and_log_output("which partimagehack", 2))
    677         { fatal_error("Please install partimagehack RPM/tarball."); }
    678     }
    679   if (flag_set['m'])
    680     {
    681       bkpinfo->manual_cd_tray = TRUE;
    682     }
    683   if (flag_set['k'])
    684     {
    685       strncpy (bkpinfo->kernel_path, flag_val['k'], MAX_STR_LEN);
    686       if (!strcmp (bkpinfo->kernel_path, "failsafe"))
    687     {
    688       strcpy (bkpinfo->kernel_path, "FAILSAFE");
    689     }
    690       if (strcmp (bkpinfo->kernel_path, "FAILSAFE")
    691       && !does_file_exist (bkpinfo->kernel_path))
    692     {
    693       retval++;
    694       sprintf(tmp,
    695            "You specified kernel '%s', which does not exist\n",
    696            bkpinfo->kernel_path);
    697           log_to_screen(tmp);
    698     }
    699     }
    700 if (flag_set['p'])
    701     {
    702       strncpy (bkpinfo->prefix, flag_val['p'], MAX_STR_LEN/4);
    703     }
    704 
    705 
    706   if (flag_set['d'])
    707     {               /* backup directory (if ISO/NFS) */
    708       if (flag_set['i'])
    709     {
    710       strncpy (bkpinfo->isodir, flag_val['d'], MAX_STR_LEN/4);
    711           sprintf(tmp, "ls -l %s", bkpinfo->isodir);
    712           if (run_program_and_log_output(tmp, FALSE)) { fatal_error("output folder does not exist - please create it"); }
    713     }
    714       else if (flag_set['n'])
    715     {
    716       strncpy (bkpinfo->nfs_remote_dir, flag_val['d'], MAX_STR_LEN);
    717     }
    718       else          /* backup device (if tape/CD-R/CD-RW) */
    719     {
    720       strncpy (bkpinfo->media_device, flag_val['d'], MAX_STR_LEN/4);
    721     }
    722     }
    723 
    724   if (flag_set['n'])
    725     {
    726       sprintf (tmp, "echo hi > %s/%s/.dummy.txt", bkpinfo->isodir, bkpinfo->nfs_remote_dir);
    727       if (run_program_and_log_output (tmp, FALSE))
    728     {
    729       retval++;
    730       sprintf (tmp, "Are you sure directory '%s' exists in remote dir '%s'?\nIf so, do you have rights to write to it?\n",
    731            bkpinfo->nfs_remote_dir, bkpinfo->nfs_mount);
    732           log_to_screen (tmp);
    733     }
    734     }
    735 
    736   if (!flag_set['d'] && (flag_set['c'] || flag_set['w'] || flag_set['C']))
    737     {
    738       if (g_kernel_version >= 2.6)
    739         {
    740       if (popup_and_get_string("Device", "Please specify the device", bkpinfo->media_device, MAX_STR_LEN/4))
    741             {
    742           retval ++;
    743           log_to_screen("User opted to cancel.");
    744         }
    745     }
    746       else if (find_cdrw_device (bkpinfo->media_device))
    747     {
    748       retval++;
    749       log_to_screen(
    750            "Tried and failed to find CD-R[W] drive automatically.\n");
    751     }
    752       else
    753     {
    754       flag_set['d'] = TRUE;
    755       strncpy (flag_val['d'], bkpinfo->media_device, MAX_STR_LEN/4);
    756     }
    757     }
    758 
    759   if (!flag_set['d'] && !flag_set['n'] && !flag_set['C'])
    760     {
    761       retval++;
    762       log_to_screen( "Please specify the backup device/directory.\n");
    763       fatal_error("You didn't use -d to specify the backup device/directory.");
    764     }
     705        if ((bkpinfo->differential < 1) || (bkpinfo->differential > 9)) {
     706            fatal_error
     707                ("The D option should be between 1 and 9 inclusive");
     708        }
     709    }
     710    if (flag_set['x']) {
     711        strncpy(bkpinfo->image_devs, flag_val['x'], MAX_STR_LEN / 4);
     712        if (run_program_and_log_output("which partimagehack", 2)) {
     713            fatal_error("Please install partimagehack RPM/tarball.");
     714        }
     715    }
     716    if (flag_set['m']) {
     717        bkpinfo->manual_cd_tray = TRUE;
     718    }
     719    if (flag_set['k']) {
     720        strncpy(bkpinfo->kernel_path, flag_val['k'], MAX_STR_LEN);
     721        if (!strcmp(bkpinfo->kernel_path, "failsafe")) {
     722            strcpy(bkpinfo->kernel_path, "FAILSAFE");
     723        }
     724        if (strcmp(bkpinfo->kernel_path, "FAILSAFE")
     725            && !does_file_exist(bkpinfo->kernel_path)) {
     726            retval++;
     727            sprintf(tmp,
     728                    "You specified kernel '%s', which does not exist\n",
     729                    bkpinfo->kernel_path);
     730            log_to_screen(tmp);
     731        }
     732    }
     733    if (flag_set['p']) {
     734        strncpy(bkpinfo->prefix, flag_val['p'], MAX_STR_LEN / 4);
     735    }
     736
     737
     738    if (flag_set['d']) {        /* backup directory (if ISO/NFS) */
     739        if (flag_set['i']) {
     740            strncpy(bkpinfo->isodir, flag_val['d'], MAX_STR_LEN / 4);
     741            sprintf(tmp, "ls -l %s", bkpinfo->isodir);
     742            if (run_program_and_log_output(tmp, FALSE)) {
     743                fatal_error
     744                    ("output folder does not exist - please create it");
     745            }
     746        } else if (flag_set['n']) {
     747            strncpy(bkpinfo->nfs_remote_dir, flag_val['d'], MAX_STR_LEN);
     748        } else {                /* backup device (if tape/CD-R/CD-RW) */
     749
     750            strncpy(bkpinfo->media_device, flag_val['d'], MAX_STR_LEN / 4);
     751        }
     752    }
     753
     754    if (flag_set['n']) {
     755        sprintf(tmp, "echo hi > %s/%s/.dummy.txt", bkpinfo->isodir,
     756                bkpinfo->nfs_remote_dir);
     757        if (run_program_and_log_output(tmp, FALSE)) {
     758            retval++;
     759            sprintf(tmp,
     760                    "Are you sure directory '%s' exists in remote dir '%s'?\nIf so, do you have rights to write to it?\n",
     761                    bkpinfo->nfs_remote_dir, bkpinfo->nfs_mount);
     762            log_to_screen(tmp);
     763        }
     764    }
     765
     766    if (!flag_set['d']
     767        && (flag_set['c'] || flag_set['w'] || flag_set['C'])) {
     768        if (g_kernel_version >= 2.6) {
     769            if (popup_and_get_string
     770                ("Device", "Please specify the device",
     771                 bkpinfo->media_device, MAX_STR_LEN / 4)) {
     772                retval++;
     773                log_to_screen("User opted to cancel.");
     774            }
     775        } else if (find_cdrw_device(bkpinfo->media_device)) {
     776            retval++;
     777            log_to_screen
     778                ("Tried and failed to find CD-R[W] drive automatically.\n");
     779        } else {
     780            flag_set['d'] = TRUE;
     781            strncpy(flag_val['d'], bkpinfo->media_device, MAX_STR_LEN / 4);
     782        }
     783    }
     784
     785    if (!flag_set['d'] && !flag_set['n'] && !flag_set['C']) {
     786        retval++;
     787        log_to_screen("Please specify the backup device/directory.\n");
     788        fatal_error
     789            ("You didn't use -d to specify the backup device/directory.");
     790    }
    765791/* optional, obscure */
    766   for (i = '0'; i <= '9'; i++)
    767     {
    768       if (flag_set[i])
    769     {
    770       bkpinfo->compression_level = i - '0';
    771     }           /* not '\0' but '0' */
    772     }
    773   if (flag_set['S'])
    774     {
    775       sprintf (bkpinfo->scratchdir, "%s/mondo.scratch.%ld", flag_val['S'],
    776            random () % 32768);
    777     }
    778   if (flag_set['T'])
    779     {
    780       sprintf (bkpinfo->tmpdir, "%s/tmp.mondo.%ld", flag_val['T'],
    781            random () % 32768);
    782       sprintf(tmp, "touch %s/.foo.dat", flag_val['T']);
    783       if (run_program_and_log_output(tmp, 1))
    784         {
    785       retval++;
    786       log_to_screen( "Please specify a tempdir which I can write to. :)");
    787       fatal_error("I cannot write to the tempdir you specified.");
    788     }
    789       sprintf(tmp, "ln -sf %s/.foo.dat %s/.bar.dat", flag_val['T'], flag_val['T']);
    790       if (run_program_and_log_output(tmp, 1))
    791         {
    792       retval++;
    793       log_to_screen("Please don't specify a SAMBA or VFAT or NFS tmpdir.");
    794       fatal_error("I cannot write to the tempdir you specified.");
    795     }     
    796     }
    797   if (flag_set['A'])
    798     {
    799       strncpy (bkpinfo->call_after_iso, flag_val['A'], MAX_STR_LEN);
    800     }
    801   if (flag_set['B'])
    802     {
    803       strncpy (bkpinfo->call_before_iso, flag_val['B'], MAX_STR_LEN);
    804     }
    805   if (flag_set['F'])
    806     {
    807       g_skip_floppies = TRUE;
    808     }
    809   if (flag_set['H'])
    810     {
    811       g_cd_recovery = TRUE;
    812     }
    813   if (flag_set['l'])
    814     {
     792    for (i = '0'; i <= '9'; i++) {
     793        if (flag_set[i]) {
     794            bkpinfo->compression_level = i - '0';
     795        }                       /* not '\0' but '0' */
     796    }
     797    if (flag_set['S']) {
     798        sprintf(bkpinfo->scratchdir, "%s/mondo.scratch.%ld", flag_val['S'],
     799                random() % 32768);
     800    }
     801    if (flag_set['T']) {
     802        sprintf(bkpinfo->tmpdir, "%s/tmp.mondo.%ld", flag_val['T'],
     803                random() % 32768);
     804        sprintf(tmp, "touch %s/.foo.dat", flag_val['T']);
     805        if (run_program_and_log_output(tmp, 1)) {
     806            retval++;
     807            log_to_screen
     808                ("Please specify a tempdir which I can write to. :)");
     809            fatal_error("I cannot write to the tempdir you specified.");
     810        }
     811        sprintf(tmp, "ln -sf %s/.foo.dat %s/.bar.dat", flag_val['T'],
     812                flag_val['T']);
     813        if (run_program_and_log_output(tmp, 1)) {
     814            retval++;
     815            log_to_screen
     816                ("Please don't specify a SAMBA or VFAT or NFS tmpdir.");
     817            fatal_error("I cannot write to the tempdir you specified.");
     818        }
     819    }
     820    if (flag_set['A']) {
     821        strncpy(bkpinfo->call_after_iso, flag_val['A'], MAX_STR_LEN);
     822    }
     823    if (flag_set['B']) {
     824        strncpy(bkpinfo->call_before_iso, flag_val['B'], MAX_STR_LEN);
     825    }
     826    if (flag_set['F']) {
     827        g_skip_floppies = TRUE;
     828    }
     829    if (flag_set['H']) {
     830        g_cd_recovery = TRUE;
     831    }
     832    if (flag_set['l']) {
    815833#ifdef __FreeBSD__
    816834#  define BOOT_LOADER_CHARS "GLBMR"
     
    822840#  endif
    823841#endif
    824       if (!strchr(BOOT_LOADER_CHARS, (bkpinfo->boot_loader = flag_val['l'][0])))
    825     {
    826       log_msg(1, "%c? WTF is %c? I need G, L, E or R.", bkpinfo->boot_loader, bkpinfo->boot_loader);
    827       fatal_error("Please specify GRUB, LILO, ELILO  or RAW with the -l switch");
    828     }
     842        if (!strchr
     843            (BOOT_LOADER_CHARS,
     844             (bkpinfo->boot_loader = flag_val['l'][0]))) {
     845            log_msg(1, "%c? WTF is %c? I need G, L, E or R.",
     846                    bkpinfo->boot_loader, bkpinfo->boot_loader);
     847            fatal_error
     848                ("Please specify GRUB, LILO, ELILO  or RAW with the -l switch");
     849        }
    829850#undef BOOT_LOADER_CHARS
    830     }
    831   if (flag_set['f'])
    832     {
    833       strncpy (bkpinfo->boot_device, resolve_softlinks_to_get_to_actual_device_file(flag_val['f']), MAX_STR_LEN/4);
    834     }
    835   if (flag_set['P'])
    836     {
    837       strncpy (bkpinfo->postnuke_tarball, flag_val['P'], MAX_STR_LEN);
    838     }
    839   if (flag_set['Q'])
    840     {
    841       i = which_boot_loader(tmp);
    842       log_msg(3, "boot loader is %c, residing at %s", i, tmp);
    843       printf("boot loader is %c, residing at %s\n", i, tmp);
    844       finish(0);
    845     }
    846   if (flag_set['L'])
    847     {
    848       bkpinfo->use_lzo = TRUE;
    849       if (run_program_and_log_output ("which lzop", FALSE))
    850     {
    851       retval++;
    852       log_to_screen(
    853            "Please install LZOP. You can't use '-L' until you do.\n");
    854     }
    855     }
    856 
    857   if (!flag_set['o'] && !run_program_and_log_output("cat /etc/issue.net | grep -i suse | grep 64", TRUE))
    858     {
    859       bkpinfo->make_cd_use_lilo = TRUE;
    860       log_to_screen("Forcing you to use LILO. SuSE 9.0 (64-bit) has a broken mkfs.vfat binary.");
    861     }
    862   if (flag_set['o'])
    863     {
    864       bkpinfo->make_cd_use_lilo = TRUE;
    865     }
     851    }
     852    if (flag_set['f']) {
     853        strncpy(bkpinfo->boot_device,
     854                resolve_softlinks_to_get_to_actual_device_file(flag_val
     855                                                               ['f']),
     856                MAX_STR_LEN / 4);
     857    }
     858    if (flag_set['P']) {
     859        strncpy(bkpinfo->postnuke_tarball, flag_val['P'], MAX_STR_LEN);
     860    }
     861    if (flag_set['Q']) {
     862        i = which_boot_loader(tmp);
     863        log_msg(3, "boot loader is %c, residing at %s", i, tmp);
     864        printf("boot loader is %c, residing at %s\n", i, tmp);
     865        finish(0);
     866    }
     867    if (flag_set['L']) {
     868        bkpinfo->use_lzo = TRUE;
     869        if (run_program_and_log_output("which lzop", FALSE)) {
     870            retval++;
     871            log_to_screen
     872                ("Please install LZOP. You can't use '-L' until you do.\n");
     873        }
     874    }
     875
     876    if (!flag_set['o']
     877        &&
     878        !run_program_and_log_output
     879        ("cat /etc/issue.net | grep -i suse | grep 64", TRUE)) {
     880        bkpinfo->make_cd_use_lilo = TRUE;
     881        log_to_screen
     882            ("Forcing you to use LILO. SuSE 9.0 (64-bit) has a broken mkfs.vfat binary.");
     883    }
     884    if (flag_set['o']) {
     885        bkpinfo->make_cd_use_lilo = TRUE;
     886    }
    866887#ifndef __FreeBSD__
    867   else
    868     {
    869       if (!is_this_a_valid_disk_format("vfat"))
    870         {
    871       bkpinfo->make_cd_use_lilo = TRUE;
    872       log_to_screen( "Your kernel appears not to support vfat filesystems. I am therefore");
    873       log_to_screen( "using LILO instead of SYSLINUX as the CD/floppy's boot loader.");
    874         }
    875       if (run_program_and_log_output("which mkfs.vfat", FALSE))
    876         {
    877       bkpinfo->make_cd_use_lilo = TRUE;
     888    else {
     889        if (!is_this_a_valid_disk_format("vfat")) {
     890            bkpinfo->make_cd_use_lilo = TRUE;
     891            log_to_screen
     892                ("Your kernel appears not to support vfat filesystems. I am therefore");
     893            log_to_screen
     894                ("using LILO instead of SYSLINUX as the CD/floppy's boot loader.");
     895        }
     896        if (run_program_and_log_output("which mkfs.vfat", FALSE)) {
     897            bkpinfo->make_cd_use_lilo = TRUE;
    878898#ifdef __IA32__
    879       log_to_screen( "Your filesystem is missing 'mkfs.vfat', so I cannot use SYSLINUX as");
    880       log_to_screen( "your boot loader. I shall therefore use LILO instead.");
     899            log_to_screen
     900                ("Your filesystem is missing 'mkfs.vfat', so I cannot use SYSLINUX as");
     901            log_to_screen
     902                ("your boot loader. I shall therefore use LILO instead.");
    881903#endif
    882904#ifdef __IA64__
    883       log_to_screen( "Your filesystem is missing 'mkfs.vfat', so I cannot prepare the EFI");
    884       log_to_screen( "environment correctly. Please install it.");
    885       fatal_error("Aborting");
     905            log_to_screen
     906                ("Your filesystem is missing 'mkfs.vfat', so I cannot prepare the EFI");
     907            log_to_screen("environment correctly. Please install it.");
     908            fatal_error("Aborting");
    886909#endif
    887     }
     910        }
    888911#ifdef __IA64__
    889       /* We force ELILO usage on IA64 */
    890       bkpinfo->make_cd_use_lilo = TRUE;
     912        /* We force ELILO usage on IA64 */
     913        bkpinfo->make_cd_use_lilo = TRUE;
    891914#endif
    892     }
     915    }
    893916#endif
    894917
    895   if (bkpinfo->make_cd_use_lilo && !does_file_exist("/boot/boot.b"))
    896     {
    897       paranoid_system("touch /boot/boot.b");
    898     }
    899 
    900   i = flag_set['O'] + flag_set['V'];
    901   if (i == 0)
    902     {
    903       retval++;
    904       log_to_screen( "Specify backup (-O), verify (-V) or both (-OV).\n");
    905     }
     918    if (bkpinfo->make_cd_use_lilo && !does_file_exist("/boot/boot.b")) {
     919        paranoid_system("touch /boot/boot.b");
     920    }
     921
     922    i = flag_set['O'] + flag_set['V'];
     923    if (i == 0) {
     924        retval++;
     925        log_to_screen("Specify backup (-O), verify (-V) or both (-OV).\n");
     926    }
    906927
    907928/* and finally... */
    908929
    909   paranoid_free(tmp);
    910   paranoid_free(psz); 
    911   return (retval);
     930    paranoid_free(tmp);
     931    paranoid_free(psz);
     932    return (retval);
    912933}
    913934
     
    926947 */
    927948int
    928 retrieve_switches_from_command_line (int argc, char *argv[],
    929                      char flag_val[128][MAX_STR_LEN],
    930                      bool flag_set[128])
     949retrieve_switches_from_command_line(int argc, char *argv[],
     950                                    char flag_val[128][MAX_STR_LEN],
     951                                    bool flag_set[128])
    931952{
    932     /*@ ints ***/
    933   int opt = 0;
    934   char tmp[MAX_STR_LEN];
    935   int i = 0;
    936   int len;
    937 
    938     /*@ bools ****/
    939   bool bad_switches = FALSE;
    940 
    941   assert(flag_val!=NULL);
    942   assert(flag_set!=NULL);
    943 
    944   for (i = 0; i < 128; i++)
    945     {
    946       flag_val[i][0] = '\0';
    947       flag_set[i] = FALSE;
    948     }
    949   while ((opt =
    950       getopt (argc, argv,
    951           "0123456789A:B:CDE:FHI:J:K:LNOP:QRS:T:VWb:c:d:ef:gik:l:mn:op:rs:tuw:x:")) !=
    952      -1)
    953     {
    954       if (opt == '?')
    955     {
    956       bad_switches = TRUE;
    957       /*log_it("Invalid option: %c\n",optopt); */
    958     }
    959       else
    960     {
    961       if (flag_set[optopt])
    962         {
    963           bad_switches = TRUE;
    964           sprintf(tmp, "Switch -%c previously defined as %s\n", opt,
    965                flag_val[i]);
    966               log_to_screen(tmp);
    967         }
    968       else
    969         {
    970           flag_set[opt] = TRUE;
    971           if (optarg)
    972         {
    973                   len = strlen(optarg);
    974                   if (optarg[0] != '/' && optarg[len-1] == '/')
    975                     {
    976                       optarg[--len] = '\0';
    977               log_to_screen("Warning - param '%s' should not have trailing slash!", optarg);
    978             }
    979                   if (opt=='d')
    980                     {
    981                       if (strchr(flag_val[opt], '/') && flag_val[opt][0]!='/')
    982                         {
    983                           sprintf(tmp, "-%c flag --- must be absolute path --- '%s' isn't absolute", opt, flag_val[opt]);
    984                           log_to_screen(tmp);
    985                           bad_switches = TRUE;
    986                         }
    987             }
    988           strcpy(flag_val[opt], optarg);
    989         }
    990         }
    991     }
    992     }
    993   for (i = optind; i < argc; i++)
    994     {
    995       bad_switches = TRUE;
    996       sprintf(tmp, "Invalid arg -- %s\n", argv[i]);
    997       log_to_screen(tmp);
    998     }
    999   return (bad_switches);
     953    /*@ ints ** */
     954    int opt = 0;
     955    char tmp[MAX_STR_LEN];
     956    int i = 0;
     957    int len;
     958
     959    /*@ bools *** */
     960    bool bad_switches = FALSE;
     961
     962    assert(flag_val != NULL);
     963    assert(flag_set != NULL);
     964
     965    for (i = 0; i < 128; i++) {
     966        flag_val[i][0] = '\0';
     967        flag_set[i] = FALSE;
     968    }
     969    while ((opt =
     970            getopt(argc, argv,
     971                   "0123456789A:B:C:DE:FHI:J:K:LNOP:QRS:T:VWb:c:d:ef:gik:l:mn:op:rs:tuw:x:"))
     972           != -1) {
     973        if (opt == '?') {
     974            bad_switches = TRUE;
     975            /*log_it("Invalid option: %c\n",optopt); */
     976        } else {
     977            if (flag_set[optopt]) {
     978                bad_switches = TRUE;
     979                sprintf(tmp, "Switch -%c previously defined as %s\n", opt,
     980                        flag_val[i]);
     981                log_to_screen(tmp);
     982            } else {
     983                flag_set[opt] = TRUE;
     984                if (optarg) {
     985                    len = strlen(optarg);
     986                    if (optarg[0] != '/' && optarg[len - 1] == '/') {
     987                        optarg[--len] = '\0';
     988                        log_to_screen
     989                            ("Warning - param '%s' should not have trailing slash!",
     990                             optarg);
     991                    }
     992                    if (opt == 'd') {
     993                        if (strchr(flag_val[opt], '/')
     994                            && flag_val[opt][0] != '/') {
     995                            sprintf(tmp,
     996                                    "-%c flag --- must be absolute path --- '%s' isn't absolute",
     997                                    opt, flag_val[opt]);
     998                            log_to_screen(tmp);
     999                            bad_switches = TRUE;
     1000                        }
     1001                    }
     1002                    strcpy(flag_val[opt], optarg);
     1003                }
     1004            }
     1005        }
     1006    }
     1007    for (i = optind; i < argc; i++) {
     1008        bad_switches = TRUE;
     1009        sprintf(tmp, "Invalid arg -- %s\n", argv[i]);
     1010        log_to_screen(tmp);
     1011    }
     1012    return (bad_switches);
    10001013}
    10011014
     
    10061019 * Print a not-so-helpful help message and exit.
    10071020 */
    1008 void
    1009 help_screen ()
     1021void help_screen()
    10101022{
    1011   log_msg(1, "Type 'man mondo-archive' for more information\n");
    1012   exit (1);
     1023    log_msg(1, "Type 'man mondo-archive' for more information\n");
     1024    exit(1);
    10131025}
    10141026
     
    10201032void terminate_daemon(int sig)
    10211033{
    1022   char tmp[64];
    1023   char tmp2 [MAX_STR_LEN];
    1024   //  char command[512];
    1025   //  pid_t pid;
    1026 
    1027   switch(sig)
    1028     {
     1034    char tmp[64];
     1035    char tmp2[MAX_STR_LEN];
     1036    //  char command[512];
     1037    //  pid_t pid;
     1038
     1039    switch (sig) {
    10291040    case SIGINT:
    10301041        sprintf(tmp, "SIGINT");
     
    10331044    case SIGKILL:
    10341045        sprintf(tmp, "SIGKILL");
    1035         strcpy(tmp2, "I seriously have no clue how this signal even got to me. Something's wrong with your system.");
     1046        strcpy(tmp2,
     1047               "I seriously have no clue how this signal even got to me. Something's wrong with your system.");
    10361048        break;
    10371049    case SIGTERM:
    10381050        sprintf(tmp, "SIGTERM");
    1039         strcpy (tmp2, "Got terminate signal");
     1051        strcpy(tmp2, "Got terminate signal");
    10401052        break;
    10411053    case SIGHUP:
    10421054        sprintf(tmp, "SIGHUP");
    1043         strcpy (tmp2, "Hangup on line");
     1055        strcpy(tmp2, "Hangup on line");
    10441056        break;
    10451057    case SIGSEGV:
    10461058        sprintf(tmp, "SIGSEGV");
    1047         strcpy (tmp2, "Internal programming error. Please send a backtrace as well as your log.");
     1059        strcpy(tmp2,
     1060               "Internal programming error. Please send a backtrace as well as your log.");
    10481061        break;
    10491062    case SIGPIPE:
    10501063        sprintf(tmp, "SIGPIPE");
    1051         strcpy (tmp2, "Pipe was broken");
     1064        strcpy(tmp2, "Pipe was broken");
    10521065        break;
    1053     case SIGABRT:
    1054     sprintf (tmp, "SIGABRT");
    1055     sprintf (tmp2, "Abort - probably failed assertion. I'm sleeping for a few seconds so you can read the message.");
    1056     break;
     1066    case SIGABRT:
     1067        sprintf(tmp, "SIGABRT");
     1068        sprintf(tmp2,
     1069                "Abort - probably failed assertion. I'm sleeping for a few seconds so you can read the message.");
     1070        break;
    10571071    default:
    10581072        sprintf(tmp, "(Unknown)");
    1059     }
    1060 
    1061   strcat(tmp, " signal received from OS");
    1062   log_to_screen(tmp);
    1063   log_to_screen (tmp2);
    1064   if (sig == SIGABRT) {
    1065       sleep (10);
    1066   }
    1067   kill_buffer();
    1068   fatal_error("Mondoarchive is terminating in response to a signal from the OS");
    1069   finish(254); // just in case
     1073    }
     1074
     1075    strcat(tmp, " signal received from OS");
     1076    log_to_screen(tmp);
     1077    log_to_screen(tmp2);
     1078    if (sig == SIGABRT) {
     1079        sleep(10);
     1080    }
     1081    kill_buffer();
     1082    fatal_error
     1083        ("Mondoarchive is terminating in response to a signal from the OS");
     1084    finish(254);                // just in case
    10701085}
    10711086
     
    10791094void set_signals(int on)
    10801095{
    1081   int signals[]= { SIGTERM, SIGHUP, SIGTRAP, SIGABRT, SIGINT, SIGKILL, SIGSTOP, 0 };
    1082   int i;
    1083  
    1084   signal(SIGPIPE, sigpipe_occurred);
    1085   for (i=0; signals[i]; i++)
    1086     {
    1087       if (on)
    1088         { signal(signals[i], terminate_daemon); }
    1089       else
    1090         { signal(signals[i], termination_in_progress); }
    1091     }
     1096    int signals[] =
     1097        { SIGTERM, SIGHUP, SIGTRAP, SIGABRT, SIGINT, SIGKILL, SIGSTOP, 0 };
     1098    int i;
     1099
     1100    signal(SIGPIPE, sigpipe_occurred);
     1101    for (i = 0; signals[i]; i++) {
     1102        if (on) {
     1103            signal(signals[i], terminate_daemon);
     1104        } else {
     1105            signal(signals[i], termination_in_progress);
     1106        }
     1107    }
    10921108}
    10931109
     
    11011117void termination_in_progress(int sig)
    11021118{
    1103   log_msg(1, "Termination in progress");
    1104   usleep(1000);
    1105   pthread_exit(0);
     1119    log_msg(1, "Termination in progress");
     1120    usleep(1000);
     1121    pthread_exit(0);
    11061122}
    11071123
  • branches/2.05/mondo/mondo/mondoarchive/mondoarchive.8

    r30 r116  
    6969.BI "-r "
    7070Use DVD drive as backup device and its disks as backup media. Growisofs decides
    71 on the best speed for your drive.
     71on the best speed for your drive. Note that calling mondoarchive
     72.B using sudo when writing to DVDs will fail
     73because growisofs does not support this - see the growisofs manpage for
     74details.
    7275
    7376.TP
     
    321324A link to Mondo's HTML-based manual (by Mikael Hultgren, Cafeole, Randy Delphs,
    322325Stan Benoit, and me) may be found at
    323 .I http://www.microwerks.net/~hugo/docs/docs.html
     326.I http://www.mondorescue.org/docs/docs.html
    324327- or in
    325328.I /usr/share/doc/mondo-x.xx
     
    403406.SH AUTHORS
    404407Hugo Rabson (coding)
    405 .I "hugorabson@msn.comt"
     408.I "hugo.rabson@mondorescue.org"
    406409.br
    407410Jesse Keating (packaging)
     
    414417.I "mikael_hultgren@gmx.net"
    415418.br
    416 See mailing list at http://www.mondorescue.com for technical support.
     419See mailing list at http://www.mondorescue.org for technical support.
    417420.
  • branches/2.05/mondo/mondo/mondorestore/mondorestore.8

    r30 r116  
    3434A link to Mondo's HTML-based manual (by Mikael Hultgren, Cafeole, Randy Delphs,
    3535Stan Benoit, and me) may be found at
    36 .I http://www.microwerks.net/~hugo/docs/docs.html
     36.I http://www.mondorescue.org/docs/docs.html
    3737- or in
    3838.I /usr/share/doc/mondo-x.xx
     
    5151.SH AUTHORS
    5252Hugo Rabson (coding)
    53 .I "hugorabson@msn.comt"
     53.I "hugo.rabson@mondorescue.org"
    5454.br
    5555Jesse Keating (packaging)
     
    6262.I "mikael_hultgren@gmx.net"
    6363.br
    64 See mailing list at http://www.mondorescue.com for technical support.
     64See mailing list at http://www.mondorescue.org for technical support.
    6565.
Note: See TracChangeset for help on using the changeset viewer.