Changeset 3192 in MondoRescue for branches/3.0/mondo/src/common/libmondo-cli.c


Ignore:
Timestamp:
Sep 25, 2013, 9:03:25 AM (11 years ago)
Author:
Bruno Cornec
Message:
  • revert r3188 & r3189 as I started to work on branch 3.0 before deciding it was much better to do it in 3.2. This will allow some small maintenance work on 3.0 if needed, while pushing all the rest to 3.2 and providing early access to it.
File:
1 edited

Legend:

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

    r3188 r3192  
    9797    for (i = 0; i < 128; i++) {
    9898        if (flag_set[i]) {
    99             log_msg(3, "-%c %s", i, flag_val[i]);
     99            mr_asprintf(tmp, "-%c %s", i, flag_val[i]);
     100            log_msg(3, tmp);
     101            mr_free(tmp);
    100102        }
    101103    }
     
    148150    char *tmp = NULL;
    149151    char *tmp1 = NULL;
    150     char *tmp2 = NULL;
    151152    char *psz = NULL;
    152153    char *p = NULL;
     
    207208            log_msg(1, "Using star instead of afio");
    208209        } else {
    209             fatal_error("Neither afio nor star is installed. Please install at least one.");
     210            fatal_error
     211                ("Neither afio nor star is installed. Please install at least one.");
    210212        }
    211213    }
     
    217219        }
    218220        if (!find_home_of_exe("star")) {
    219             fatal_error("Please install 'star' RPM or tarball if you are going to use -R. Thanks.");
     221            fatal_error
     222                ("Please install 'star' RPM or tarball if you are going to use -R. Thanks.");
    220223        }
    221224    }
     
    231234
    232235    if (flag_set['I']) {
    233         if (bkpinfo->include_paths && bkpinfo->include_paths[0] == '-') {
     236        if (bkpinfo->include_paths[0] == '-') {
    234237            retval++;
    235238            log_to_screen("Please supply a sensible value with '-I'\n");
     
    265268            }
    266269        }
    267         mr_free(tmp1);
     270        paranoid_free(tmp1);
    268271        mr_make_devlist_from_pathlist(flag_val['I'], 'I');
    269272        log_msg(4, "Finished with the -I option");
    270273    }
    271274
    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.");
     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.");
    274279    }
    275280
     
    278283        if (flag_set['I']) {
    279284            retval++;
    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. :-)");
     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. :-)");
    281287        }
    282288        bkpinfo->make_filelist = FALSE;
    283         mr_asprintf(bkpinfo->include_paths, "%s", flag_val['J']);
     289        strcpy(bkpinfo->include_paths, flag_val['J']);
    284290    }
    285291
    286292    if ((flag_set['c'] || flag_set['w'] || flag_set['C'] || flag_set['r']) && (! bkpinfo->restore_data)) {
    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.");
     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.");
    292302        }
    293303        if (g_kernel_version >= 2.6 && !strstr(flag_val['d'], "/dev/")) {
    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.");
     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.");
    299312        }
    300313        if (flag_set['C']) {
    301314            bkpinfo->cdrw_speed = atoi(flag_val['C']);
    302315            if (bkpinfo->cdrw_speed < 1) {
    303                 fatal_error("You specified a silly speed for a CD-R[W] drive");
     316                fatal_error
     317                    ("You specified a silly speed for a CD-R[W] drive");
    304318            }
    305319            if (!flag_set['L']) {
    306                 log_to_screen("You must use -L with -C. Therefore I am setting it for you.");
     320                log_to_screen
     321                    ("You must use -L with -C. Therefore I am setting it for you.");
    307322                flag_set['L'] = 1;
    308323                flag_val['L'][0] = '\0';
     
    311326            log_msg(3, "flag_val['c'] = %s", flag_val['c']);
    312327            log_msg(3, "flag_val['w'] = %s", flag_val['w']);
     328//    log_msg(3, "flag_set['r'] = %i", flag_set['r'] );
    313329            if (flag_set['c']) {
    314330                bkpinfo->cdrw_speed = atoi(flag_val['c']);
     
    320336
    321337            if (bkpinfo->cdrw_speed < 1) {
    322                 fatal_error("You specified a silly speed for a CD-R[W] drive");
     338                fatal_error
     339                    ("You specified a silly speed for a CD-R[W] drive");
    323340            }
    324341        }
     
    328345        log_it("Hmm! No tape drive specified. Let's see what we can do.");
    329346        if (find_tape_device_and_size(flag_val['d'], tmp)) {
    330             fatal_error("Tape device not specified. I couldn't find it either.");
     347            fatal_error
     348                ("Tape device not specified. I couldn't find it either.");
    331349        }
    332350        flag_set['d'] = TRUE;
    333         log_to_screen("You didn't specify a tape streamer device. I'm assuming %s", flag_val['d']);
     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);
    334355    }
    335356
     
    337358    {
    338359        if (! flag_set['d']) {
    339             fatal_error("You need to specify a device file with -d for bootable USB device usage");
     360            fatal_error
     361                ("You need to specify a device file with -d for bootable USB device usage");
    340362        }
    341363        if ((!flag_set['s']) && (! bkpinfo->restore_data)) {
     
    347369    {
    348370        if (flag_set['m']) {
    349             fatal_error("Manual CD tray (-m) not yet supported in conjunction w/ DVD drives. Drop -m.");
     371            fatal_error
     372                ("Manual CD tray (-m) not yet supported in conjunction w/ DVD drives. Drop -m.");
    350373        }
    351374        if (!flag_set['d']) {
     
    356379        }
    357380        if (strchr(flag_val['d'], ',')) {
    358             fatal_error("Please don't give a SCSI node. Give a _device_, preferably a /dev entry, for the parameter of the -d flag.");
     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.");
    359383        }
    360384        if (! bkpinfo->restore_data) {
    361385            if (!find_home_of_exe("growisofs")) {
    362                 fatal_error("Please install growisofs (probably part of dvd+rw-tools). If you want DVD support, you need it.");
     386                fatal_error
     387                    ("Please install growisofs (probably part of dvd+rw-tools). If you want DVD support, you need it.");
    363388            }
    364389            if (!find_home_of_exe("dvd+rw-format")) {
    365                 fatal_error("Please install dvd+rw-format (probably part of dvd+rw-tools). If you want DVD support, you need it.");
     390                fatal_error
     391                    ("Please install dvd+rw-format (probably part of dvd+rw-tools). If you want DVD support, you need it.");
    366392            }
    367393            if (!flag_set['s']) {
    368394                sprintf(flag_val['s'], "%d", DEFAULT_DVD_DISK_SIZE);    // 4.7 salesman's GB = 4.482 real GB = 4582 MB
    369395                strcat(flag_val['s'], "m");
    370                 log_to_screen("You did not specify a size (-s) for DVD. I'm guessing %s.", flag_val['s']);
     396                log_to_screen
     397                    ("You did not specify a size (-s) for DVD. I'm guessing %s.",
     398                    flag_val['s']);
    371399                flag_set['s'] = 1;
    372400            }
    373401        }
     402/*
     403      if (flag_set['Z']) {
     404      bkpinfo->blank_dvd_first = TRUE;
     405      }
     406*/
    374407    }
    375408
    376409    if (flag_set['t'] || flag_set['u']) {   /* tape size */
    377410        if (strchr(flag_val['d'], ',')) {
    378             fatal_error("Please don't give a SCSI node. Give a _device_, preferably a /dev entry, for the parameter of the -d flag.");
     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.");
    379413        }
    380414        if ((flag_set['O']) && (! bkpinfo->restore_data)) {
    381415            if (flag_set['s']) {
    382416                if (flag_set['t']) {
    383                     fatal_error("For the moment, please don't specify a tape size. Mondo should handle end-of-tape gracefully anyway.");
     417                    fatal_error
     418                        ("For the moment, please don't specify a tape size. Mondo should handle end-of-tape gracefully anyway.");
    384419                }
    385420                if (process_the_s_switch(flag_val['s'])) {
     
    405440
    406441    if (flag_set['n']) {
    407         mr_free(bkpinfo->netfs_mount);
    408         mr_asprintf(bkpinfo->netfs_mount, "%s", flag_val['n']);
     442        strncpy(bkpinfo->netfs_mount, flag_val['n'], MAX_STR_LEN);
    409443        if (!flag_set['d']) {
    410             mr_free(bkpinfo->netfs_remote_dir);
    411             mr_asprintf(bkpinfo->netfs_remote_dir, "/");
     444            strncpy(bkpinfo->netfs_remote_dir, "/", MAX_STR_LEN);
    412445        }
    413446        /* test for protocol */
     
    440473        /* Store the 2 values */
    441474        /*  using memmove instead of strcpy as per #584 */
    442         /* memmove(bkpinfo->netfs_mount, p, MAX_STR_LEN); */
    443         bkpinfo->netfs_mount = p;
     475        memmove(bkpinfo->netfs_mount, p, MAX_STR_LEN);
    444476
    445477        /* test if we specified a user */
     
    447479        if (p != NULL) {
    448480            /* User found. Store the 2 values */
    449             bkpinfo->netfs_user = bkpinfo->netfs_mount;
    450481            p++;
    451482            /* new netfs mount */
    452             mr_asprintf(bkpinfo->netfs_mount, "%s", p);
    453             /* now that user is computed, create the right value by removing end of string */
     483            strcpy(tmp,p);
    454484            p--;
    455485            *p = '\0';
    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 
     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);
    461495        if (strlen(bkpinfo->isodir) < 3) {
    462496            log_to_screen("Network share is not mounted. Trying to mount it for you.\n");
    463497            if (bkpinfo->netfs_user) {
    464498                if (strstr(bkpinfo->netfs_proto, "sshfs")) {
    465                     mr_asprintf(tmp1, "sshfs %s@%s", bkpinfo->netfs_user, bkpinfo->netfs_mount);
     499                    sprintf(tmp, "sshfs %s@%s", bkpinfo->netfs_user, bkpinfo->netfs_mount);
    466500                } else if (strstr(bkpinfo->netfs_proto, "smbfs")) {
    467                     mr_asprintf(tmp1, "mount -t cifs %s -o user=%s", bkpinfo->netfs_mount, bkpinfo->netfs_user);
     501                    sprintf(tmp, "mount -t cifs %s -o user=%s", bkpinfo->netfs_mount, bkpinfo->netfs_user);
    468502                } else if (strstr(bkpinfo->netfs_proto, "nfs")) {
    469                     mr_asprintf(tmp1, "mount %s@%s", bkpinfo->netfs_user, bkpinfo->netfs_mount);
     503                    sprintf(tmp, "mount %s@%s", bkpinfo->netfs_user, bkpinfo->netfs_mount);
    470504                } else {
    471505                    log_to_screen("Protocol %s not supported yet for network backups.\n", bkpinfo->netfs_proto);
     
    474508            } else {
    475509                if (strstr(bkpinfo->netfs_proto, "sshfs")) {
    476                     mr_asprintf(tmp1, "sshfs %s", bkpinfo->netfs_mount);
     510                    sprintf(tmp, "sshfs %s", bkpinfo->netfs_mount);
    477511                } else if (strstr(bkpinfo->netfs_proto, "smbfs")) {
    478                     mr_asprintf(tmp1, "mount -t cifs %s", bkpinfo->netfs_mount);
     512                    sprintf(tmp, "mount -t cifs %s", bkpinfo->netfs_mount);
    479513                } else if (strstr(bkpinfo->netfs_proto, "nfs")) {
    480                     mr_asprintf(tmp1, "mount %s", bkpinfo->netfs_mount);
     514                    sprintf(tmp, "mount %s", bkpinfo->netfs_mount);
    481515                } else {
    482516                    log_to_screen("Protocol %s not supported yet for network backups.\n", bkpinfo->netfs_proto);
     
    484518                }
    485519            }
    486             i = system(tmp1);
    487             mr_free(tmp1);
    488 
    489             if (i) {
     520            if (system(tmp)) {
    490521                log_to_screen("Unable to mount Network share %s. Please mount manually.\n", bkpinfo->netfs_mount);
    491522                retval++;
    492523            } else {
    493524                if (bkpinfo->netfs_user) {
    494                     mr_asprintf(tmp1, "mount | grep -E \"^[%s@]*%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_user, bkpinfo->netfs_mount);
     525                    sprintf(tmp, "mount | grep -E \"^[%s@]*%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_user,
     526                        bkpinfo->netfs_mount);
    495527                } else {
    496                     mr_asprintf(tmp1, "mount | grep -E \"^%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_mount);
     528                    sprintf(tmp, "mount | grep -E \"^%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_mount);
    497529                }
    498                 strncpy(bkpinfo->isodir, call_program_and_get_last_line_of_output(tmp), MAX_STR_LEN / 4);
     530                strncpy(bkpinfo->isodir,
     531                        call_program_and_get_last_line_of_output(tmp),
     532                        MAX_STR_LEN / 4);
    499533                if (strlen(bkpinfo->isodir) < 3) {
    500534                    retval++;
     
    590624            }
    591625        }
    592         mr_free(tmp1);
     626        paranoid_free(tmp1);
    593627
    594628        mr_make_devlist_from_pathlist(flag_val['E'], 'E');
     
    634668        log_msg(1, "Internal tape block size is now %ld bytes", itbs);
    635669        if (itbs % 512 != 0 || itbs < 256 || itbs > 1024L * 1024) {
    636             fatal_error("Are you nuts? Silly, your internal tape block size is. Abort, I shall.");
     670            fatal_error
     671                ("Are you nuts? Silly, your internal tape block size is. Abort, I shall.");
    637672        }
    638673        bkpinfo->internal_tape_block_size = itbs;
     
    643678//      bkpinfo->differential = atoi (flag_val['D']);
    644679        if ((bkpinfo->differential < 1) || (bkpinfo->differential > 9)) {
    645             fatal_error("The D option should be between 1 and 9 inclusive");
     680            fatal_error
     681                ("The D option should be between 1 and 9 inclusive");
    646682        }
    647683    }
     
    666702            && !does_file_exist(bkpinfo->kernel_path)) {
    667703            retval++;
    668             log_to_screen("You specified kernel '%s', which does not exist\n", bkpinfo->kernel_path);
     704            sprintf(tmp,
     705                    "You specified kernel '%s', which does not exist\n",
     706                    bkpinfo->kernel_path);
     707            log_to_screen(tmp);
    669708        }
    670709    }
     
    684723            }
    685724        } else if (flag_set['n']) {
    686             mr_free(bkpinfo->netfs_remote_dir);
    687             mr_asprintf(bkpinfo->netfs_remote_dir, "%s", flag_val['d']);
     725            strncpy(bkpinfo->netfs_remote_dir, flag_val['d'], MAX_STR_LEN);
    688726        } else {                /* backup device (if tape/CD-R/CD-RW) */
    689727            strncpy(bkpinfo->media_device, flag_val['d'], MAX_STR_LEN / 4);
     
    694732        mr_asprintf(tmp1,"%s/%s/.dummy.txt", bkpinfo->isodir,bkpinfo->netfs_remote_dir);
    695733        if ((bkpinfo->netfs_user) && (strstr(bkpinfo->netfs_proto,"nfs"))) {
    696             mr_asprintf(tmp2, "su - %s -c \"echo hi > %s\"", bkpinfo->netfs_user, tmp1);
     734            sprintf(tmp, "su - %s -c \"echo hi > %s\"", bkpinfo->netfs_user, tmp1);
    697735        } else {
    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);
     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);
    706744        }
    707745        unlink(tmp1);
    708         mr_free(tmp1);
    709     }
    710 
    711     if (!flag_set['d'] && (flag_set['c'] || flag_set['w'] || flag_set['C'])) {
     746        paranoid_free(tmp1);
     747    }
     748
     749    if (!flag_set['d']
     750        && (flag_set['c'] || flag_set['w'] || flag_set['C'])) {
    712751        if (g_kernel_version >= 2.6) {
    713752            if (popup_and_get_string
     
    730769        retval++;
    731770        log_to_screen("Please specify the backup device/directory.\n");
    732         fatal_error("You didn't use -d to specify the backup device/directory.");
     771        fatal_error
     772            ("You didn't use -d to specify the backup device/directory.");
    733773    }
    734774
     
    741781    if (flag_set['S']) {
    742782        setup_scratchdir(flag_val['S']);
    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);
     783        sprintf(tmp, "touch %s/.foo.dat", bkpinfo->scratchdir);
     784        if (run_program_and_log_output(tmp, 1)) {
     785            retval++;
    747786            log_to_screen("Please specify a scratchdir which I can write to. :)");
    748787            fatal_error("I cannot write to the scratchdir you specified.");
    749788        }
    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);
     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++;
    756792            log_to_screen("Please don't specify a SAMBA or VFAT or NFS scratchdir.");
    757793            fatal_error("I cannot write to the scratchdir you specified.");
    758794        }
    759         mr_free(tmp1);
    760795    }
    761796
    762797    if (flag_set['T']) {
    763798        setup_tmpdir(flag_val['T']);
    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) {
     799        sprintf(tmp, "touch %s/.foo.dat", bkpinfo->tmpdir);
     800        if (run_program_and_log_output(tmp, 1)) {
    769801            retval++;
    770802            log_to_screen("Please specify a tempdir which I can write to. :)");
    771803            fatal_error("I cannot write to the tempdir you specified.");
    772804        }
    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) {
     805        sprintf(tmp, "ln -sf %s/.foo.dat %s/.bar.dat", bkpinfo->tmpdir, bkpinfo->tmpdir);
     806        if (run_program_and_log_output(tmp, 1)) {
    778807            retval++;
    779808            log_to_screen("Please don't specify a SAMBA or VFAT or NFS tmpdir.");
     
    804833#  endif
    805834#endif
    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");
     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");
    809842        }
    810843#undef BOOT_LOADER_CHARS
     
    812845
    813846    if (flag_set['f']) {
    814         strncpy(bkpinfo->boot_device, resolve_softlinks_to_get_to_actual_device_file(flag_val['f']),MAX_STR_LEN / 4);
     847        strncpy(bkpinfo->boot_device,
     848                resolve_softlinks_to_get_to_actual_device_file(flag_val
     849                                                               ['f']),
     850                MAX_STR_LEN / 4);
    815851    }
    816852
     
    830866        if (run_program_and_log_output("which lzop", 2)) {
    831867            retval++;
    832             log_to_screen("Please install LZOP. You can't use '-L' until you do.\n");
     868            log_to_screen
     869                ("Please install LZOP. You can't use '-L' until you do.\n");
    833870        }
    834871    }
     
    843880        if (run_program_and_log_output("which gzip", 2)) {
    844881            retval++;
    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");
     882            log_to_screen
     883                ("Please install gzip. You can't use '-G' until you do.\n");
    854884        }
    855885    }
     
    867897    if ((!is_this_a_valid_disk_format("vfat")) && (! bkpinfo->restore_data)) {
    868898        bkpinfo->make_cd_use_lilo = TRUE;
    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.");
     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.");
    871903    }
    872904    if ((run_program_and_log_output("which mkfs.vfat", 2)) && (! bkpinfo->restore_data)) {
    873905        bkpinfo->make_cd_use_lilo = TRUE;
    874906#ifdef __IA32__
    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.");
     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.");
    877911#endif
    878912#ifdef __IA64__
    879         log_to_screen("Your filesystem is missing 'mkfs.vfat', so I cannot prepare the EFI");
     913        log_to_screen
     914            ("Your filesystem is missing 'mkfs.vfat', so I cannot prepare the EFI");
    880915        log_to_screen("environment correctly. Please install it.");
    881916        fatal_error("Aborting");
     
    897932
    898933    if ((! bkpinfo->restore_data) && (flag_set['Z'])) {
    899             fatal_error("The -Z switch is only valid in restore mode");
     934            fatal_error
     935                ("The -Z switch is only valid in restore mode");
    900936    }
    901937
     
    937973 * @return The number of problems with the command line (0 for success).
    938974 */
    939 int retrieve_switches_from_command_line(int argc, char *argv[], char flag_val[128][MAX_STR_LEN], bool flag_set[128])
     975int
     976retrieve_switches_from_command_line(int argc, char *argv[],
     977                                    char flag_val[128][MAX_STR_LEN],
     978                                    bool flag_set[128])
    940979{
    941980    /*@ ints ** */
    942981    int opt = 0;
     982    char *tmp = NULL;
    943983    int i = 0;
    944984    int len;
     
    954994        flag_set[i] = FALSE;
    955995    }
    956     while ((opt = getopt(argc, argv, MONDO_OPTIONS)) != -1) {
     996    while ((opt =
     997            getopt(argc, argv, MONDO_OPTIONS))
     998           != -1) {
    957999        if (opt == '?') {
    9581000            bad_switches = TRUE;
     1001            /*log_it("Invalid option: %c\n",optopt); */
    9591002        } else {
    9601003            if (flag_set[opt]) {
    9611004                bad_switches = TRUE;
    962                 log_to_screen("Switch -%c previously defined as %s\n", opt, flag_val[opt]);
     1005                mr_asprintf(tmp, "Switch -%c previously defined as %s\n", opt, flag_val[opt]);
     1006                log_to_screen(tmp);
     1007                paranoid_free(tmp);
    9631008            } else {
    9641009                flag_set[opt] = TRUE;
     
    9741019                        if (strchr(flag_val[opt], '/')
    9751020                            && flag_val[opt][0] != '/') {
    976                             log_to_screen("-%c flag --- must be absolute path --- '%s' isn't absolute", opt, flag_val[opt]);
     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);
    9771024                            bad_switches = TRUE;
    9781025                        }
     
    9851032    for (i = optind; i < argc; i++) {
    9861033        bad_switches = TRUE;
    987         log_to_screen("Invalid arg -- %s\n", argv[i]);
     1034        mr_asprintf(tmp, "Invalid arg -- %s\n", argv[i]);
     1035        log_to_screen(tmp);
     1036        paranoid_free(tmp);
    9881037    }
    9891038    return (bad_switches);
     
    10481097    mr_strcat(tmp, " signal received from OS");
    10491098    log_to_screen(tmp);
    1050     mr_free(tmp);
     1099    paranoid_free(tmp);
    10511100
    10521101    log_to_screen(tmp2);
    1053     mr_free(tmp2);
     1102    paranoid_free(tmp2);
    10541103    if (sig == SIGABRT) {
    10551104        sleep(10);
     
    10591108    free_MR_global_filenames();
    10601109
    1061     fatal_error("MondoRescue is terminating in response to a signal from the OS");
     1110    fatal_error
     1111        ("MondoRescue is terminating in response to a signal from the OS");
    10621112    finish(254);                // just in case
    10631113}
     
    10721122void set_signals(int on)
    10731123{
    1074     int signals[] = { SIGTERM, SIGHUP, SIGTRAP, SIGABRT, SIGINT, SIGKILL, SIGSTOP, 0 };
     1124    int signals[] =
     1125        { SIGTERM, SIGHUP, SIGTRAP, SIGABRT, SIGINT, SIGKILL, SIGSTOP, 0 };
    10751126    int i;
    10761127
Note: See TracChangeset for help on using the changeset viewer.