Ignore:
Timestamp:
Aug 18, 2009, 3:05:43 PM (15 years ago)
Author:
Bruno Cornec
Message:

r3334@localhost: bruno | 2009-08-08 12:17:37 +0200

  • Change mr_asprintf interface to pass only the char * (makes bkpinfo usage more easy)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/mondorestore/mondo-prep.c

    r2316 r2323  
    7979        make_list_of_drives_in_mountlist(mountlist, drivelist);
    8080        for (lino = 0; lino < drivelist->entries; lino++) {
    81             mr_asprintf(&command, "dd if=%s bs=512 count=1 2> /dev/null | grep \"%s\"", drivelist->el[lino].device, MONDO_WAS_HERE);
     81            mr_asprintf(command, "dd if=%s bs=512 count=1 2> /dev/null | grep \"%s\"", drivelist->el[lino].device, MONDO_WAS_HERE);
    8282            res = run_program_and_log_output(command, 1);
    8383            mr_free(command);
     
    258258        strcpy(vgremove_sz, "vgremove");
    259259    }
    260     mr_asprintf(&tmp1, "for i in `%s | cut -d\"'\" -f2 | sort -r` ; do echo \"Shutting down lv $i\" >> %s ; %s -f $i; done", lvscan_sz, MONDO_LOGFILE, lvremove_sz);
     260    mr_asprintf(tmp1, "for i in `%s | cut -d\"'\" -f2 | sort -r` ; do echo \"Shutting down lv $i\" >> %s ; %s -f $i; done", lvscan_sz, MONDO_LOGFILE, lvremove_sz);
    261261    run_program_and_log_output(tmp1, 5);
    262262    mr_free(tmp1);
     
    305305            *q = '\0';
    306306            log_msg(1, "Deleting old entries at /dev/%s", tmp);
    307             mr_asprintf(&tmp1, "rm -Rf /dev/%s", tmp);
     307            mr_asprintf(tmp1, "rm -Rf /dev/%s", tmp);
    308308            run_program_and_log_output(tmp1, 1);
    309309            mr_free(tmp1);
     
    335335            log_it("%s... so I'll get creative.", tmp);
    336336            if (lvmversion == 2) {
    337                 mr_asprintf(&tmp1, "tail -n5 %s | grep Insufficient | tail -n1", MONDO_LOGFILE);
     337                mr_asprintf(tmp1, "tail -n5 %s | grep Insufficient | tail -n1", MONDO_LOGFILE);
    338338                strcpy(tmp, call_program_and_get_last_line_of_output(tmp1));
    339339                mr_free(tmp1);
    340340            } else {
    341                 mr_asprintf(&tmp1, "tail -n5 %s | grep lvcreate | tail -n1", MONDO_LOGFILE);
     341                mr_asprintf(tmp1, "tail -n5 %s | grep lvcreate | tail -n1", MONDO_LOGFILE);
    342342                strcpy(tmp, call_program_and_get_last_line_of_output(tmp1));
    343343                mr_free(tmp1);
     
    393393            retval++;
    394394        }
    395         mr_asprintf(&tmp1, "echo \"%s\" >> /tmp/out.sh", command);
     395        mr_asprintf(tmp1, "echo \"%s\" >> /tmp/out.sh", command);
    396396        system(tmp1);
    397397        mr_free(tmp1);
     
    484484                 fgets(incoming, MAX_STR_LEN - 1, fin));
    485485            if (!feof(fin)) {
    486                 mr_asprintf(&tmp, "Investigating %s", old_mountlist->el[lino].device);
     486                mr_asprintf(tmp, "Investigating %s", old_mountlist->el[lino].device);
    487487                log_it(tmp);
    488488                mr_free(tmp);
     
    497497                        *p = '\0';
    498498                        for (p--; p > incoming && *(p - 1) > 32; p--);
    499                         mr_asprintf(&tmp, "Extrapolating %s", p);
     499                        mr_asprintf(tmp, "Extrapolating %s", p);
    500500                        log_it(tmp);
    501501                        mr_free(tmp);
     
    518518                            new_mountlist->entries++;
    519519                        } else {
    520                             mr_asprintf(&tmp, "Not adding %s to mountlist: it's already there", p);
     520                            mr_asprintf(tmp, "Not adding %s to mountlist: it's already there", p);
    521521                            log_it(tmp);
    522522                            mr_free(tmp);
     
    582582  }
    583583  // create device list from normal disks followed by spare ones
    584   mr_asprintf(&devices, "%s", raidlist->el[i].data_disks.el[0].device);
     584  mr_asprintf(devices, "%s", raidlist->el[i].data_disks.el[0].device);
    585585  for (j = 1; j < raidlist->el[i].data_disks.entries; j++) {
    586     mr_asprintf(&strtmp, "%s", devices);
     586    mr_asprintf(strtmp, "%s", devices);
    587587    paranoid_free(devices);
    588     mr_asprintf(&devices, "%s %s", strtmp,
     588    mr_asprintf(devices, "%s %s", strtmp,
    589589         raidlist->el[i].data_disks.el[j].device);
    590590    paranoid_free(strtmp);
    591591  }
    592592  for (j = 0; j < raidlist->el[i].spare_disks.entries; j++) {
    593     mr_asprintf(&strtmp, "%s", devices);
     593    mr_asprintf(strtmp, "%s", devices);
    594594    paranoid_free(devices);
    595     mr_asprintf(&devices, "%s %s", strtmp,
     595    mr_asprintf(devices, "%s %s", strtmp,
    596596         raidlist->el[i].spare_disks.el[j].device);
    597597    paranoid_free(strtmp);
     
    599599  // translate RAID level
    600600  if (raidlist->el[i].raid_level == -2) {
    601     mr_asprintf(&level, "multipath");
     601    mr_asprintf(level, "multipath");
    602602  } else if (raidlist->el[i].raid_level == -1) {
    603     mr_asprintf(&level, "linear");
     603    mr_asprintf(level, "linear");
    604604  } else {
    605     mr_asprintf(&level, "raid%d", raidlist->el[i].raid_level);
     605    mr_asprintf(level, "raid%d", raidlist->el[i].raid_level);
    606606  }
    607607  // create RAID device:
     
    610610  // - faulty devices ignored
    611611  // - persistent superblock always used as this is recommended
    612   mr_asprintf(&program, "mdadm --create --force --run --auto=yes %s --level=%s --raid-devices=%d", raidlist->el[i].raid_device, level, raidlist->el[i].data_disks.entries);
     612  mr_asprintf(program, "mdadm --create --force --run --auto=yes %s --level=%s --raid-devices=%d", raidlist->el[i].raid_device, level, raidlist->el[i].data_disks.entries);
    613613  if (raidlist->el[i].parity != -1) {
    614     mr_asprintf(&strtmp, "%s", program);
     614    mr_asprintf(strtmp, "%s", program);
    615615    paranoid_free(program);
    616616    switch(raidlist->el[i].parity) {
    617617    case 0:
    618       mr_asprintf(&program, "%s --parity=%s", strtmp, "la");
     618      mr_asprintf(program, "%s --parity=%s", strtmp, "la");
    619619      break;
    620620    case 1:
    621       mr_asprintf(&program, "%s --parity=%s", strtmp, "ra");
     621      mr_asprintf(program, "%s --parity=%s", strtmp, "ra");
    622622      break;
    623623    case 2:
    624       mr_asprintf(&program, "%s --parity=%s", strtmp, "ls");
     624      mr_asprintf(program, "%s --parity=%s", strtmp, "ls");
    625625      break;
    626626    case 3:
    627       mr_asprintf(&program, "%s --parity=%s", strtmp, "rs");
     627      mr_asprintf(program, "%s --parity=%s", strtmp, "rs");
    628628      break;
    629629    default:
     
    634634  }
    635635  if (raidlist->el[i].chunk_size != -1) {
    636     mr_asprintf(&strtmp, "%s", program);
     636    mr_asprintf(strtmp, "%s", program);
    637637    paranoid_free(program);
    638     mr_asprintf(&program, "%s --chunk=%d", strtmp, raidlist->el[i].chunk_size);
     638    mr_asprintf(program, "%s --chunk=%d", strtmp, raidlist->el[i].chunk_size);
    639639    paranoid_free(strtmp);
    640640  }
    641641  if (raidlist->el[i].spare_disks.entries > 0) {
    642     mr_asprintf(&strtmp, "%s", program);
     642    mr_asprintf(strtmp, "%s", program);
    643643    paranoid_free(program);
    644     mr_asprintf(&program, "%s --spare-devices=%d", strtmp, raidlist->el[i].spare_disks.entries);
     644    mr_asprintf(program, "%s --spare-devices=%d", strtmp, raidlist->el[i].spare_disks.entries);
    645645    paranoid_free(strtmp);
    646646  }
    647   mr_asprintf(&strtmp, "%s", program);
     647  mr_asprintf(strtmp, "%s", program);
    648648  paranoid_free(program);
    649   mr_asprintf(&program, "%s %s", strtmp, devices);
     649  mr_asprintf(program, "%s %s", strtmp, devices);
    650650  paranoid_free(strtmp);
    651651  res = run_program_and_log_output(program, 1);
     
    688688
    689689    if (strstr(format, "raid")) {   // do not form RAID disks; do it to /dev/md* instead
    690         mr_asprintf(&tmp, "Not formatting %s (it is a RAID disk)", device);
     690        mr_asprintf(tmp, "Not formatting %s (it is a RAID disk)", device);
    691691        log_it(tmp);
    692692        mr_free(tmp);
     
    700700#endif
    701701    if (strlen(format) <= 2) {
    702         mr_asprintf(&tmp, "%s has a really small format type ('%s') - this is probably a hexadecimal string, which would suggest the partition is an image --- I shouldn't format it", device, format);
     702        mr_asprintf(tmp, "%s has a really small format type ('%s') - this is probably a hexadecimal string, which would suggest the partition is an image --- I shouldn't format it", device, format);
    703703        log_it(tmp);
    704704        mr_free(tmp);
     
    706706    }
    707707    if (is_this_device_mounted(device)) {
    708         mr_asprintf(&tmp, "%s is mounted - cannot format it       ", device);
     708        mr_asprintf(tmp, "%s is mounted - cannot format it       ", device);
    709709        log_to_screen(tmp);
    710710        mr_free(tmp);
     
    736736            char line[MAX_STR_LEN];
    737737
    738             mr_asprintf(&tmp, "Initializing Vinum device %s (this may take a *long* time)", device);
     738            mr_asprintf(tmp, "Initializing Vinum device %s (this may take a *long* time)", device);
    739739            log_to_screen(tmp);
    740740            mr_free(tmp);
    741741
    742742            /* format raid partition */
    743             mr_asprintf(&program, "for plex in `vinum lv -r %s | grep '^P' | tr '\t' ' ' | tr -s ' ' | cut -d' ' -f2`; do echo $plex; done > /tmp/plexes", basename(device));
     743            mr_asprintf(program, "for plex in `vinum lv -r %s | grep '^P' | tr '\t' ' ' | tr -s ' ' | cut -d' ' -f2`; do echo $plex; done > /tmp/plexes", basename(device));
    744744            system(program);
    745745            if (g_fprep) {
     
    753753                    *(strchr(line, '\n')) = '\0';   // get rid of the \n on the end
    754754
    755                 mr_asprintf(&tmp, "Initializing plex: %s", line);
     755                mr_asprintf(tmp, "Initializing plex: %s", line);
    756756                open_evalcall_form(tmp);
    757757                mr_free(tmp);
    758758
    759                 mr_asprintf(&tmp, "vinum init %s", line);
     759                mr_asprintf(tmp, "vinum init %s", line);
    760760                system(tmp);
    761761                mr_free(tmp);
    762762
    763763                while (1) {
    764                     mr_asprintf(&tmp, "vinum lp -r %s | grep '^S' | head -1 | tr -s ' ' | cut -d: -f2 | cut -f1 | sed 's/^ //' | sed 's/I //' | sed 's/%%//'", line);
     764                    mr_asprintf(tmp, "vinum lp -r %s | grep '^S' | head -1 | tr -s ' ' | cut -d: -f2 | cut -f1 | sed 's/^ //' | sed 's/I //' | sed 's/%%//'", line);
    765765                    FILE *pin = popen(tmp, "r");
    766766                    mr_free(tmp);
     
    782782        }
    783783#else
    784         mr_asprintf(&tmp, "Initializing RAID device %s", device);
     784        mr_asprintf(tmp, "Initializing RAID device %s", device);
    785785        log_to_screen(tmp);
    786786        mr_free(tmp);
     
    798798            log_msg(1, "Creating RAID device %s via mdadm returned %d", device, res);
    799799        } else {
    800             mr_asprintf(&program, "mkraid --really-force %s", device);
     800            mr_asprintf(program, "mkraid --really-force %s", device);
    801801            res = run_program_and_log_output(program, 1);
    802802            log_msg(1, "%s returned %d", program, res);
     
    822822    }
    823823    program = which_format_command_do_i_need(format);
    824     mr_asprintf(&tmp, "%s %s", program, device);
     824    mr_asprintf(tmp, "%s %s", program, device);
    825825    if (strstr(program, "kludge")) {
    826826        mr_strcat(tmp, " /");
     
    828828    mr_free(program);
    829829
    830     mr_asprintf(&program, "sh -c 'echo -en \"y\\ny\\ny\\n\" | %s'", tmp);
     830    mr_asprintf(program, "sh -c 'echo -en \"y\\ny\\ny\\n\" | %s'", tmp);
    831831    mr_free(tmp);
    832832
    833     mr_asprintf(&tmp, "Formatting %s as %s", device, format);
     833    mr_asprintf(tmp, "Formatting %s as %s", device, format);
    834834    update_progress_form(tmp);
    835835    mr_free(tmp);
     
    848848        mr_free(program);
    849849#ifdef __FreeBSD__
    850         mr_asprintf(&program, "newfs_msdos -F 32 %s", device);
     850        mr_asprintf(program, "newfs_msdos -F 32 %s", device);
    851851#else
    852852#ifdef __IA64__
    853853        /* For EFI partitions take fat16
    854854         * as we want to make small ones */
    855         mr_asprintf(&program, "mkfs -t %s -F 16 %s", format, device);
     855        mr_asprintf(program, "mkfs -t %s -F 16 %s", format, device);
    856856#else
    857         mr_asprintf(&program, "mkfs -t %s -F 32 %s", format, device);
     857        mr_asprintf(program, "mkfs -t %s -F 32 %s", format, device);
    858858#endif
    859859#endif
     
    911911
    912912    assert(mountlist != NULL);
    913     mr_asprintf(&tmp, "format_everything (mountlist, interactively = %s", (interactively) ? "true" : "false");
     913    mr_asprintf(tmp, "format_everything (mountlist, interactively = %s", (interactively) ? "true" : "false");
    914914    log_it(tmp);
    915915    mr_free(tmp);
     
    939939            if (interactively) {
    940940                // ask user if we should format the current device
    941                 mr_asprintf(&tmp, "Shall I format %s (%s) ?", me->device, me->mountpoint);
     941                mr_asprintf(tmp, "Shall I format %s (%s) ?", me->device, me->mountpoint);
    942942                do_it = ask_me_yes_or_no(tmp);
    943943                mr_free(tmp);
     
    989989        me = &mountlist->el[lino];  // the current mountlist entry
    990990        if (!strcmp(me->mountpoint, "image")) {
    991             mr_asprintf(&tmp, "Not formatting %s - it's an image", me->device);
     991            mr_asprintf(tmp, "Not formatting %s - it's an image", me->device);
    992992            log_it(tmp);
    993993            mr_free(tmp);
    994994        } else if (!strcmp(me->format, "raid")) {
    995             mr_asprintf(&tmp, "Not formatting %s - it's a raid-let", me->device);
     995            mr_asprintf(tmp, "Not formatting %s - it's a raid-let", me->device);
    996996            log_it(tmp);
    997997            mr_free(tmp);
    998998            continue;
    999999        } else if (!strcmp(me->format, "lvm")) {
    1000             mr_asprintf(&tmp, "Not formatting %s - it's an LVM", me->device);
     1000            mr_asprintf(tmp, "Not formatting %s - it's an LVM", me->device);
    10011001            log_it(tmp);
    10021002            mr_free(tmp);
    10031003            continue;
    10041004        } else if (!strncmp(me->device, "/dev/md", 7)) {
    1005             mr_asprintf(&tmp, "Already formatted %s - it's a soft-RAID dev", me->device);
     1005            mr_asprintf(tmp, "Already formatted %s - it's a soft-RAID dev", me->device);
    10061006            log_it(tmp);
    10071007            mr_free(tmp);
     
    10101010                   && strncmp(me->device, "/dev/hd", 7)
    10111011                   && strncmp(me->device, "/dev/sd", 7)) {
    1012             mr_asprintf(&tmp, "Not formatting %s yet - doesn't exist - probably an LVM", me->device);
     1012            mr_asprintf(tmp, "Not formatting %s yet - doesn't exist - probably an LVM", me->device);
    10131013            log_it(tmp);
    10141014            mr_free(tmp);
     
    10171017            if (interactively) {
    10181018                // ask user if we should format the current device
    1019                 mr_asprintf(&tmp, "Shall I format %s (%s) ?", me->device, me->mountpoint);
     1019                mr_asprintf(tmp, "Shall I format %s (%s) ?", me->device, me->mountpoint);
    10201020                do_it = ask_me_yes_or_no(tmp);
    10211021                mr_free(tmp);
     
    10481048    }
    10491049
    1050     mr_asprintf(&tmp, "format_everything () - %s", (retval) ? "failed!" : "finished successfully");
     1050    mr_asprintf(tmp, "format_everything () - %s", (retval) ? "failed!" : "finished successfully");
    10511051    log_it(tmp);
    10521052    mr_free(tmp);
     
    11111111
    11121112    if (devno_we_must_allow_for >= 5) {
    1113         mr_asprintf(&tmp, "Making dummy primary 1 on %s", drivename);
     1113        mr_asprintf(tmp, "Making dummy primary 1 on %s", drivename);
    11141114        log_it(tmp);
    11151115        mr_free(tmp);
     
    11271127    }
    11281128    for (; current_devno < devno_we_must_allow_for; current_devno++) {
    1129         mr_asprintf(&tmp, "Creating dummy partition %d on %s", current_devno, drivename);
     1129        mr_asprintf(tmp, "Creating dummy partition %d on %s", current_devno, drivename);
    11301130        log_it(tmp);
    11311131        mr_free(tmp);
     
    13601360    for (c = 'a'; c <= 'z'; ++c) {
    13611361        int idx;
    1362         mr_asprintf(&subdev_str, "%s%c", drivename, c);
     1362        mr_asprintf(subdev_str, "%s%c", drivename, c);
    13631363        if ((idx = find_device_in_mountlist(mountlist, subdev_str)) < 0) {
    13641364            lp->d_partitions[c - 'a'].p_size = 0;
     
    14161416    display_disklabel(ftmp, lp);
    14171417    fclose(ftmp);
    1418     mr_asprintf(&command, "disklabel -wr %s auto", canonical_name(drivename));
     1418    mr_asprintf(command, "disklabel -wr %s auto", canonical_name(drivename));
    14191419    retval += run_program_and_log_output(command, TRUE);
    14201420    mr_free(command);
    14211421
    1422     mr_asprintf(&command, "disklabel -R %s /tmp/disklabel", canonical_name(drivename));
     1422    mr_asprintf(command, "disklabel -R %s /tmp/disklabel", canonical_name(drivename));
    14231423    retval += run_program_and_log_output(command, TRUE);
    14241424    mr_free(command);
     
    14681468    malloc_string(format);
    14691469
    1470     mr_asprintf(&tmp, "Partitioning drive %s", drivename);
     1470    mr_asprintf(tmp, "Partitioning drive %s", drivename);
    14711471    log_it(tmp);
    14721472    mr_free(tmp);
     
    14771477#else
    14781478    make_hole_for_file(FDISK_LOG);
    1479     mr_asprintf(&tmp, "parted2fdisk %s >> %s 2>> %s", drivename, FDISK_LOG, FDISK_LOG);
     1479    mr_asprintf(tmp, "parted2fdisk %s >> %s 2>> %s", drivename, FDISK_LOG, FDISK_LOG);
    14801480    pout_to_fdisk = popen(tmp, "w");
    14811481    mr_free(tmp);
     
    15001500                // try DangerouslyDedicated mode
    15011501                for (c = 'a'; c <= 'z'; c++) {
    1502                     mr_asprintf(&subdev_str, "%s%c", drivename, c);
     1502                    mr_asprintf(subdev_str, "%s%c", drivename, c);
    15031503                    if (find_device_in_mountlist(mountlist, subdev_str) > 0) {
    15041504                        fbsd_part = TRUE;
     
    15101510                                                 drivename,
    15111511                                                 0);
    1512                     mr_asprintf(&command, "disklabel -B %s", basename(drivename));
     1512                    mr_asprintf(command, "disklabel -B %s", basename(drivename));
    15131513                    if (system(command)) {
    15141514                        log_to_screen
     
    15221522            }
    15231523            for (c = 'a'; c <= 'z'; c++) {
    1524                 mr_asprintf(&subdev_str, "%s%c", device_str, c);
     1524                mr_asprintf(subdev_str, "%s%c", device_str, c);
    15251525                if (find_device_in_mountlist(mountlist, subdev_str) > 0) {
    15261526                    fbsd_part = TRUE;
     
    15351535                partsize = 0;
    15361536                for (i = 'a'; i < 'z'; ++i) {
    1537                     mr_asprintf(&subdev_str, "%s%c", device_str, i);
     1537                    mr_asprintf(subdev_str, "%s%c", device_str, i);
    15381538                    line = find_device_in_mountlist(mountlist, subdev_str);
    15391539                    mr_free(subdev_str);
     
    15651565            file = open(drivename, O_WRONLY);
    15661566            if (file != -1) {
    1567                 mr_asprintf(&tmp, "Warning - unable to open %s for wiping it's partition table", drivename);
     1567                mr_asprintf(tmp, "Warning - unable to open %s for wiping it's partition table", drivename);
    15681568                log_to_screen(tmp);
    15691569                mr_free(tmp);
     
    15721572            for (i = 0; i < 512; i++) {
    15731573                if (!write(file, "\0", 1)) {
    1574                     mr_asprintf(&tmp, "Warning - unable to write to %s", drivename);
     1574                    mr_asprintf(tmp, "Warning - unable to write to %s", drivename);
    15751575                    log_to_screen(tmp);
    15761576                    mr_free(tmp);
     
    16181618#ifdef __FreeBSD__
    16191619        if ((current_devno <= 4) && fbsd_part) {
    1620             mr_asprintf(&tmp, "disklabel -B %s", basename(device_str));
     1620            mr_asprintf(tmp, "disklabel -B %s", basename(device_str));
    16211621            retval += label_drive_or_slice(mountlist, device_str, 0);
    16221622            if (system(tmp)) {
     
    16341634    if (pout_to_fdisk) {
    16351635// mark relevant partition as bootable
    1636         mr_asprintf(&tmp, "a\n%s\n", call_program_and_get_last_line_of_output("make-me-bootable /tmp/mountlist.txt dummy"));
     1636        mr_asprintf(tmp, "a\n%s\n", call_program_and_get_last_line_of_output ("make-me-bootable /tmp/mountlist.txt dummy"));
    16371637        fput_string_one_char_at_a_time(pout_to_fdisk, tmp);
    16381638        mr_free(tmp);
     
    16441644        log_msg(0,
    16451645                "------------------- fdisk.log looks like this ------------------");
    1646         mr_asprintf(&tmp, "cat %s >> %s", FDISK_LOG, MONDO_LOGFILE);
     1646        mr_asprintf(tmp, "cat %s >> %s", FDISK_LOG, MONDO_LOGFILE);
    16471647        system(tmp);
    16481648        mr_free(tmp);
     
    16501650        log_msg(0,
    16511651                "------------------- end of fdisk.log... word! ------------------");
    1652         mr_asprintf(&tmp, "tail -n6 %s | grep -F \"16: \"", FDISK_LOG);
     1652        mr_asprintf(tmp, "tail -n6 %s | grep -F \"16: \"", FDISK_LOG);
    16531653        if (!run_program_and_log_output(tmp, 5)) {
    16541654            g_partition_table_locked_up++;
     
    16561656        mr_free(tmp);
    16571657
    1658         mr_asprintf(&tmp, "partprobe %s", drivename);
     1658        mr_asprintf(tmp, "partprobe %s", drivename);
    16591659        if (!run_program_and_log_output(tmp, 5)) {
    16601660            g_partition_table_locked_up--;
     
    17081708
    17091709    if (!strncmp(drive, RAID_DEVICE_STUB, strlen(RAID_DEVICE_STUB))) {
    1710         mr_asprintf(&tmp, "Not partitioning %s - it is a virtual drive", drive);
     1710        mr_asprintf(tmp, "Not partitioning %s - it is a virtual drive", drive);
    17111711        log_it(tmp);
    17121712        mr_free(tmp);
     
    17161716    partition_name = build_partition_name(drive, partno);
    17171717    if (partsize <= 0) {
    1718         mr_asprintf(&tmp, "Partitioning device %s (max size)", partition_name);
     1718        mr_asprintf(tmp, "Partitioning device %s (max size)", partition_name);
    17191719    } else {
    1720         mr_asprintf(&tmp, "Partitioning device %s (%lld MB)", partition_name, (long long) partsize / 1024);
     1720        mr_asprintf(tmp, "Partitioning device %s (%lld MB)", partition_name, (long long) partsize / 1024);
    17211721    }
    17221722    update_progress_form(tmp);
     
    17251725
    17261726    if (is_this_device_mounted(partition_name)) {
    1727         mr_asprintf(&tmp, "%s is mounted, and should not be partitioned", partition_name);
     1727        mr_asprintf(tmp, "%s is mounted, and should not be partitioned", partition_name);
    17281728        log_to_screen(tmp);
    17291729        mr_free(tmp);
     
    17371737    /* BERLIOS: should not be called each time */
    17381738    part_table_fmt = which_partition_format(drive);
    1739     mr_asprintf(&output, "");
     1739    mr_asprintf(output, "");
    17401740    /* make it a primary/extended/logical */
    17411741    if (partno <= 4) {
     
    17691769    }
    17701770    mr_strcat(output, "\n");
    1771     mr_asprintf(&tmp,"PARTSIZE = +%ld",(long)partsize);
     1771    mr_asprintf(tmp,"PARTSIZE = +%ld",(long)partsize);
    17721772    log_it(tmp);
    17731773    mr_free(tmp);
     
    17771777    log_it("---end of fdisk---");
    17781778
    1779     mr_asprintf(&program, "parted2fdisk %s >> %s 2>> %s", drive, MONDO_LOGFILE, MONDO_LOGFILE);
     1779    mr_asprintf(program, "parted2fdisk %s >> %s 2>> %s", drive, MONDO_LOGFILE, MONDO_LOGFILE);
    17801780    if (pout_to_fdisk) {
    17811781        log_msg(1, "Doing the new all-in-one fdisk thing");
     
    17831783        fput_string_one_char_at_a_time(pout_to_fdisk, output);
    17841784        fput_string_one_char_at_a_time(pout_to_fdisk, "\n\np\n");
    1785         mr_asprintf(&tmp, "%s", last_line_of_file(FDISK_LOG));
     1785        mr_asprintf(tmp, "%s", last_line_of_file(FDISK_LOG));
    17861786        if (strstr(tmp, " (m ")) {
    17871787            log_msg(1, "Successfully created partition %d on %s", partno, drive);
     
    18261826                                 format, -1);
    18271827            if (res) {
    1828                 mr_asprintf(&tmp, "Failed to vacuum-pack %s", partition_name);
     1828                mr_asprintf(tmp, "Failed to vacuum-pack %s", partition_name);
    18291829                log_it(tmp);
    18301830                mr_free(tmp);
     
    18401840                                   partsize);
    18411841            if (retval) {
    1842                 mr_asprintf(&tmp, "Partitioned %s but failed to set its type", partition_name);
     1842                mr_asprintf(tmp, "Partitioned %s but failed to set its type", partition_name);
    18431843                log_it(tmp);
    18441844                mr_free(tmp);
    18451845            } else {
    18461846                if (partsize > 0) {
    1847                     mr_asprintf(&tmp, "Partition %s created+configured OK", partition_name);
     1847                    mr_asprintf(tmp, "Partition %s created+configured OK", partition_name);
    18481848                    log_to_screen(tmp);
    18491849                    mr_free(tmp);
     
    18531853            }
    18541854        } else {
    1855             mr_asprintf(&tmp, "Failed to partition %s", partition_name);
     1855            mr_asprintf(tmp, "Failed to partition %s", partition_name);
    18561856            if (partsize > 0) {
    18571857                log_to_screen(tmp);
     
    19971997    p = (char *) strrchr(partition, '/');
    19981998    if (strcmp(format, "swap") == 0) {
    1999         mr_asprintf(&partcode, "82");
     1999        mr_asprintf(partcode, "82");
    20002000    } else if (strcmp(format, "vfat") == 0) {
    20012001        if (partsize / 1024 > 8192) {
    2002             mr_asprintf(&partcode, "c");
     2002            mr_asprintf(partcode, "c");
    20032003        } else {
    2004             mr_asprintf(&partcode, "b");
     2004            mr_asprintf(partcode, "b");
    20052005        }
    20062006    } else if (strcmp(format, "ext2") == 0
     
    20102010               || strcmp(format, "xfs") == 0
    20112011               || strcmp(format, "jfs") == 0) {
    2012         mr_asprintf(&partcode, "83");
     2012        mr_asprintf(partcode, "83");
    20132013    } else if (strcmp(format, "minix") == 0) {
    2014         mr_asprintf(&partcode, "81");
     2014        mr_asprintf(partcode, "81");
    20152015    } else if (strcmp(format, "vmfs3") == 0) {
    2016         mr_asprintf(&partcode, "fb");
     2016        mr_asprintf(partcode, "fb");
    20172017    } else if (strcmp(format, "vmkcore") == 0) {
    2018         mr_asprintf(&partcode, "fc");
     2018        mr_asprintf(partcode, "fc");
    20192019    } else if (strcmp(format, "raid") == 0) {
    2020         mr_asprintf(&partcode, "fd");
     2020        mr_asprintf(partcode, "fd");
    20212021    } else if (strcmp(format, "ntfs") == 0) {
    2022         mr_asprintf(&partcode, "7");
     2022        mr_asprintf(partcode, "7");
    20232023    } else if ((strcmp(format, "ufs") == 0)
    20242024               || (strcmp(format, "ffs") == 0)) {   /* raid autodetect */
    2025         mr_asprintf(&partcode, "a5");
     2025        mr_asprintf(partcode, "a5");
    20262026    } else if (strcmp(format, "lvm") == 0) {
    2027         mr_asprintf(&partcode, "8e");
     2027        mr_asprintf(partcode, "8e");
    20282028    } else if (format[0] == '\0') { /* LVM physical partition */
    2029         mr_asprintf(&partcode, "");
     2029        mr_asprintf(partcode, "");
    20302030    } else if (strlen(format) >= 1 && strlen(format) <= 2) {
    2031         mr_asprintf(&partcode, format);
     2031        mr_asprintf(partcode, format);
    20322032    } else {
    20332033        /* probably an image */
    2034         mr_asprintf(&tmp, "Unknown format ('%s') - using supplied string anyway", format);
     2034        mr_asprintf(tmp, "Unknown format ('%s') - using supplied string anyway", format);
    20352035        mvaddstr_and_log_it(g_currentY++, 0, tmp);
    20362036        mr_free(tmp);
    20372037#ifdef __FreeBSD__
    2038         mr_asprintf(&partcode, format); // was a5
     2038        mr_asprintf(partcode, format);  // was a5
    20392039#else
    2040         mr_asprintf(&partcode, format); // was 83
     2040        mr_asprintf(partcode, format);  // was 83
    20412041#endif
    20422042    }
     
    20522052                || strstr(last_line_of_file(FDISK_LOG), " (1-4)")) {
    20532053                log_msg(5, "Specifying partno (%d) - yay", partno);
    2054                 mr_asprintf(&tmp, "%d\n", partno);
     2054                mr_asprintf(tmp, "%d\n", partno);
    20552055                fput_string_one_char_at_a_time(pout_to_fdisk, tmp);
    20562056                mr_free(tmp);
     
    20602060            }
    20612061
    2062             mr_asprintf(&tmp, "%s\n", partcode);
     2062            mr_asprintf(tmp, "%s\n", partcode);
    20632063            fput_string_one_char_at_a_time(pout_to_fdisk, tmp);
    20642064            mr_free(tmp);
     
    20702070                    last_line_of_file(FDISK_LOG));
    20712071
    2072             mr_asprintf(&tmp, "%s", last_line_of_file(FDISK_LOG));
     2072            mr_asprintf(tmp, "%s", last_line_of_file(FDISK_LOG));
    20732073            if (!strstr(tmp, " (m ")) {
    20742074                log_msg(1, "last line = '%s'; part type set failed", tmp);
     
    20802080            fput_string_one_char_at_a_time(pout_to_fdisk, "p\n");
    20812081        } else {
    2082             mr_asprintf(&output, "t\n%d\n%s\nw\n", partno, partcode);
    2083             mr_asprintf(&command, "parted2fdisk %s >> %s 2>> %s", drive,
     2082            mr_asprintf(output, "t\n%d\n%s\nw\n", partno, partcode);
     2083            mr_asprintf(command, "parted2fdisk %s >> %s 2>> %s", drive,
    20842084                    MONDO_LOGFILE, MONDO_LOGFILE);
    20852085            log_msg(5, "output = '%s'", output);
     
    21232123        return 1;
    21242124    }
    2125     mr_asprintf(&program, "vinum start -f %s", raid_device);
     2125    mr_asprintf(program, "vinum start -f %s", raid_device);
    21262126#else
    2127     mr_asprintf(&program, "raidstart %s", raid_device);
     2127    mr_asprintf(program, "raidstart %s", raid_device);
    21282128#endif
    21292129    log_msg(1, "program = %s", program);
     
    21682168        return 1;
    21692169    }
    2170     mr_asprintf(&program, "vinum stop -f %s", raid_device);
     2170    mr_asprintf(program, "vinum stop -f %s", raid_device);
    21712171#else
    21722172    // use raidstop if it exists, otherwise use mdadm
    21732173    if (run_program_and_log_output("which raidstop", FALSE)) {
    2174         mr_asprintf(&program, "mdadm -S %s", raid_device);
     2174        mr_asprintf(program, "mdadm -S %s", raid_device);
    21752175    } else {
    2176         mr_asprintf(&program, "raidstop %s", raid_device);
     2176        mr_asprintf(program, "raidstop %s", raid_device);
    21772177    }
    21782178#endif
     
    23202320    if (strcmp(format, "swap") == 0) {
    23212321#ifdef __FreeBSD__
    2322         mr_asprintf(&program, "true");
     2322        mr_asprintf(program, "true");
    23232323#else
    2324         mr_asprintf(&program, "mkswap");
     2324        mr_asprintf(program, "mkswap");
    23252325#endif
    23262326    } else if (strcmp(format, "vfat") == 0) {
    2327         mr_asprintf(&program, "format-and-kludge-vfat");
     2327        mr_asprintf(program, "format-and-kludge-vfat");
    23282328#ifndef __FreeBSD__
    23292329    } else if (strcmp(format, "reiserfs") == 0) {
    2330         mr_asprintf(&program, "mkreiserfs -ff");
     2330        mr_asprintf(program, "mkreiserfs -ff");
    23312331    } else if (strcmp(format, "xfs") == 0) {
    2332         mr_asprintf(&program, "mkfs.xfs -f -q");
     2332        mr_asprintf(program, "mkfs.xfs -f -q");
    23332333    } else if (strcmp(format, "jfs") == 0) {
    2334         mr_asprintf(&program, "mkfs.jfs");
     2334        mr_asprintf(program, "mkfs.jfs");
    23352335    } else if (strcmp(format, "ext3") == 0) {
    2336         mr_asprintf(&program, "mkfs -t ext3 -F -q");
     2336        mr_asprintf(program, "mkfs -t ext3 -F -q");
    23372337    } else if (strcmp(format, "ext4") == 0) {
    2338         mr_asprintf(&program, "mkfs -t ext4 -F -q");
     2338        mr_asprintf(program, "mkfs -t ext4 -F -q");
    23392339    } else if (strcmp(format, "minix") == 0) {
    2340         mr_asprintf(&program, "mkfs.minix");
     2340        mr_asprintf(program, "mkfs.minix");
    23412341    } else if (strcmp(format, "vmfs") == 0) {
    2342         mr_asprintf(&program, "mkfs -t vmfs");
     2342        mr_asprintf(program, "mkfs -t vmfs");
    23432343    } else if (strcmp(format, "ntfs") == 0) {
    23442344        /*
     
    23462346         * so the default "mkfs -t %s -c" command structure fails
    23472347         */
    2348         mr_asprintf(&program, "mkfs -t ntfs");
     2348        mr_asprintf(program, "mkfs -t ntfs");
    23492349    } else if (strcmp(format, "ocfs2") == 0) {
    23502350        /*
     
    23522352         *
    23532353         */
    2354         mr_asprintf(&program, "mkfs -t ocfs2 -F");
     2354        mr_asprintf(program, "mkfs -t ocfs2 -F");
    23552355#endif
    23562356    } else if (strcmp(format, "ext2") == 0) {
    2357         mr_asprintf(&program, "mke2fs -F -q");
     2357        mr_asprintf(program, "mke2fs -F -q");
    23582358    } else {
    23592359#ifdef __FreeBSD__
    2360         mr_asprintf(&program, "newfs_%s", format);
     2360        mr_asprintf(program, "newfs_%s", format);
    23612361#else
    2362         mr_asprintf(&program, "mkfs -t %s -c", format); // -c checks for bad blocks
    2363 #endif
    2364         mr_asprintf(&tmp, "Unknown format (%s) - assuming '%s' will do", format, program);
     2362        mr_asprintf(program, "mkfs -t %s -c", format);  // -c checks for bad blocks
     2363#endif
     2364        mr_asprintf(tmp, "Unknown format (%s) - assuming '%s' will do", format, program);
    23652365        log_it(tmp);
    23662366        mr_free(tmp);
     
    24252425        return;
    24262426    }
    2427     mr_asprintf(&tmp, "Expanding entries to suit drive %s (%ld MB)", drive_name, current_size_of_drive);
     2427    mr_asprintf(tmp, "Expanding entries to suit drive %s (%ld MB)", drive_name, current_size_of_drive);
    24282428    log_to_screen(tmp);
    24292429    mr_free(tmp);
     
    24452445
    24462446    if (original_size_of_drive <= 0) {
    2447         mr_asprintf(&tmp, "Cannot resize %s's entries. Drive not found.", drive_name);
     2447        mr_asprintf(tmp, "Cannot resize %s's entries. Drive not found.", drive_name);
    24482448        log_to_screen(tmp);
    24492449        mr_free(tmp);
     
    24512451    }
    24522452    factor = (float) (current_size_of_drive) / (float) (original_size_of_drive);
    2453     mr_asprintf(&tmp, "Disk %s was %ld MB; is now %ld MB; factor = %f", drive_name, original_size_of_drive, current_size_of_drive, factor);
     2453    mr_asprintf(tmp, "Disk %s was %ld MB; is now %ld MB; factor = %f", drive_name, original_size_of_drive, current_size_of_drive, factor);
    24542454    log_to_screen(tmp);
    24552455    mr_free(tmp);
     
    24782478        }
    24792479
    2480         mr_asprintf(&tmp, "Changing %s from %lld KB to %ld KB", drivemntlist->el[partno]->device, drivemntlist->el[partno]->size, newsizL);
     2480        mr_asprintf(tmp, "Changing %s from %lld KB to %ld KB", drivemntlist->el[partno]->device, drivemntlist->el[partno]->size, newsizL);
    24812481        log_to_screen(tmp);
    24822482        mr_free(tmp);
     
    24842484    }
    24852485    final_size = get_phys_size_of_drive(drive_name);
    2486     mr_asprintf(&tmp, "final_size = %ld MB", final_size);
     2486    mr_asprintf(tmp, "final_size = %ld MB", final_size);
    24872487    log_to_screen(tmp);
    24882488    mr_free(tmp);
Note: See TracChangeset for help on using the changeset viewer.