Changeset 3373 in MondoRescue for branches/3.2/mondo/src/common


Ignore:
Timestamp:
Apr 27, 2015, 4:25:28 PM (9 years ago)
Author:
Bruno Cornec
Message:

Change the bkpinfo->boot_device from statically allocated to dynamically allocated

Location:
branches/3.2/mondo/src/common
Files:
5 edited

Legend:

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

    r3353 r3373  
    596596
    597597    update_evalcall_form(2);
    598     if (!bkpinfo->nonbootable_backup && (bkpinfo->boot_loader == '\0' || bkpinfo->boot_device[0] == '\0')) {
     598    if (!bkpinfo->nonbootable_backup && (bkpinfo->boot_loader == '\0' || bkpinfo->boot_device == NULL)) {
    599599
    600600#ifdef __FreeBSD__
     
    638638            bkpinfo->boot_loader = ch;
    639639        }
    640         if (bkpinfo->boot_device[0] != '\0') {
     640        if (bkpinfo->boot_device != NULL) {
    641641            log_msg(2, "User specified boot device. It is '%s'.", bkpinfo->boot_device);
    642642        } else {
    643             strcpy(bkpinfo->boot_device, bootdev);
     643            mr_asprintf(bkpinfo->boot_device, "%s", bootdev);
    644644        }
    645645    }
  • branches/3.2/mondo/src/common/libmondo-cli.c

    r3351 r3373  
    811811
    812812    if (flag_set['f']) {
    813         strncpy(bkpinfo->boot_device, resolve_softlinks_to_get_to_actual_device_file(flag_val['f']),MAX_STR_LEN / 4);
     813        mr_free(bkpinfo->boot_device);
     814        mr_asprintf(bkpinfo->boot_device, "%s", resolve_softlinks_to_get_to_actual_device_file(flag_val['f']));
    814815    }
    815816
  • branches/3.2/mondo/src/common/libmondo-devices.c

    r3371 r3373  
    25952595
    25962596    if (archiving_to_media) {
    2597 
     2597        mr_free(bkpinfo->boot_device);
    25982598#ifdef __FreeBSD__
    2599         strcpy(bkpinfo->boot_device,
    2600                call_program_and_get_last_line_of_output
    2601                ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'"));
     2599        mr_asprintf(bkpinfo->boot_device, "%s", call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'"));
    26022600#else
    2603         strcpy(bkpinfo->boot_device,
    2604                call_program_and_get_last_line_of_output
    2605                ("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"));
     2601        mr_asprintf(bkpinfo->boot_device, "%s", call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"));
    26062602#endif
    26072603        i = which_boot_loader(bkpinfo->boot_device);
     
    26162612            i = which_boot_loader(bkpinfo->boot_device);
    26172613#else
    2618             if (!popup_and_get_string("Boot device", "What is your boot device? (e.g. /dev/hda)", bkpinfo->boot_device, MAX_STR_LEN / 4)) {
     2614            strcpy(tmp1, bkpinfo->boot_device);
     2615            if (!popup_and_get_string("Boot device", "What is your boot device? (e.g. /dev/hda)", tmp1, MAX_STR_LEN / 4)) {
    26192616                log_to_screen("User has chosen not to backup the PC");
    26202617                finish(1);
    26212618            }
    2622             if (does_string_exist_in_boot_block(bkpinfo->boot_device, "LILO")) {
     2619            mr_free(bkpinfo->boot_device);
     2620            mr_asprintf(bkpinfo->boot_device, "%s", tmp1);
     2621
     2622            if (does_string_exist_in_boot_block(bkpinfo->boot_device, "ELILO")) {
     2623                i = 'E';
     2624            } else
     2625                if (does_string_exist_in_boot_block(bkpinfo->boot_device, "LILO")) {
    26232626                i = 'L';
    2624             } else
    2625                 if (does_string_exist_in_boot_block(bkpinfo->boot_device, "ELILO")) {
    2626                 i = 'E';
    26272627            } else
    26282628                if (does_string_exist_in_boot_block(bkpinfo->boot_device, "GRUB")) {
  • branches/3.2/mondo/src/common/libmondo-tools.c

    r3371 r3373  
    776776    bkpinfo->media_size = -1;
    777777    bkpinfo->boot_loader = '\0';
    778     bkpinfo->boot_device[0] = '\0';
     778    bkpinfo->boot_device = NULL;
    779779    bkpinfo->zip_exe[0] = '\0';
    780780    bkpinfo->zip_suffix[0] = '\0';
  • branches/3.2/mondo/src/common/mondostructures.h

    r3278 r3373  
    361361   * to take truncate_to_drive_name() of where_is_root_mounted().
    362362   */
    363     char boot_device[MAX_STR_LEN / 4];
     363    char *boot_device;
    364364
    365365  /**
Note: See TracChangeset for help on using the changeset viewer.