Changeset 126 in MondoRescue


Ignore:
Timestamp:
Nov 19, 2005, 1:53:52 AM (18 years ago)
Author:
bcornec
Message:

This patch avoids useless invocations of `cat <file> |' where the second
process in the pipe can more efficiently read its input file itself.
It replaces also some grep'+sed' commands by an unique `sed' command.
This patch also improves readability of shell commands by
replacing \" by ' where possible.
This patch instructs mondo to say DVD' instead of CD' when appropriate.
This patch forces growisofs to use speed=1 for DVD burning. In my
experience, DVD burning time is only a small part of the total backup
time so this should not make a big difference in backup time, but
a big one in reliability of mondo. On my installation, without
the option `speed=1', mondo/growisofs is unable to burn a DVD. With
the option `speed=1', mondo works.
(Philippe De Muyter)

Location:
branches/2.05/mondo/mondo
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/2.05/mondo/mondo/common/libmondo-archive.c

    r99 r126  
    501501  paranoid_system (command);
    502502
    503   sprintf (command, "cat %s | afio -o -b %ld -M 16m %s %s 2>> %s", filelist, TAPE_BLOCK_SIZE, zipparams, fname, MONDO_LOGFILE);
     503  sprintf (command, "afio -o -b %ld -M 16m %s %s < %s 2>> %s", TAPE_BLOCK_SIZE, zipparams, fname, filelist, MONDO_LOGFILE);
    504504
    505505  sprintf(tmp, "echo hi > %s 2> /dev/null", fname);
     
    701701  strcpy( scratchdir, bkpinfo->scratchdir);
    702702  sprintf (tmp,
    703        "echo \"%s\" | tr -s ' ' '\n' | grep -x \"/dev/.*\" | tr -s '\n' ' ' | awk '{print $0\"\\n\";}'",
     703       "echo '%s' | tr -s ' ' '\n' | grep -x '/dev/.*' | tr -s '\n' ' ' | awk '{print $0\"\\n\";}'",
    704704       bkpinfo->exclude_paths);
    705705  strcpy (devs_to_exclude, call_program_and_get_last_line_of_output (tmp));
     
    935935       
    936936       
    937     "mindi --custom %s %s/images \"%s\" \"%s\" \
    938 \"%s\" %ld \"%s\" \"%s\" \"%s\" \
    939 \"%s\" %s %ld \"%s\" \"%s\" \"%s\" \"%s\" %ld %d",
     937    "mindi --custom %s %s/images '%s' '%s' \
     938'%s' %ld '%s' '%s' '%s' \
     939'%s' %s %ld '%s' '%s' '%s' '%s' %ld %d",
    940940
    941941       bkpinfo->tmpdir,         // parameter #2
     
    990990    {
    991991      log_to_screen ("Mindi failed to create your boot+data disks.");
    992       sprintf (command, "cat %s | grep \"Fatal error\"", "/var/log/mindi.log");
     992      sprintf (command, "grep 'Fatal error' %s", "/var/log/mindi.log");
    993993      strcpy (tmp, call_program_and_get_last_line_of_output (command));
    994994      if (strlen (tmp) > 1)
     
    18181818            {
    18191819              log_to_screen ("%s...OK", message_to_screen);
    1820           if (!run_program_and_log_output("tail -n10 /var/log/mondo-archive.log | fgrep \":-(\"", 1))
     1820          if (!run_program_and_log_output("tail -n10 /var/log/mondo-archive.log | fgrep ':-('", 1))
    18211821            {
    18221822          log_to_screen("Despite nonfatal errors, growisofs confirms the write was successful.");
     
    18251825          retval += res;
    18261826#ifdef DVDRWFORMAT
    1827           sprintf(tmp, "cat %s | tail -n8 | grep \"blank=full.*dvd-compat.*DAO\"", MONDO_LOGFILE);
     1827          sprintf(tmp, "tail -n8 %s | grep 'blank=full.*dvd-compat.*DAO'", MONDO_LOGFILE);
    18281828      if (g_backup_media_type == dvd && (res || !run_program_and_log_output(tmp, 1)))
    18291829            {
     
    32623262    {
    32633263      file_to_openin = biggie_filename;
    3264       sprintf (command, "md5sum \"%s\"", biggie_filename);
     3264      sprintf (command, "md5sum '%s'", biggie_filename);
    32653265      if (!(fin = popen (command, "r"))) { log_OS_error("Unable to popen-in command"); return(1); }
    32663266      (void) fgets (checksum_line, MAX_STR_LEN, fin);
     
    36413641    {
    36423642      log_to_screen
    3643         ("Please reboot from the 1st CD in Compare Mode, as a precaution.");
     3643        ("Please reboot from the 1st %s in Compare Mode, as a precaution.", media_descriptor_string(g_backup_media_type));
    36443644      chdir ("/");
    36453645      iamhere("Before calling verify_cd_image()");
     
    37933793*/
    37943794          sprintf (tmp,
    3795        "cat %s | grep \"afio: \" | sed 's/afio: //' | grep -vx \"/dev/.*\" >> /tmp/changed.files",
     3795       "sed -n -e 's/afio: //p' %s | grep -vx '/dev/.*' >> /tmp/changed.files",
    37963796       MONDO_LOGFILE);
    37973797      system (tmp);
    37983798         
    37993799      sprintf (tmp,
    3800        "cat %s | grep \"star: \" | sed 's/star: //' | grep -vx \"/dev/.*\" >> /tmp/changed.files",
     3800       "sed -n -e 's/star: //p' %s | grep -vx '/dev/.*' >> /tmp/changed.files",
    38013801       MONDO_LOGFILE);
    38023802      system (tmp);
  • branches/2.05/mondo/mondo/common/libmondo-devices.c

    r123 r126  
    20792079                 if ((bkpinfo->compression_level = which_compression_level()) == -1)
    20802080                     { log_to_screen("User has chosen not to backup the PC"); finish(1); }
    2081                  if (!popup_and_get_string ("ISO size.", "Please enter how big you want each ISO image to be (in megabytes). This should be less than or equal to the size of the CD-R[W]'s you plan to backup to.", sz_size, 16))
     2081                 if (!popup_and_get_string ("ISO size.", "Please enter how big you want each ISO image to be (in megabytes). This should be less than or equal to the size of the CD-R[W]'s or DVD's you plan to backup to.", sz_size, 16))
    20822082                     { log_to_screen ("User has chosen not to backup the PC"); finish(1); }
    20832083                 for(i=0; i<=MAX_NOOF_MEDIA; i++) { bkpinfo->media_size[i] = atoi (sz_size); }
  • branches/2.05/mondo/mondo/common/libmondo-files.c

    r116 r126  
    569569        return (output);
    570570    }
    571     sprintf(command, "cat %s | tail -n1", filename);
     571    sprintf(command, "tail -n1 %s", filename);
    572572    fin = popen(command, "r");
    573573    (void) fgets(output, MAX_STR_LEN, fin);
     
    13091309    if (scratchLL <= 1) {
    13101310        sprintf(tmp,
    1311                 "Your backup will probably occupy a single CD/tape/ISO. Maybe two.");
     1311                "Your backup will probably occupy a single %s. Maybe two.",
     1312                media_descriptor_string(bkpinfo->backup_media_type));
    13121313    } else if (scratchLL > 4) {
    13131314        sprintf(tmp,
  • branches/2.05/mondo/mondo/common/libmondo-tools.c

    r99 r126  
    422422get_time ()
    423423{
    424 
    425 #if 0
    426 
    427     /*@ pointers *****************************************************/
    428   FILE *fin;
    429 
    430     /*@ buffers ******************************************************/
    431   char incoming[MAX_STR_LEN];
    432 
    433     /*@ end vars *****************************************************/
    434 
    435   if (!(fin = popen ("date +%s", "r"))) { log_OS_error("Cannot popen date"); return(0); }
    436   fgets (incoming, MAX_STR_LEN - 1, fin);
    437   paranoid_pclose (fin);
    438   return (atol (incoming));
    439 #else
    440424  return (long) time ((void *) 0);
    441 #endif
    442425}
    443426
  • branches/2.05/mondo/mondo/common/my-stuff.h

    r102 r126  
    345345 * @c growisofs command to generate a bootable DVD using isolinux, except for the directory to image.
    346346 */
    347 #define MONDO_GROWISOFS_REGULAR_SYSLINUX "growisofs -use-the-force-luke -J -no-emul-boot -boot-load-size 4 -b isolinux.bin --boot-info-table -c boot.cat -boot-load-size 4 -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL_Version -V _CD#_ -v"
     347#define MONDO_GROWISOFS_REGULAR_SYSLINUX "growisofs -speed=1 -use-the-force-luke -J -no-emul-boot -boot-load-size 4 -b isolinux.bin --boot-info-table -c boot.cat -boot-load-size 4 -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL_Version -V _CD#_ -v"
    348348
    349349/**
    350350 * @c growisofs command to generate a bootable DVD using LILO, except for the directory to image.
    351351 */ // -b images/mindi-boot.2880.img
    352 #define MONDO_GROWISOFS_REGULAR_ELILO     "growisofs -use-the-force-luke -no-emul-boot -b images/mindi-boot.2880.img -c boot.cat -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ -v"
     352#define MONDO_GROWISOFS_REGULAR_ELILO     "growisofs -speed=1 -use-the-force-luke -no-emul-boot -b images/mindi-boot.2880.img -c boot.cat -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ -v"
    353353
    354354/**
    355355 * @c growisofs command to generate a bootable DVD using LILO, except for the directory to image.
    356356 */ // -b images/mindi-boot.2880.img
    357 #define MONDO_GROWISOFS_REGULAR_LILO     "growisofs -no-emul-boot -b isolinux.bin -c boot.cat -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ -v"
     357#define MONDO_GROWISOFS_REGULAR_LILO     "growisofs -speed=1 -no-emul-boot -b isolinux.bin -c boot.cat -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ -v"
    358358
    359359/**
    360360 * @c growisofs command to generate a nonbootable DVD, except for the directory to image.
    361361 */
    362 #define MONDO_GROWISOFS_NONBOOT          "growisofs -use-the-force-luke -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ -v"
     362#define MONDO_GROWISOFS_NONBOOT          "growisofs -speed=1 -use-the-force-luke -J -r -p MondoRescue -publisher www.mondorescue.org -A Mondo_Rescue_GPL -V _CD#_ -v"
    363363
    364364/**
  • branches/2.05/mondo/mondo/common/newt-specific.c

    r99 r126  
    562562  if (grep_for_me[0] != '\0')
    563563    {
    564       sprintf (command, "cat %s | grep \"%s\" | tail -n%d", filename,
    565            grep_for_me, g_noof_log_lines);
    566     }
    567   else
    568     {
    569       sprintf (command, "cat %s | tail -n%d", filename, g_noof_log_lines);
     564      sprintf (command, "grep '%s' %s | tail -n%d",           
     565                    grep_for_me, filename,
     566                    g_noof_log_lines);
     567    }
     568  else
     569    {
     570      sprintf (command, "cat %s | tail -n%d %s", g_noof_log_lines, filename);
    570571    }
    571572  fin = popen (command, "r");
  • branches/2.05/mondo/mondo/mondorestore/mondo-prep.c

    r88 r126  
    478478              {
    479479                strcpy(tmp, call_program_and_get_last_line_of_output
    480                     ("cat /var/log/mondo-archive.log | tail -n5 | grep Insufficient | tail -n1"));
     480                    ("tail -n5 /var/log/mondo-archive.log | grep Insufficient | tail -n1"));
    481481              }
    482482            else
    483483              {
    484484                strcpy(tmp, call_program_and_get_last_line_of_output
    485                     ("cat /var/log/mondo-archive.log | tail -n5 | grep lvcreate | tail -n1"));
     485                    ("tail -n5 /var/log/mondo-archive.log | grep lvcreate | tail -n1"));
    486486              }
    487487            for(p=tmp; *p!='\0' && !isdigit(*p); p++);
Note: See TracChangeset for help on using the changeset viewer.