Changeset 3300 for branches/3.2


Ignore:
Timestamp:
Jun 8, 2014, 10:51:42 AM (5 years ago)
Author:
bruno
Message:
  • Change function which_format_command_do_i_need to allocate string (freed by caller), and also solve an assert issue during fedora tests
Location:
branches/3.2/mondo/src/mondorestore
Files:
2 edited

Legend:

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

    r3292 r3300  
    695695        fprintf(g_fprep, "%s\n", program);
    696696    }
     697    mr_free(program);
    697698    fin = fopen("/tmp/plexes", "r");
    698699    while (fgets(line, MAX_STR_LEN - 1, fin)) {
     
    754755        fprintf(g_fprep, "%s\n", program);
    755756    }
     757    mr_free(program);
    756758}
    757759paranoid_system("sync");
     
    765767if (!strcmp(format, "lvm")) {
    766768    log_msg(1, "Don't format %s - it's part of an lvm volume", device);
    767     mr_free(program);
    768769    return (0);
    769770}
    770 res = which_format_command_do_i_need(format, program);
     771program = which_format_command_do_i_need(format);
    771772mr_asprintf(tmp, "%s %s", program, device);
    772773if (strstr(program, "kludge")) {
     
    21162117 * @return 0 for success, nonzero for failure.
    21172118 */
    2118 int which_format_command_do_i_need(char *format, char *program) {
    2119 
    2120 /** int *************************************************************/
    2121 int res = 0;
    2122 
    2123 /** buffers *********************************************************/
    2124 
    2125 /** end ***************************************************************/
     2119char *which_format_command_do_i_need(char *format) {
    21262120
    21272121assert_string_is_neither_NULL_nor_zerolength(format);
    2128 assert(program != NULL);
    21292122
    21302123if (strcmp(format, "swap") == 0) {
    21312124#ifdef __FreeBSD__
    2132     strcpy(program, "true");
     2125    mr_asprintf(program, "true");
    21332126#else
    2134     strcpy(program, "mkswap");
     2127    mr_asprintf(program, "mkswap");
    21352128#endif
    21362129} else if (strcmp(format, "vfat") == 0) {
    2137     strcpy(program, "format-and-kludge-vfat");
     2130    mr_asprintf(program, "format-and-kludge-vfat");
    21382131#ifndef __FreeBSD__
    21392132} else if (strcmp(format, "reiserfs") == 0) {
    2140     strcpy(program, "mkreiserfs -ff");
     2133    mr_asprintf(program, "mkreiserfs -ff");
    21412134} else if (strcmp(format, "xfs") == 0) {
    2142     strcpy(program, "mkfs.xfs -f -q");
     2135    mr_asprintf(program, "mkfs.xfs -f -q");
    21432136} else if (strcmp(format, "jfs") == 0) {
    2144     strcpy(program, "mkfs.jfs");
     2137    mr_asprintf(program, "mkfs.jfs");
    21452138} else if (strcmp(format, "ext3") == 0) {
    2146     strcpy(program, "mkfs -t ext3 -F -q");
     2139    mr_asprintf(program, "mkfs -t ext3 -F -q");
    21472140} else if (strcmp(format, "ext4") == 0) {
    2148     strcpy(program, "mkfs -t ext4 -F -q");
     2141    mr_asprintf(program, "mkfs -t ext4 -F -q");
    21492142} else if (strcmp(format, "btrfs") == 0) {
    2150     strcpy(program, "mkfs.btrfs");
     2143    mr_asprintf(program, "mkfs.btrfs");
    21512144} else if (strcmp(format, "minix") == 0) {
    2152     strcpy(program, "mkfs.minix");
     2145    mr_asprintf(program, "mkfs.minix");
    21532146} else if (strcmp(format, "vmfs") == 0) {
    2154     strcpy(program, "mkfs -t vmfs");
     2147    mr_asprintf(program, "mkfs -t vmfs");
    21552148} else if (strcmp(format, "ntfs") == 0) {
    21562149    /*
     
    21582151     * so the default "mkfs -t %s -c" command structure fails
    21592152     */
    2160     strcpy(program, "mkfs -t ntfs");
     2153    mr_asprintf(program, "mkfs -t ntfs");
    21612154} else if (strcmp(format, "ocfs2") == 0) {
    21622155    /*
     
    21642157     *
    21652158     */
    2166     strcpy(program, "mkfs -t ocfs2 -F");
     2159    mr_asprintf(program, "mkfs -t ocfs2 -F");
    21672160#endif
    21682161} else if (strcmp(format, "ext2") == 0) {
    2169     strcpy(program, "mke2fs -F -q");
     2162    mr_asprintf(program, "mke2fs -F -q");
    21702163} else {
    21712164#ifdef __FreeBSD__
    2172     sprintf(program, "newfs_%s", format);
     2165    mr_asprintf(program, "newfs_%s", format);
    21732166#else
    2174     sprintf(program, "mkfs -t %s -c", format);  // -c checks for bad blocks
     2167    mr_asprintf(program, "mkfs -t %s -c", format);  // -c checks for bad blocks
    21752168#endif
    21762169    log_it("Unknown format (%s) - assuming '%s' will do", format, program);
    2177     res = 0;
    2178 }
    2179 return (res);
     2170}
     2171return(program);
    21802172}
    21812173
  • branches/3.2/mondo/src/mondorestore/mondoprep.h

    r3042 r3300  
    6969int partition_everything(struct mountlist_itself *);
    7070int do_my_funky_lvm_stuff(bool, bool);
    71 int which_format_command_do_i_need(char *, char *);
     71char *which_format_command_do_i_need(char *);
    7272int make_dummy_partitions(FILE *, char *, int);
    7373int make_list_of_drives(struct mountlist_itself *,
Note: See TracChangeset for help on using the changeset viewer.