Changeset 3191 in MondoRescue for branches/3.2/mondo/src/common/libmondo-cli.c


Ignore:
Timestamp:
Sep 25, 2013, 8:55:45 AM (11 years ago)
Author:
Bruno Cornec
Message:
  • Lots of memory management backports from 3.1 to 3.2 - still not finished, nor working ATM. the common subdir was done during travel, so this is essentially a backup !
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/3.2/mondo/src/common/libmondo-cli.c

    r3185 r3191  
    9797    for (i = 0; i < 128; i++) {
    9898        if (flag_set[i]) {
    99             mr_asprintf(tmp, "-%c %s", i, flag_val[i]);
    100             log_msg(3, tmp);
    101             mr_free(tmp);
     99            log_msg(3, "-%c %s", i, flag_val[i]);
    102100        }
    103101    }
     
    150148    char *tmp = NULL;
    151149    char *tmp1 = NULL;
     150    char *tmp2 = NULL;
    152151    char *psz = NULL;
    153152    char *p = NULL;
     
    208207            log_msg(1, "Using star instead of afio");
    209208        } else {
    210             fatal_error
    211                 ("Neither afio nor star is installed. Please install at least one.");
     209            fatal_error("Neither afio nor star is installed. Please install at least one.");
    212210        }
    213211    }
     
    219217        }
    220218        if (!find_home_of_exe("star")) {
    221             fatal_error
    222                 ("Please install 'star' RPM or tarball if you are going to use -R. Thanks.");
     219            fatal_error("Please install 'star' RPM or tarball if you are going to use -R. Thanks.");
    223220        }
    224221    }
     
    234231
    235232    if (flag_set['I']) {
    236         if (bkpinfo->include_paths[0] == '-') {
     233        if (bkpinfo->include_paths && bkpinfo->include_paths[0] == '-') {
    237234            retval++;
    238235            log_to_screen("Please supply a sensible value with '-I'\n");
     
    268265            }
    269266        }
    270         paranoid_free(tmp1);
     267        mr_free(tmp1);
    271268        mr_make_devlist_from_pathlist(flag_val['I'], 'I');
    272269        log_msg(4, "Finished with the -I option");
    273270    }
    274271
    275     if (g_kernel_version >= 2.6 && !flag_set['d']
    276         && (flag_set['c'] || flag_set['w']) && (! bkpinfo->restore_data)) {
    277         fatal_error
    278             ("If you are using the 2.6.x kernel, please specify the CD-R(W) device.");
     272    if (g_kernel_version >= 2.6 && !flag_set['d'] && (flag_set['c'] || flag_set['w']) && (! bkpinfo->restore_data)) {
     273        fatal_error("If you are using the 2.6.x kernel, please specify the CD-R(W) device.");
    279274    }
    280275
     
    283278        if (flag_set['I']) {
    284279            retval++;
    285             log_to_screen
    286                 ("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. :-)");
     280            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. :-)");
    287281        }
    288282        bkpinfo->make_filelist = FALSE;
    289         strcpy(bkpinfo->include_paths, flag_val['J']);
     283        mr_asprintf(bkpinfo->include_paths, "%s", flag_val['J']);
    290284    }
    291285
    292286    if ((flag_set['c'] || flag_set['w'] || flag_set['C'] || flag_set['r']) && (! bkpinfo->restore_data)) {
    293         if (!flag_set['r'] && g_kernel_version <= 2.5
    294             && strstr(flag_val['d'], "/dev/")) {
    295             fatal_error
    296                 ("Please don't give a /dev entry. Give a SCSI node for the parameter of the -d flag.");
    297         }
    298         if (flag_set['r'] && g_kernel_version <= 2.5
    299             && !strstr(flag_val['d'], "/dev/")) {
    300             fatal_error
    301                 ("Please give a /dev entry, not a SCSI node, as the parameter of the -d flag.");
     287        if (!flag_set['r'] && g_kernel_version <= 2.5 && strstr(flag_val['d'], "/dev/")) {
     288            fatal_error("Please don't give a /dev entry. Give a SCSI node for the parameter of the -d flag.");
     289        }
     290        if (flag_set['r'] && g_kernel_version <= 2.5 && !strstr(flag_val['d'], "/dev/")) {
     291            fatal_error("Please give a /dev entry, not a SCSI node, as the parameter of the -d flag.");
    302292        }
    303293        if (g_kernel_version >= 2.6 && !strstr(flag_val['d'], "/dev/")) {
    304             log_to_screen
    305                 ("Linus says 2.6 has a broken ide-scsi module. Proceed at your own risk...");
    306         }
    307 
    308         if (system("which cdrecord > /dev/null 2> /dev/null")
    309             && system("which dvdrecord > /dev/null 2> /dev/null")) {
    310             fatal_error
    311                 ("Please install dvdrecord/cdrecord and try again.");
     294            log_to_screen("Linus says 2.6 has a broken ide-scsi module. Proceed at your own risk...");
     295        }
     296
     297        if (system("which cdrecord > /dev/null 2> /dev/null") && system("which dvdrecord > /dev/null 2> /dev/null")) {
     298            fatal_error("Please install dvdrecord/cdrecord and try again.");
    312299        }
    313300        if (flag_set['C']) {
    314301            bkpinfo->cdrw_speed = atoi(flag_val['C']);
    315302            if (bkpinfo->cdrw_speed < 1) {
    316                 fatal_error
    317                     ("You specified a silly speed for a CD-R[W] drive");
     303                fatal_error("You specified a silly speed for a CD-R[W] drive");
    318304            }
    319305            if (!flag_set['L']) {
    320                 log_to_screen
    321                     ("You must use -L with -C. Therefore I am setting it for you.");
     306                log_to_screen("You must use -L with -C. Therefore I am setting it for you.");
    322307                flag_set['L'] = 1;
    323308                flag_val['L'][0] = '\0';
     
    326311            log_msg(3, "flag_val['c'] = %s", flag_val['c']);
    327312            log_msg(3, "flag_val['w'] = %s", flag_val['w']);
    328 //    log_msg(3, "flag_set['r'] = %i", flag_set['r'] );
    329313            if (flag_set['c']) {
    330314                bkpinfo->cdrw_speed = atoi(flag_val['c']);
     
    336320
    337321            if (bkpinfo->cdrw_speed < 1) {
    338                 fatal_error
    339                     ("You specified a silly speed for a CD-R[W] drive");
     322                fatal_error("You specified a silly speed for a CD-R[W] drive");
    340323            }
    341324        }
     
    345328        log_it("Hmm! No tape drive specified. Let's see what we can do.");
    346329        if (find_tape_device_and_size(flag_val['d'], tmp)) {
    347             fatal_error
    348                 ("Tape device not specified. I couldn't find it either.");
     330            fatal_error("Tape device not specified. I couldn't find it either.");
    349331        }
    350332        flag_set['d'] = TRUE;
    351         sprintf(tmp,
    352                 "You didn't specify a tape streamer device. I'm assuming %s",
    353                 flag_val['d']);
    354         log_to_screen(tmp);
     333        log_to_screen("You didn't specify a tape streamer device. I'm assuming %s", flag_val['d']);
    355334    }
    356335
     
    358337    {
    359338        if (! flag_set['d']) {
    360             fatal_error
    361                 ("You need to specify a device file with -d for bootable USB device usage");
     339            fatal_error("You need to specify a device file with -d for bootable USB device usage");
    362340        }
    363341        if ((!flag_set['s']) && (! bkpinfo->restore_data)) {
     
    369347    {
    370348        if (flag_set['m']) {
    371             fatal_error
    372                 ("Manual CD tray (-m) not yet supported in conjunction w/ DVD drives. Drop -m.");
     349            fatal_error("Manual CD tray (-m) not yet supported in conjunction w/ DVD drives. Drop -m.");
    373350        }
    374351        if (!flag_set['d']) {
     
    379356        }
    380357        if (strchr(flag_val['d'], ',')) {
    381             fatal_error
    382                 ("Please don't give a SCSI node. Give a _device_, preferably a /dev entry, for the parameter of the -d flag.");
     358            fatal_error("Please don't give a SCSI node. Give a _device_, preferably a /dev entry, for the parameter of the -d flag.");
    383359        }
    384360        if (! bkpinfo->restore_data) {
    385361            if (!find_home_of_exe("growisofs")) {
    386                 fatal_error
    387                     ("Please install growisofs (probably part of dvd+rw-tools). If you want DVD support, you need it.");
     362                fatal_error("Please install growisofs (probably part of dvd+rw-tools). If you want DVD support, you need it.");
    388363            }
    389364            if (!find_home_of_exe("dvd+rw-format")) {
    390                 fatal_error
    391                     ("Please install dvd+rw-format (probably part of dvd+rw-tools). If you want DVD support, you need it.");
     365                fatal_error("Please install dvd+rw-format (probably part of dvd+rw-tools). If you want DVD support, you need it.");
    392366            }
    393367            if (!flag_set['s']) {
    394368                sprintf(flag_val['s'], "%d", DEFAULT_DVD_DISK_SIZE);    // 4.7 salesman's GB = 4.482 real GB = 4582 MB
    395369                strcat(flag_val['s'], "m");
    396                 log_to_screen
    397                     ("You did not specify a size (-s) for DVD. I'm guessing %s.",
    398                     flag_val['s']);
     370                log_to_screen("You did not specify a size (-s) for DVD. I'm guessing %s.", flag_val['s']);
    399371                flag_set['s'] = 1;
    400372            }
    401373        }
    402 /*
    403       if (flag_set['Z']) {
    404       bkpinfo->blank_dvd_first = TRUE;
    405       }
    406 */
    407374    }
    408375
    409376    if (flag_set['t'] || flag_set['u']) {   /* tape size */
    410377        if (strchr(flag_val['d'], ',')) {
    411             fatal_error
    412                 ("Please don't give a SCSI node. Give a _device_, preferably a /dev entry, for the parameter of the -d flag.");
     378            fatal_error("Please don't give a SCSI node. Give a _device_, preferably a /dev entry, for the parameter of the -d flag.");
    413379        }
    414380        if ((flag_set['O']) && (! bkpinfo->restore_data)) {
    415381            if (flag_set['s']) {
    416382                if (flag_set['t']) {
    417                     fatal_error
    418                         ("For the moment, please don't specify a tape size. Mondo should handle end-of-tape gracefully anyway.");
     383                    fatal_error("For the moment, please don't specify a tape size. Mondo should handle end-of-tape gracefully anyway.");
    419384                }
    420385                if (process_the_s_switch(flag_val['s'])) {
     
    440405
    441406    if (flag_set['n']) {
    442         strncpy(bkpinfo->netfs_mount, flag_val['n'], MAX_STR_LEN);
     407        mr_free(bkpinfo->netfs_mount);
     408        mr_asprintf(bkpinfo->netfs_mount, "%s", flag_val['n']);
    443409        if (!flag_set['d']) {
    444             strncpy(bkpinfo->netfs_remote_dir, "/", MAX_STR_LEN);
     410            mr_free(bkpinfo->netfs_remote_dir);
     411            mr_asprintf(bkpinfo->netfs_remote_dir, "/");
    445412        }
    446413        /* test for protocol */
     
    473440        /* Store the 2 values */
    474441        /*  using memmove instead of strcpy as per #584 */
    475         memmove(bkpinfo->netfs_mount, p, MAX_STR_LEN);
     442        /* memmove(bkpinfo->netfs_mount, p, MAX_STR_LEN); */
     443        bkpinfo->netfs_mount = p;
    476444
    477445        /* test if we specified a user */
     
    479447        if (p != NULL) {
    480448            /* User found. Store the 2 values */
     449            bkpinfo->netfs_user = bkpinfo->netfs_mount;
    481450            p++;
    482451            /* new netfs mount */
    483             strcpy(tmp,p);
     452            mr_asprintf(bkpinfo->netfs_mount, "%s", p);
     453            /* now that user is computed, create the right value by removing end of string */
    484454            p--;
    485455            *p = '\0';
    486             mr_asprintf(q,"%s",bkpinfo->netfs_mount);
    487             bkpinfo->netfs_user = q;
    488             strcpy(bkpinfo->netfs_mount,tmp);
    489         }
    490         sprintf(tmp, "mount | grep -E \"^[a-z]*#*[%s@]*%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_user,
    491                 bkpinfo->netfs_mount);
    492         strncpy(bkpinfo->isodir,
    493                 call_program_and_get_last_line_of_output(tmp),
    494                 MAX_STR_LEN / 4);
     456        }
     457        mr_asprintf(tmp1, "mount | grep -E \"^[a-z]*#*[%s@]*%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_user, bkpinfo->netfs_mount);
     458        strncpy(bkpinfo->isodir, call_program_and_get_last_line_of_output(tmp), MAX_STR_LEN / 4);
     459        mr_free(tmp1);
     460
    495461        if (strlen(bkpinfo->isodir) < 3) {
    496462            log_to_screen("Network share is not mounted. Trying to mount it for you.\n");
    497463            if (bkpinfo->netfs_user) {
    498464                if (strstr(bkpinfo->netfs_proto, "sshfs")) {
    499                     sprintf(tmp, "sshfs %s@%s", bkpinfo->netfs_user, bkpinfo->netfs_mount);
     465                    mr_asprintf(tmp1, "sshfs %s@%s", bkpinfo->netfs_user, bkpinfo->netfs_mount);
    500466                } else if (strstr(bkpinfo->netfs_proto, "smbfs")) {
    501                     sprintf(tmp, "mount -t cifs %s -o user=%s", bkpinfo->netfs_mount, bkpinfo->netfs_user);
     467                    mr_asprintf(tmp1, "mount -t cifs %s -o user=%s", bkpinfo->netfs_mount, bkpinfo->netfs_user);
    502468                } else if (strstr(bkpinfo->netfs_proto, "nfs")) {
    503                     sprintf(tmp, "mount %s@%s", bkpinfo->netfs_user, bkpinfo->netfs_mount);
     469                    mr_asprintf(tmp1, "mount %s@%s", bkpinfo->netfs_user, bkpinfo->netfs_mount);
    504470                } else {
    505471                    log_to_screen("Protocol %s not supported yet for network backups.\n", bkpinfo->netfs_proto);
     
    508474            } else {
    509475                if (strstr(bkpinfo->netfs_proto, "sshfs")) {
    510                     sprintf(tmp, "sshfs %s", bkpinfo->netfs_mount);
     476                    mr_asprintf(tmp1, "sshfs %s", bkpinfo->netfs_mount);
    511477                } else if (strstr(bkpinfo->netfs_proto, "smbfs")) {
    512                     sprintf(tmp, "mount -t cifs %s", bkpinfo->netfs_mount);
     478                    mr_asprintf(tmp1, "mount -t cifs %s", bkpinfo->netfs_mount);
    513479                } else if (strstr(bkpinfo->netfs_proto, "nfs")) {
    514                     sprintf(tmp, "mount %s", bkpinfo->netfs_mount);
     480                    mr_asprintf(tmp1, "mount %s", bkpinfo->netfs_mount);
    515481                } else {
    516482                    log_to_screen("Protocol %s not supported yet for network backups.\n", bkpinfo->netfs_proto);
     
    518484                }
    519485            }
    520             if (system(tmp)) {
     486            i = system(tmp1);
     487            mr_free(tmp1);
     488
     489            if (i) {
    521490                log_to_screen("Unable to mount Network share %s. Please mount manually.\n", bkpinfo->netfs_mount);
    522491                retval++;
    523492            } else {
    524493                if (bkpinfo->netfs_user) {
    525                     sprintf(tmp, "mount | grep -E \"^[%s@]*%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_user,
    526                         bkpinfo->netfs_mount);
     494                    mr_asprintf(tmp1, "mount | grep -E \"^[%s@]*%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_user, bkpinfo->netfs_mount);
    527495                } else {
    528                     sprintf(tmp, "mount | grep -E \"^%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_mount);
     496                    mr_asprintf(tmp1, "mount | grep -E \"^%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_mount);
    529497                }
    530                 strncpy(bkpinfo->isodir,
    531                         call_program_and_get_last_line_of_output(tmp),
    532                         MAX_STR_LEN / 4);
     498                strncpy(bkpinfo->isodir, call_program_and_get_last_line_of_output(tmp), MAX_STR_LEN / 4);
    533499                if (strlen(bkpinfo->isodir) < 3) {
    534500                    retval++;
     
    624590            }
    625591        }
    626         paranoid_free(tmp1);
     592        mr_free(tmp1);
    627593
    628594        mr_make_devlist_from_pathlist(flag_val['E'], 'E');
     
    668634        log_msg(1, "Internal tape block size is now %ld bytes", itbs);
    669635        if (itbs % 512 != 0 || itbs < 256 || itbs > 1024L * 1024) {
    670             fatal_error
    671                 ("Are you nuts? Silly, your internal tape block size is. Abort, I shall.");
     636            fatal_error("Are you nuts? Silly, your internal tape block size is. Abort, I shall.");
    672637        }
    673638        bkpinfo->internal_tape_block_size = itbs;
     
    678643//      bkpinfo->differential = atoi (flag_val['D']);
    679644        if ((bkpinfo->differential < 1) || (bkpinfo->differential > 9)) {
    680             fatal_error
    681                 ("The D option should be between 1 and 9 inclusive");
     645            fatal_error("The D option should be between 1 and 9 inclusive");
    682646        }
    683647    }
     
    702666            && !does_file_exist(bkpinfo->kernel_path)) {
    703667            retval++;
    704             sprintf(tmp,
    705                     "You specified kernel '%s', which does not exist\n",
    706                     bkpinfo->kernel_path);
    707             log_to_screen(tmp);
     668            log_to_screen("You specified kernel '%s', which does not exist\n", bkpinfo->kernel_path);
    708669        }
    709670    }
     
    723684            }
    724685        } else if (flag_set['n']) {
    725             strncpy(bkpinfo->netfs_remote_dir, flag_val['d'], MAX_STR_LEN);
     686            mr_free(bkpinfo->netfs_remote_dir);
     687            mr_asprintf(bkpinfo->netfs_remote_dir, "%s", flag_val['d']);
    726688        } else {                /* backup device (if tape/CD-R/CD-RW) */
    727689            strncpy(bkpinfo->media_device, flag_val['d'], MAX_STR_LEN / 4);
     
    732694        mr_asprintf(tmp1,"%s/%s/.dummy.txt", bkpinfo->isodir,bkpinfo->netfs_remote_dir);
    733695        if ((bkpinfo->netfs_user) && (strstr(bkpinfo->netfs_proto,"nfs"))) {
    734             sprintf(tmp, "su - %s -c \"echo hi > %s\"", bkpinfo->netfs_user, tmp1);
     696            mr_asprintf(tmp2, "su - %s -c \"echo hi > %s\"", bkpinfo->netfs_user, tmp1);
    735697        } else {
    736             sprintf(tmp, "echo hi > %s", tmp1);
    737         }
    738         if (run_program_and_log_output(tmp, 2)) {
    739             retval++;
    740             sprintf(tmp,
    741                     "Are you sure directory '%s' exists in remote dir '%s'?\nIf so, do you have rights to write to it?\n",
    742                     bkpinfo->netfs_remote_dir, bkpinfo->netfs_mount);
    743             log_to_screen(tmp);
     698            mr_asprintf(tmp2, "echo hi > %s", tmp1);
     699        }
     700        i = run_program_and_log_output(tmp2, 2);
     701        mr_free(tmp2);
     702
     703        if (i) {
     704            retval++;
     705            log_to_screen("Are you sure directory '%s' exists in remote dir '%s'?\nIf so, do you have rights to write to it?\n", bkpinfo->netfs_remote_dir, bkpinfo->netfs_mount);
    744706        }
    745707        unlink(tmp1);
    746         paranoid_free(tmp1);
    747     }
    748 
    749     if (!flag_set['d']
    750         && (flag_set['c'] || flag_set['w'] || flag_set['C'])) {
     708        mr_free(tmp1);
     709    }
     710
     711    if (!flag_set['d'] && (flag_set['c'] || flag_set['w'] || flag_set['C'])) {
    751712        if (g_kernel_version >= 2.6) {
    752713            if (popup_and_get_string
     
    769730        retval++;
    770731        log_to_screen("Please specify the backup device/directory.\n");
    771         fatal_error
    772             ("You didn't use -d to specify the backup device/directory.");
     732        fatal_error("You didn't use -d to specify the backup device/directory.");
    773733    }
    774734
     
    781741    if (flag_set['S']) {
    782742        setup_scratchdir(flag_val['S']);
    783         sprintf(tmp, "touch %s/.foo.dat", bkpinfo->scratchdir);
    784         if (run_program_and_log_output(tmp, 1)) {
    785             retval++;
     743        mr_asprintf(tmp1, "touch %s/.foo.dat", bkpinfo->scratchdir);
     744        if (run_program_and_log_output(tmp1, 1)) {
     745            retval++;
     746            mr_free(tmp1);
    786747            log_to_screen("Please specify a scratchdir which I can write to. :)");
    787748            fatal_error("I cannot write to the scratchdir you specified.");
    788749        }
    789         sprintf(tmp, "ln -sf %s/.foo.dat %s/.bar.dat", bkpinfo->scratchdir, bkpinfo->scratchdir);
    790         if (run_program_and_log_output(tmp, 1)) {
    791             retval++;
     750        mr_free(tmp1);
     751
     752        mr_asprintf(tmp1, "ln -sf %s/.foo.dat %s/.bar.dat", bkpinfo->scratchdir, bkpinfo->scratchdir);
     753        if (run_program_and_log_output(tmp1, 1)) {
     754            retval++;
     755            mr_free(tmp1);
    792756            log_to_screen("Please don't specify a SAMBA or VFAT or NFS scratchdir.");
    793757            fatal_error("I cannot write to the scratchdir you specified.");
    794758        }
     759        mr_free(tmp1);
    795760    }
    796761
    797762    if (flag_set['T']) {
    798763        setup_tmpdir(flag_val['T']);
    799         sprintf(tmp, "touch %s/.foo.dat", bkpinfo->tmpdir);
    800         if (run_program_and_log_output(tmp, 1)) {
     764        mr_asprintf(tmp1, "touch %s/.foo.dat", bkpinfo->tmpdir);
     765        i = run_program_and_log_output(tmp1, 1);
     766        mr_free(tmp1);
     767
     768        if (i) {
    801769            retval++;
    802770            log_to_screen("Please specify a tempdir which I can write to. :)");
    803771            fatal_error("I cannot write to the tempdir you specified.");
    804772        }
    805         sprintf(tmp, "ln -sf %s/.foo.dat %s/.bar.dat", bkpinfo->tmpdir, bkpinfo->tmpdir);
    806         if (run_program_and_log_output(tmp, 1)) {
     773        mr_asprintf(tmp1, "ln -sf %s/.foo.dat %s/.bar.dat", bkpinfo->tmpdir, bkpinfo->tmpdir);
     774        i = run_program_and_log_output(tmp1, 1);
     775        mr_free(tmp1);
     776
     777        if (i) {
    807778            retval++;
    808779            log_to_screen("Please don't specify a SAMBA or VFAT or NFS tmpdir.");
     
    833804#  endif
    834805#endif
    835         if (!strchr
    836             (BOOT_LOADER_CHARS,
    837              (bkpinfo->boot_loader = flag_val['l'][0]))) {
    838             log_msg(1, "%c? WTF is %c? I need G, L, E or R.",
    839                     bkpinfo->boot_loader, bkpinfo->boot_loader);
    840             fatal_error
    841                 ("Please specify GRUB, LILO, ELILO  or RAW with the -l switch");
     806        if (!strchr(BOOT_LOADER_CHARS, (bkpinfo->boot_loader = flag_val['l'][0]))) {
     807            log_msg(1, "%c? What is %c? I need G, L, E or R.", bkpinfo->boot_loader, bkpinfo->boot_loader);
     808            fatal_error("Please specify GRUB, LILO, ELILO  or RAW with the -l switch");
    842809        }
    843810#undef BOOT_LOADER_CHARS
     
    845812
    846813    if (flag_set['f']) {
    847         strncpy(bkpinfo->boot_device,
    848                 resolve_softlinks_to_get_to_actual_device_file(flag_val
    849                                                                ['f']),
    850                 MAX_STR_LEN / 4);
     814        strncpy(bkpinfo->boot_device, resolve_softlinks_to_get_to_actual_device_file(flag_val['f']),MAX_STR_LEN / 4);
    851815    }
    852816
     
    866830        if (run_program_and_log_output("which lzop", 2)) {
    867831            retval++;
    868             log_to_screen
    869                 ("Please install LZOP. You can't use '-L' until you do.\n");
     832            log_to_screen("Please install LZOP. You can't use '-L' until you do.\n");
    870833        }
    871834    }
     
    880843        if (run_program_and_log_output("which gzip", 2)) {
    881844            retval++;
    882             log_to_screen
    883                 ("Please install gzip. You can't use '-G' until you do.\n");
     845            log_to_screen("Please install gzip. You can't use '-G' until you do.\n");
     846        }
     847    }
     848
     849    if ((flag_set['Y']) && (! bkpinfo->restore_data)) {
     850        bkpinfo->use_lzma = TRUE;
     851        if (run_program_and_log_output("which lzma", 2)) {
     852            retval++;
     853            log_to_screen("Please install lzma. You can't use '-Y' until you do.\n");
    884854        }
    885855    }
     
    897867    if ((!is_this_a_valid_disk_format("vfat")) && (! bkpinfo->restore_data)) {
    898868        bkpinfo->make_cd_use_lilo = TRUE;
    899         log_to_screen
    900             ("Your kernel appears not to support vfat filesystems. I am therefore");
    901         log_to_screen
    902             ("using LILO instead of SYSLINUX as the media boot loader.");
     869        log_to_screen("Your kernel appears not to support vfat filesystems. I am therefore");
     870        log_to_screen("using LILO instead of SYSLINUX as the media boot loader.");
    903871    }
    904872    if ((run_program_and_log_output("which mkfs.vfat", 2)) && (! bkpinfo->restore_data)) {
    905873        bkpinfo->make_cd_use_lilo = TRUE;
    906874#ifdef __IA32__
    907         log_to_screen
    908             ("Your filesystem is missing 'mkfs.vfat', so I cannot use SYSLINUX as");
    909         log_to_screen
    910             ("your boot loader. I shall therefore use LILO instead.");
     875        log_to_screen("Your filesystem is missing 'mkfs.vfat', so I cannot use SYSLINUX as");
     876        log_to_screen("your boot loader. I shall therefore use LILO instead.");
    911877#endif
    912878#ifdef __IA64__
    913         log_to_screen
    914             ("Your filesystem is missing 'mkfs.vfat', so I cannot prepare the EFI");
     879        log_to_screen("Your filesystem is missing 'mkfs.vfat', so I cannot prepare the EFI");
    915880        log_to_screen("environment correctly. Please install it.");
    916881        fatal_error("Aborting");
     
    932897
    933898    if ((! bkpinfo->restore_data) && (flag_set['Z'])) {
    934             fatal_error
    935                 ("The -Z switch is only valid in restore mode");
     899            fatal_error("The -Z switch is only valid in restore mode");
    936900    }
    937901
     
    973937 * @return The number of problems with the command line (0 for success).
    974938 */
    975 int
    976 retrieve_switches_from_command_line(int argc, char *argv[],
    977                                     char flag_val[128][MAX_STR_LEN],
    978                                     bool flag_set[128])
     939int retrieve_switches_from_command_line(int argc, char *argv[], char flag_val[128][MAX_STR_LEN], bool flag_set[128])
    979940{
    980941    /*@ ints ** */
    981942    int opt = 0;
    982     char *tmp = NULL;
    983943    int i = 0;
    984944    int len;
     
    994954        flag_set[i] = FALSE;
    995955    }
    996     while ((opt =
    997             getopt(argc, argv, MONDO_OPTIONS))
    998            != -1) {
     956    while ((opt = getopt(argc, argv, MONDO_OPTIONS)) != -1) {
    999957        if (opt == '?') {
    1000958            bad_switches = TRUE;
    1001             /*log_it("Invalid option: %c\n",optopt); */
    1002959        } else {
    1003960            if (flag_set[opt]) {
    1004961                bad_switches = TRUE;
    1005                 mr_asprintf(tmp, "Switch -%c previously defined as %s\n", opt, flag_val[opt]);
    1006                 log_to_screen(tmp);
    1007                 paranoid_free(tmp);
     962                log_to_screen("Switch -%c previously defined as %s\n", opt, flag_val[opt]);
    1008963            } else {
    1009964                flag_set[opt] = TRUE;
     
    1019974                        if (strchr(flag_val[opt], '/')
    1020975                            && flag_val[opt][0] != '/') {
    1021                             mr_asprintf(tmp, "-%c flag --- must be absolute path --- '%s' isn't absolute", opt, flag_val[opt]);
    1022                             log_to_screen(tmp);
    1023                             paranoid_free(tmp);
     976                            log_to_screen("-%c flag --- must be absolute path --- '%s' isn't absolute", opt, flag_val[opt]);
    1024977                            bad_switches = TRUE;
    1025978                        }
     
    1032985    for (i = optind; i < argc; i++) {
    1033986        bad_switches = TRUE;
    1034         mr_asprintf(tmp, "Invalid arg -- %s\n", argv[i]);
    1035         log_to_screen(tmp);
    1036         paranoid_free(tmp);
     987        log_to_screen("Invalid arg -- %s\n", argv[i]);
    1037988    }
    1038989    return (bad_switches);
     
    10971048    mr_strcat(tmp, " signal received from OS");
    10981049    log_to_screen(tmp);
    1099     paranoid_free(tmp);
     1050    mr_free(tmp);
    11001051
    11011052    log_to_screen(tmp2);
    1102     paranoid_free(tmp2);
     1053    mr_free(tmp2);
    11031054    if (sig == SIGABRT) {
    11041055        sleep(10);
     
    11081059    free_MR_global_filenames();
    11091060
    1110     fatal_error
    1111         ("MondoRescue is terminating in response to a signal from the OS");
     1061    fatal_error("MondoRescue is terminating in response to a signal from the OS");
    11121062    finish(254);                // just in case
    11131063}
     
    11221072void set_signals(int on)
    11231073{
    1124     int signals[] =
    1125         { SIGTERM, SIGHUP, SIGTRAP, SIGABRT, SIGINT, SIGKILL, SIGSTOP, 0 };
     1074    int signals[] = { SIGTERM, SIGHUP, SIGTRAP, SIGABRT, SIGINT, SIGKILL, SIGSTOP, 0 };
    11261075    int i;
    11271076
Note: See TracChangeset for help on using the changeset viewer.