Changeset 2320


Ignore:
Timestamp:
Aug 18, 2009, 2:37:39 PM (10 years ago)
Author:
bruno
Message:

r3331@localhost: bruno | 2009-08-06 01:34:32 +0200

  • bkpinfo->scratchdir is now dynamically allocated
  • mondoarchive tests made in text+newt env. Seems OK. Valgrind errors to be fixed
Location:
branches/2.2.10/mondo
Files:
14 edited

Legend:

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

    r2318 r2320  
    337337        mr_asprintf(&zipparams, "");
    338338    }
    339 
    340 //  make_hole_for_file(fname);
    341339
    342340    if (!does_file_exist(bkpinfo->tmpdir)) {
     
    543541
    544542    assert(bkpinfo != NULL);
    545     mr_asprintf(&tmp, "echo '%s' | tr -s ' ' '\n' | grep -E '^/dev/.*$' | tr -s '\n' ' ' | awk '{print $0\"\\n\";}'", bkpinfo->exclude_paths);
    546     mr_asprintf(&devs_to_exclude, "%s", call_program_and_get_last_line_of_output(tmp));
    547     mr_free(tmp);
    548 
    549     mr_asprintf(&tmp, "devs_to_exclude = '%s'", devs_to_exclude);
    550     log_msg(2, tmp);
    551     mr_free(tmp);
     543    if (bkpinfo->exclude_paths) {
     544        mr_asprintf(&tmp, "echo '%s' | tr -s ' ' '\n' | grep -E '^/dev/.*$' | tr -s '\n' ' ' | awk '{print $0\"\\n\";}'", bkpinfo->exclude_paths);
     545        mr_asprintf(&devs_to_exclude, "%s", call_program_and_get_last_line_of_output(tmp));
     546        mr_free(tmp);
     547
     548        mr_asprintf(&tmp, "devs_to_exclude = '%s'", devs_to_exclude);
     549        log_msg(2, tmp);
     550        mr_free(tmp);
     551    }
    552552
    553553    mvaddstr_and_log_it(g_currentY, 0,
     
    885885            last_filelist_number,   // parameter #12 (STRING)
    886886            estimated_total_noof_slices,    // parameter #13 (INT)
    887             devs_to_exclude,    // parameter #14
     887            (devs_to_exclude == NULL) ? "\"\"" : devs_to_exclude,   // parameter #14
    888888            use_comp_sz,        // parameter #15
    889889            use_lilo_sz,        // parameter #16
     
    920920    if (!res) {
    921921        log_to_screen("Boot+data disks were created OK");
    922         mr_asprintf(&command, "cp -f %s/images/mindi.iso %s/mondorescue.iso",
    923                 bkpinfo->scratchdir, MINDI_CACHE);
     922        mr_asprintf(&command, "cp -f %s/images/mindi.iso %s/mondorescue.iso", bkpinfo->scratchdir, MINDI_CACHE);
    924923        log_msg(2, command);
    925924        run_program_and_log_output(command, FALSE);
     
    927926
    928927        if (bkpinfo->nonbootable_backup) {
    929             mr_asprintf(&command, "cp -f %s/all.tar.gz %s/images",
    930                     bkpinfo->tmpdir, bkpinfo->scratchdir);
     928            mr_asprintf(&command, "cp -f %s/all.tar.gz %s/images", bkpinfo->tmpdir, bkpinfo->scratchdir);
    931929            if (system(command)) {
    932930                paranoid_free(command);
     
    941939            paranoid_free(command);
    942940        } else {
    943             mr_asprintf(&tmp, "cp -f %s/images/all.tar.gz %s", bkpinfo->scratchdir,
    944                 bkpinfo->tmpdir);
     941            mr_asprintf(&tmp, "cp -f %s/images/all.tar.gz %s", bkpinfo->scratchdir, bkpinfo->tmpdir);
    945942            if (system(tmp)) {
    946943                fatal_error("Cannot find all.tar.gz in tmpdir");
     
    16891686    }
    16901687
    1691     log_msg(2, "make_iso_fs --- scratchdir=%s --- destfile=%s",
    1692             bkpinfo->scratchdir, destfile);
     1688    log_msg(2, "make_iso_fs --- scratchdir=%s --- destfile=%s", bkpinfo->scratchdir, destfile);
    16931689    (void) getcwd(old_pwd, MAX_STR_LEN - 1);
    16941690    mr_asprintf(&tmp, "chmod 755 %s", bkpinfo->scratchdir);
     
    17271723        } else {
    17281724            res =
    1729                 eval_call_to_make_ISO(bkpinfo->call_make_iso,
    1730                                       bkpinfo->scratchdir,
    1731                                       g_current_media_number,
    1732                                       MONDO_LOGFILE, message_to_screen);
     1725                eval_call_to_make_ISO(bkpinfo->call_make_iso, bkpinfo->scratchdir, g_current_media_number, MONDO_LOGFILE, message_to_screen);
    17331726            if (res) {
    17341727                log_to_screen("%s...failed to write", message_to_screen);
     
    17891782                pause_for_N_seconds(5, "Letting DVD drive settle");
    17901783                res =
    1791                     eval_call_to_make_ISO(bkpinfo->call_make_iso,
    1792                                           bkpinfo->scratchdir,
    1793                                           g_current_media_number,
    1794                                           MONDO_LOGFILE,
    1795                                           message_to_screen);
     1784                    eval_call_to_make_ISO(bkpinfo->call_make_iso, bkpinfo->scratchdir, g_current_media_number, MONDO_LOGFILE, message_to_screen);
    17961785                retval += res;
    17971786                if (!bkpinfo->please_dont_eject) {
     
    23782367    if (g_getfattr) {
    23792368        get_fattr_list(biggielist, xattr_fname);
    2380         mr_asprintf(&command, "cp %s %s/archives/", xattr_fname,
    2381             bkpinfo->scratchdir);
     2369        mr_asprintf(&command, "cp %s %s/archives/", xattr_fname, bkpinfo->scratchdir);
    23822370        paranoid_system(command);
    23832371        mr_free(command);
     
    33023290    paranoid_fclose(fout);
    33033291
    3304     mr_asprintf(&tmp1, "cp -f %s/autorun %s/", g_mondo_home,
    3305             bkpinfo->scratchdir);
     3292    mr_asprintf(&tmp1, "cp -f %s/autorun %s/", g_mondo_home, bkpinfo->scratchdir);
    33063293    if (run_program_and_log_output(tmp1, FALSE)) {
    33073294        log_msg(2, "Warning - unable to copy autorun to scratchdir");
  • branches/2.2.10/mondo/src/common/libmondo-cli.c

    r2319 r2320  
    5656static int get_dsf_mount_list (const char *dsf, char **included_dsf_list, char **excluded_dsf_list);
    5757static int create_list_of_non_NFS_mounted_file_systems (void);
    58 static MOUNTED_FS_STRUCT *find_mount_point_in_list (char *mount_point);
    59 static MOUNTED_FS_STRUCT *find_device_in_list (char *device);
     58static MOUNTED_FS_STRUCT *find_mount_point_in_list (const char *mount_point);
     59static MOUNTED_FS_STRUCT *find_device_in_list (const char *device);
    6060
    6161/* Do we use extended attributes and acl ?
     
    124124    mr_free(tmp);
    125125
    126     sprintf(bkpinfo->scratchdir + strlen(bkpinfo->scratchdir),
    127             "/mondo.scratch.%ld", random() % 32767);
     126    mr_strcat(bkpinfo->scratchdir, "/mondo.scratch.%ld", random() % 32767);
     127
    128128    mr_asprintf(&tmp, "mkdir -p %s/tmpfs", bkpinfo->tmpdir);
    129129    paranoid_system(tmp);
     
    168168        bkpinfo->media_size[j] = friendly_sizestr_to_sizelong(p);
    169169    }
    170 //      bkpinfo->media_size[0] = bkpinfo->media_size[MAX_NOOF_MEDIA];
    171170    for (j = 1; j <= MAX_NOOF_MEDIA; j++) {
    172171        if (bkpinfo->media_size[j] <= 0) {
     
    189188    while (DSFptr != NULL) {
    190189        DSFnext = DSFptr->next;
    191         paranoid_free(DSFptr);
     190        mr_free(DSFptr);
    192191        DSFptr = DSFnext;
    193192    }
     
    221220 * structure if it did.
    222221 */
    223 static MOUNTED_FS_STRUCT *find_device_in_list (char *device)
     222static MOUNTED_FS_STRUCT *find_device_in_list (const char *device)
    224223{
    225224    MOUNTED_FS_STRUCT *DSFptr = NULL;
     
    242241 * structure if it did.
    243242 */
    244 static MOUNTED_FS_STRUCT *find_mount_point_in_list (char *mount_point)
     243static MOUNTED_FS_STRUCT *find_mount_point_in_list (const char *mount_point)
    245244{
    246245    MOUNTED_FS_STRUCT *DSFptr = NULL;
     
    283282    log_msg(5, "Running: %s", command);
    284283    mr_asprintf(&mounted_file_system, "%s", call_program_and_get_last_line_of_output(command));
    285     paranoid_free(command);
     284    mr_free(command);
    286285
    287286    mount_cnt = atoi(mounted_file_system);
    288287    log_msg (5, "mount_cnt: %d", mount_cnt);
    289     paranoid_free(mounted_file_system);
     288    mr_free(mounted_file_system);
    290289
    291290    for (i=mount_cnt; i > 0; i--) {
     
    293292        log_msg(5, "Running: %s", command);
    294293        mr_asprintf(&mounted_file_system, "%s", call_program_and_get_last_line_of_output(command));
    295         paranoid_free(command);
     294        mr_free(command);
    296295
    297296        log_msg (5, "mounted_file_system: %s", mounted_file_system);
    298297        if ((token = strtok(mounted_file_system, token_chars)) == NULL) {
    299298            log_msg (4, "Could not get the list of mounted file systems");
    300             paranoid_free(mounted_file_system);
     299            mr_free(mounted_file_system);
    301300            mr_free(token);
    302301            return (1);
     
    315314            if ((token = strtok(NULL, token_chars)) == NULL) {
    316315                log_msg (5, "Ran out of entries on the mounted file systems list");
    317                 paranoid_free(mounted_file_system);
     316                mr_free(mounted_file_system);
    318317                mr_free(token);
    319318                return (1);
     
    324323            token = strtok(NULL, token_chars);
    325324        }
    326         paranoid_free(mounted_file_system);
     325        mr_free(mounted_file_system);
    327326    }
    328327    /********
     
    377376    log_msg(5, "  Executing: %s", command);
    378377    mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
    379     paranoid_free(command);
     378    mr_free(command);
    380379
    381380    log_msg(5, "  Return value: %s", tmp);
    382381    c = atoi(tmp);
    383     paranoid_free(tmp);
     382    mr_free(tmp);
    384383
    385384    if (!c) {
     
    403402    log_msg(4, "Executing: %s", command);
    404403    mr_asprintf(&partition_list, "%s", call_program_and_get_last_line_of_output(command));
    405     paranoid_free(command);
     404    mr_free(command);
    406405    log_msg(4, "Partition list for %s: %s", dsf, partition_list);
    407406    if (!strlen(partition_list)) {
     
    419418        mr_free(token);
    420419    }
    421     paranoid_free(partition_list);
     420    mr_free(partition_list);
    422421 
    423422    /********
     
    457456        log_msg(4, "  Running: %s", command);
    458457        mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
    459         paranoid_free(command);
     458        mr_free(command);
     459
    460460        log_msg(4, "  Return value: %s", tmp);
    461461        c = strlen(tmp);
    462         paranoid_free(tmp);
     462        mr_free(tmp);
     463
    463464        if (c) {
    464465            log_msg(4, "It's swap. Ignoring partition %s", partitions[i]);
     
    468469        mr_asprintf(&command, "mount 2>/dev/null | awk '{if((NF>0)&&($1==\"%s\")){print $3}}'", partitions[i]);
    469470        mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
    470         paranoid_free(command);
     471        mr_free(command);
     472
    471473        if (strlen(tmp)) {
    472474            log_msg(4, "  %s is mounted: %s", partitions[i], tmp);
    473475            if ((DSFptr = find_mount_point_in_list(tmp)) == NULL) {
    474476                log_msg (4, "Can't find mount point %s in mounted file systems list", tmp);
    475                 paranoid_free(tmp);
     477                mr_free(tmp);
    476478                return (1);
    477479            }
    478480            DSFptr->check = 1;
    479             paranoid_free(tmp);
     481            mr_free(tmp);
    480482            continue;
    481483        }
    482         paranoid_free(tmp);
     484        mr_free(tmp);
    483485        /* It's not swap and it's not mounted. See if it's LVM */
    484486        log_msg(4, "  It's not mounted. Checking to see if it's LVM...");
     
    487489        log_msg(4, "  Running: %s", command);
    488490        mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
    489         paranoid_free(command);
     491        mr_free(command);
    490492        if (strlen(tmp)) {
    491493            log_msg(4, "  Partition ID: %s", tmp);
     
    496498                log_msg(4, "  Running: %s", command);
    497499                strcpy(VG, call_program_and_get_last_line_of_output(command));
    498                 paranoid_free(command);
     500                mr_free(command);
    499501                log_msg(4, "  Volume Group: %s", VG);
    500502                if (strlen(VG)) {
     
    504506                    log_msg(4, "  Running: %s", command);
    505507                    mr_asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command));
    506                     paranoid_free(command);
     508                    mr_free(command);
    507509                    log_msg(4, "  VG %s mount_list: %s", VG, mount_list);
    508510                    lastpos = 0;
     
    511513                        if ((DSFptr = find_mount_point_in_list(token)) == NULL) {
    512514                            log_msg (4, "Can't find mount point %s in mounted file systems list", token);
    513                             paranoid_free(tmp);
     515                            mr_free(tmp);
    514516                            mr_free(token);
    515517                            return (1);
     
    522524                     * any of the Logical Volumes on the Volume Group.
    523525                     *******/
    524                     paranoid_free(mount_list);
     526                    mr_free(mount_list);
    525527                    mr_asprintf(&command, "%s", "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");
    526528                    log_msg (5, "Running: %s", command);
    527529                    mr_asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command));
    528                     paranoid_free(command);
     530                    mr_free(command);
    529531                    log_msg(4, "  Software raid device list: %s", mount_list);
    530532                    lastpos = 0;
     
    532534                        mr_asprintf(&command, "mdadm --detail %s 2>/dev/null | grep -c %s", token, VG);
    533535                        log_msg (5, "Running: %s", command);
    534                         paranoid_free(tmp);
     536                        mr_free(tmp);
    535537                        mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
    536                         paranoid_free(command);
     538                        mr_free(command);
    537539                        log_msg(4, "Number of Software raid device: %s", tmp);
    538540                        if (atoi(tmp)) {
     
    540542                            if ((DSFptr = find_device_in_list(token)) == NULL) {
    541543                                log_msg (4, "Can't find device %s in mounted file systems list", token);
    542                                 paranoid_free(tmp);
     544                                mr_free(tmp);
    543545                                mr_free(token);
    544546                                return (1);
     
    548550                    }
    549551                    mr_free(token);
    550                     paranoid_free(mount_list);
     552                    mr_free(mount_list);
    551553                } else {
    552554                    log_msg (4, "Error finding Volume Group for partition %s", partitions[i]);
    553                     paranoid_free(tmp);
     555                    mr_free(tmp);
    554556                    return (1);
    555557                }
    556                 paranoid_free(tmp);
     558                mr_free(tmp);
    557559                continue;
    558560            }
     
    560562            log_msg (4, "Error finding partition type for the partition %s", partitions[i]);
    561563        }
    562         paranoid_free(tmp);
     564        mr_free(tmp);
    563565        /********
    564566         * It's not swap, mounted, or LVM. See if it's used in a software raid device.
     
    568570        log_msg(4, "  Running: %s", command);
    569571        mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
    570         paranoid_free(command);
     572        mr_free(command);
    571573        if (!strlen(tmp)) {
    572574            log_msg(4, "  Partition %s is not used in a non-LVM software raid device", partitions[i]);
    573             paranoid_free(tmp);
     575            mr_free(tmp);
    574576            continue;
    575577        }
     
    579581        log_msg (5, "  Running: %s", command);
    580582        mr_asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command));
    581         paranoid_free(command);
     583        mr_free(command);
    582584        log_msg(4, "  Software raid device list: %s", mount_list);
    583585        /* Loop through the software raid device list to see if we can find the partition */
     
    586588            mr_asprintf(&command, "mdadm --detail %s 2>/dev/null | grep -c %s", token, tmp);
    587589            log_msg(4, "  Running: %s", command);
    588             paranoid_free(tmp);
     590            mr_free(tmp);
    589591            mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
    590             paranoid_free(command);
     592            mr_free(command);
    591593            if (!atoi(tmp)) {
    592594                log_msg (4,"  Didn't find partition %s in software raid device %s", partitions[i], token);
     
    594596                if ((DSFptr = find_device_in_list(token)) == NULL) {
    595597                    log_msg (4, "Can't find device %s in mounted file systems list", token);
    596                     paranoid_free(tmp);
     598                    mr_free(tmp);
    597599                    mr_free(token);
    598600                    return (1);
     
    603605            mr_free(token);
    604606        }
    605         paranoid_free(tmp);
    606     }
    607     paranoid_free(partition_list);
    608     paranoid_free(mount_list);
     607        mr_free(tmp);
     608    }
     609    mr_free(partition_list);
     610    mr_free(mount_list);
    609611
    610612    /* Determine how much memory to allocate for included_dsf_list and excluded_dsf_list */
     
    753755
    754756    if (flag_set['I']) {
    755         if (bkpinfo->include_paths[0] == '-') {
     757        if (bkpinfo->include_paths && bkpinfo->include_paths[0] == '-') {
    756758            retval++;
    757759            log_to_screen("Please supply a sensible value with '-I'\n");
    758         }
    759         if (!strcmp(bkpinfo->include_paths, "/")) {
    760             log_msg(2, "'/' is pleonastic.");
    761760        }
    762761
     
    783782            }
    784783        }
    785         paranoid_free(tmp1);
     784        mr_free(tmp1);
    786785        while ((token = mr_strtok(flag_val['I'], token_chars, &lastpos)) != NULL) {
    787786            switch (get_dsf_mount_list(token, &mounted_on_dsf, &not_mounted_on_dsf)) {
     
    798797                log_to_screen("  %s\n", mounted_on_dsf);
    799798                mr_asprintf(&p, "/");
     799                mr_free(bkpinfo->include_paths);
    800800                bkpinfo->include_paths = p;
    801801                if (strlen(not_mounted_on_dsf)) {
     
    803803                    log_to_screen("Not archiving the following file systems:\n");
    804804                    log_to_screen("  %s\n", not_mounted_on_dsf);
    805                     mr_strcat(bkpinfo->exclude_paths, "%s ", not_mounted_on_dsf);
     805                    mr_strcat(bkpinfo->exclude_paths, " %s ", not_mounted_on_dsf);
    806806                }
    807807                break;
     
    837837        bkpinfo->make_filelist = FALSE;
    838838        mr_asprintf(&p, "%s", flag_val['J']);
     839        mr_free(bkpinfo->include_paths);
    839840        bkpinfo->include_paths = p;
    840841    }
     
    10891090
    10901091    if (flag_set['E']) {
    1091         if (bkpinfo->exclude_paths[0] == '-') {
     1092        if (bkpinfo->exclude_paths && bkpinfo->exclude_paths[0] == '-') {
    10921093            retval++;
    10931094            log_to_screen("Please supply a sensible value with '-E'\n");
    10941095        }
    1095         mr_strcat(bkpinfo->exclude_paths, " ");
    10961096        mr_asprintf(&tmp1, "%s", flag_val['E']);
    10971097
     
    11361136                    log_to_screen("  %s\n", mounted_on_dsf);
    11371137                    log_msg (5, "Adding to bkpinfo->exclude_paths due to -E option: %s", mounted_on_dsf);
    1138                     mr_strcat(bkpinfo->exclude_paths, "%s ", mounted_on_dsf);
    1139                     }
     1138                    mr_strcat(bkpinfo->exclude_paths, " %s ", mounted_on_dsf);
    11401139                }
    11411140                break;
     
    11461145            /* A device special file was not passed in. Process it as a path. */
    11471146            case -1:
    1148                 mr_strcat(bkpinfo->exclude_paths, "%s ", token);
     1147                mr_strcat(bkpinfo->exclude_paths, " %s ", token);
    11491148                break;
    11501149            }
     
    11641163    {
    11651164        mr_asprintf(&psz, "%s", list_of_NFS_mounts_only());
    1166         mr_strcat(bkpinfo->exclude_paths, "%s ", psz);
     1165        mr_strcat(bkpinfo->exclude_paths, " %s ", psz);
    11671166        mr_free(psz);
    11681167
     
    13001299
    13011300    if (flag_set['S']) {
    1302         sprintf(bkpinfo->scratchdir, "%s/mondo.scratch.%ld", flag_val['S'],
    1303                 random() % 32768);
     1301        mr_asprintf(&tmp1, "%s/mondo.scratch.%ld", flag_val['S'], random() % 32768);
     1302        mr_free(bkpinfo->scratchdir);
     1303        bkpinfo->scratchdir = tmp1;
    13041304    }
    13051305
     
    13761376        finish(0);
    13771377    }
     1378    mr_free(tmp);
    13781379
    13791380    if ((flag_set['L']) && (! bkpinfo->restore_data)) {
     
    14661467/* and finally... */
    14671468
    1468     paranoid_free(tmp);
    14691469    return (retval);
    14701470}
     
    15151515                mr_asprintf(&tmp, "Switch -%c previously defined as %s\n", opt, flag_val[opt]);
    15161516                log_to_screen(tmp);
    1517                 paranoid_free(tmp);
     1517                mr_free(tmp);
    15181518            } else {
    15191519                flag_set[opt] = TRUE;
     
    15311531                            mr_asprintf(&tmp, "-%c flag --- must be absolute path --- '%s' isn't absolute", opt, flag_val[opt]);
    15321532                            log_to_screen(tmp);
    1533                             paranoid_free(tmp);
     1533                            mr_free(tmp);
    15341534                            bad_switches = TRUE;
    15351535                        }
     
    15441544        mr_asprintf(&tmp, "Invalid arg -- %s\n", argv[i]);
    15451545        log_to_screen(tmp);
    1546         paranoid_free(tmp);
     1546        mr_free(tmp);
    15471547    }
    15481548    return (bad_switches);
     
    16071607    mr_strcat(tmp, " signal received from OS");
    16081608    log_to_screen(tmp);
    1609     paranoid_free(tmp);
     1609    mr_free(tmp);
    16101610
    16111611    log_to_screen(tmp2);
    1612     paranoid_free(tmp2);
     1612    mr_free(tmp2);
    16131613    if (sig == SIGABRT) {
    16141614        sleep(10);
  • branches/2.2.10/mondo/src/common/libmondo-devices.c

    r2319 r2320  
    19791979            finish(1);
    19801980        }
    1981         strcpy(bkpinfo->scratchdir, p);
    1982         mr_free(p);
     1981        mr_free(bkpinfo->scratchdir);
     1982        bkpinfo->scratchdir = p;
    19831983
    19841984// Interactive mode:
     
    21562156    if (tmp[0] != '/') {
    21572157        mr_asprintf(&sz, "%s", tmp);
    2158         paranoid_free(tmp);
     2158        mr_free(tmp);
    21592159        mr_asprintf(&tmp, "/%s", sz);
    21602160        mr_free(sz);
     
    21662166    log_it("bkpinfo->tmpdir is being set to %s", bkpinfo->tmpdir);
    21672167
    2168     sprintf(bkpinfo->scratchdir, "%s/mondo.scratch.%d", tmp,
    2169             (int) (random() % 32768));
     2168    mr_asprintf(&sz, "%s/mondo.scratch.%d", tmp, (int) (random() % 32768));
     2169    mr_free(bkpinfo->scratchdir);
     2170    bkpinfo->scratchdir = sz;
    21702171    log_it("bkpinfo->scratchdir is being set to %s", bkpinfo->scratchdir);
    21712172
    21722173    mr_asprintf(&command, "rm -Rf %s/tmp.mondo.* %s/mondo.scratch.*", tmp, tmp);
    2173     paranoid_free(tmp);
     2174    mr_free(tmp);
    21742175
    21752176    paranoid_system(command);
  • branches/2.2.10/mondo/src/common/libmondo-filelist.c

    r2296 r2320  
    12961296
    12971297    assert(bkpinfo != NULL);
    1298     log_it("tmpdir=%s; scratchdir=%s", bkpinfo->tmpdir,
    1299            bkpinfo->scratchdir);
     1298    log_it("tmpdir=%s; scratchdir=%s", bkpinfo->tmpdir, bkpinfo->scratchdir);
    13001299    if (bkpinfo->make_filelist) {
    13011300        mvaddstr_and_log_it(g_currentY, 0,
     
    13081307    if (bkpinfo->make_filelist) {
    13091308        res =
    1310             mondo_makefilelist(MONDO_LOGFILE, bkpinfo->tmpdir,
    1311                                bkpinfo->scratchdir, bkpinfo->include_paths,
    1312                                bkpinfo->exclude_paths,
    1313                                bkpinfo->differential, NULL);
     1309            mondo_makefilelist(MONDO_LOGFILE, bkpinfo->tmpdir, bkpinfo->scratchdir, bkpinfo->include_paths, bkpinfo->exclude_paths, bkpinfo->differential, NULL);
    13141310    } else {
    13151311        res =
    1316             mondo_makefilelist(MONDO_LOGFILE, bkpinfo->tmpdir,
    1317                                bkpinfo->scratchdir, NULL,
    1318                                bkpinfo->exclude_paths,
    1319                                bkpinfo->differential,
    1320                                bkpinfo->include_paths);
     1312            mondo_makefilelist(MONDO_LOGFILE, bkpinfo->tmpdir, bkpinfo->scratchdir, NULL, bkpinfo->exclude_paths, bkpinfo->differential, bkpinfo->include_paths);
    13211313    }
    13221314
     
    13821374        malloc_string(find_skeleton_marker);
    13831375        mr_asprintf(&find_excludes, " ");
    1384         while((token = mr_strtok (sth, delims, &lastpos))) {
    1385           mr_asprintf(&strtmp,"%s", find_excludes);
    1386           paranoid_free(find_excludes);
    1387           mr_asprintf(&find_excludes,"%s -path %s -prune -o", strtmp, token);
    1388           paranoid_free(strtmp);
    1389           mr_free(token);
     1376        if (sth != NULL) {
     1377            while((token = mr_strtok(sth, delims, &lastpos))) {
     1378                mr_strcat(find_excludes," -path %s -prune -o", token);
     1379            }
    13901380        }
    13911381#if linux
     
    13961386        mr_asprintf(&strtmp, "find '%s' -fstype mvfs -prune -o -path /proc -prune -o %s -type d -print > %s 2> /dev/null", dir, find_excludes, g_skeleton_filelist);
    13971387#endif
    1398         paranoid_free(find_excludes);
     1388        mr_free(find_excludes);
     1389
    13991390        log_msg(5, "find command = %s", strtmp);
    14001391        (void)system(strtmp);
    1401         paranoid_free(strtmp);
     1392        mr_free(strtmp);
     1393
    14021394        mr_asprintf(&tmp, "wc -l %s | awk '{print $1;}'", g_skeleton_filelist);
    1403         g_skeleton_entries =
    1404             1 + atol(call_program_and_get_last_line_of_output(tmp));
    1405         paranoid_free(tmp);
     1395        g_skeleton_entries = 1 + atol(call_program_and_get_last_line_of_output(tmp));
     1396        mr_free(tmp);
     1397
    14061398        sprintf(name_of_evalcall_form, "Making catalog of %s", dir);
    14071399        open_evalcall_form(name_of_evalcall_form);
     
    14151407                "grep -Fv '%s' %s > %s.new 2> /dev/null", dir,
    14161408                g_skeleton_filelist, g_skeleton_filelist);
    1417 //    log_msg(0, "fsm = %s", find_skeleton_marker);
    14181409        if (!system(find_skeleton_marker)) {
    14191410            percentage = (int) (skeleton_lino * 100 / g_skeleton_entries);
    14201411            skeleton_lino++;
    1421 //        log_msg(5, "Found %s", dir);
    1422 //        log_msg(2, "Incrementing skeleton_lino; now %ld/%ld (%d%%)", skeleton_lino, g_skeleton_entries, percentage);
    14231412            sprintf(find_skeleton_marker, "mv -f %s.new %s",
    14241413                    g_skeleton_filelist, g_skeleton_filelist);
    1425 //        log_msg(6, "fsm = %s", find_skeleton_marker);
    14261414            run_program_and_log_output(find_skeleton_marker, 8);
    14271415            time(&this_time);
     
    15701558    char *p, *q;
    15711559    char *sz_datefile;
    1572     char *sz_filelist, *exclude_paths, *tmp;
     1560    char *sz_filelist;
     1561    char *exclude_paths = NULL;
     1562    char *tmp;
    15731563    int i;
    15741564    FILE *fout;
     
    15811571    malloc_string(tmp);
    15821572    malloc_string(g_skeleton_filelist);
    1583     if (!(exclude_paths = malloc(8*MAX_STR_LEN))) {
    1584         fatal_error("Cannot malloc exclude_paths");
    1585     }
    15861573    mr_asprintf(&sz_datefile,MONDO_CACHE"/difflevel.%d" , 0);
    15871574    if (!include_paths && !userdef_filelist) {
     
    16371624        mr_free(command);
    16381625    } else {
    1639         log_msg(2, "include_paths = '%s'", include_paths);
     1626        if (include_paths) {
     1627            log_msg(2, "include_paths = '%s'", include_paths);
     1628        }
    16401629        log_msg(1, "Calculating filelist");
    16411630        mr_asprintf(&tmp2, "%s", call_program_and_get_last_line_of_output("mount | grep -Ew 'ntfs|ntfs-3g|fat|vfat|dos' | awk '{print $3}'"));
     
    16491638            log_msg(2, "Found windows files: %s",tmp2);
    16501639        }
    1651         paranoid_free(tmp1);
    1652 
    1653         snprintf(exclude_paths, (size_t)8*MAX_STR_LEN," %s %s %s %s %s . .. \
    1654 " MNT_CDROM " " MNT_FLOPPY " /media /tmp \
    1655 /proc /sys " MINDI_CACHE, MONDO_CACHE, excp, tmp2, (tmpdir[0] == '/' && tmpdir[1] == '/') ? (tmpdir + 1) : tmpdir, (scratchdir[0] == '/' && scratchdir[1] == '/') ? (scratchdir + 1) : scratchdir);
    1656         paranoid_free(tmp2);
     1640        mr_free(tmp1);
     1641
     1642        mr_asprintf(&exclude_paths, " %s %s %s %s %s . ..  " MNT_CDROM " " MNT_FLOPPY " /media /tmp  /proc /sys " MINDI_CACHE, MONDO_CACHE, (excp == NULL) ? "" : excp, tmp2, (tmpdir[0] == '/' && tmpdir[1] == '/') ? (tmpdir + 1) : tmpdir, (scratchdir[0] == '/' && scratchdir[1] == '/') ? (scratchdir + 1) : scratchdir);
     1643        mr_free(tmp2);
    16571644
    16581645        log_msg(2, "Excluding paths = '%s'", exclude_paths);
    1659         log_msg(2,
    1660                 "Generating skeleton filelist so that we can track our progress");
     1646        log_msg(2, "Generating skeleton filelist so that we can track our progress");
    16611647        sprintf(g_skeleton_filelist, "%s/tmpfs/skeleton.txt", tmpdir);
    16621648        make_hole_for_file(g_skeleton_filelist);
     
    16671653        }
    16681654        i = 0;
    1669         if (strlen(include_paths) == 0) {
     1655        if ((!include_paths) || (strlen(include_paths) == 0)) {
    16701656            log_msg(1, "Including only '/' in %s", sz_filelist);
    16711657            open_and_list_dir("/", exclude_paths, fout,
     
    16851671            }
    16861672        }
     1673        mr_free(exclude_paths);
    16871674        paranoid_fclose(fout);
    16881675    }
     
    17021689    paranoid_free(sz_filelist);
    17031690    log_msg(2, "Freeing variables");
    1704     paranoid_free(exclude_paths);
    17051691    paranoid_free(tmp);
    17061692    paranoid_free(g_skeleton_filelist);
  • branches/2.2.10/mondo/src/common/libmondo-tools.c

    r2319 r2320  
    448448        mr_free(tmp);
    449449    }
    450     make_hole_for_dir(bkpinfo->scratchdir);
     450    if (bkpinfo->scratchdir) {
     451        make_hole_for_dir(bkpinfo->scratchdir);
     452        chmod(bkpinfo->scratchdir, 0700);
     453    } else {
     454        fatal_error("Scratchdir set to NULL !");
     455    }
    451456    if (bkpinfo->backup_media_type == iso)
    452457        make_hole_for_dir(bkpinfo->isodir);
     
    680685        fprintf(stderr, "Type 'man mondoarchive' for help.\n");
    681686    }
    682     if (strlen(bkpinfo->tmpdir) < 2 || strlen(bkpinfo->scratchdir) < 2) {
    683         log_it("tmpdir or scratchdir are blank/missing");
     687    if (strlen(bkpinfo->tmpdir) < 2) {
     688        log_it("tmpdir is blank/missing");
    684689        retval++;
    685690    }
     
    688693        bkpinfo->include_paths = p;
    689694    }
    690     chmod(bkpinfo->scratchdir, 0700);
    691695    g_backup_media_type = bkpinfo->backup_media_type;
    692696    paranoid_free(mtpt);
  • branches/2.2.10/mondo/src/common/mondostructures.h

    r2226 r2320  
    480480   * As such, it needs to be at least as large as the largest CD/DVD/ISO.
    481481   */
    482     char scratchdir[MAX_STR_LEN / 4];
     482    char *scratchdir;
    483483
    484484  /**
     
    515515   * If you do nothing, "/" will be used.
    516516   */
    517     char include_paths[MAX_STR_LEN*4];
     517    char *include_paths;
    518518
    519519  /**
     
    522522   * the scratchdir, and the tempdir are automatically excluded.
    523523   */
    524     char exclude_paths[MAX_STR_LEN*4];
     524    char *exclude_paths;
    525525
    526526  /**
  • branches/2.2.10/mondo/src/common/newt-specific.c

    r2319 r2320  
    294294     fatal_error(char *error_string) {
    295295        /*@ buffers ***************************************************** */
    296         char fatalstr[MAX_NEWT_COMMENT_LEN] =
    297             "-------FATAL ERROR---------";
    298         char *tmp;
    299         char *command;
     296        char *command = NULL;
    300297        static bool already_exiting = FALSE;
    301298
    302299        /*@ end vars **************************************************** */
    303300
    304         malloc_string(command);
    305         tmp = malloc(MAX_NEWT_COMMENT_LEN);
    306301        set_signals(FALSE);     // link to external func
    307302        g_exiting = TRUE;
     
    311306            log_msg(2, "mastermind %d is exiting", (int) getpid());
    312307            kill(g_main_pid, SIGTERM);
    313             paranoid_free(tmp);
    314308            finish(1);
    315309        }
     
    319313                log_msg(2, "non-m/m %d is exiting", (int) getpid());
    320314                kill(g_main_pid, SIGTERM);
    321                 paranoid_free(tmp);
    322315                finish(1);
    323316            }
     
    327320        if (already_exiting) {
    328321            log_msg(3, "...I'm already exiting. Give me time, Julian!");
    329             paranoid_free(tmp);
    330322            finish(1);
    331323        }
     
    338330        kill_anything_like_this("ntfsclone");
    339331        sync();
    340         /*
    341         sprintf(tmp, "umount %s", g_tmpfs_mountpt);
    342         for (i = 0; i < 10 && run_program_and_log_output(tmp, 5); i++) {
    343             log_msg(2, "Waiting for child processes to terminate");
    344             sleep(1);
    345             run_program_and_log_output(tmp, 5);
    346         }
    347         */
    348332
    349333        chdir("/");
    350334        if (g_selfmounted_isodir) {
    351             sprintf(command, "umount %s", g_selfmounted_isodir);
     335            mr_asprintf(&command, "umount %s", g_selfmounted_isodir);
    352336            run_program_and_log_output(command, 5);
    353             sprintf(command, "rmdir %s", g_selfmounted_isodir);
     337            mr_free(command);
     338            mr_asprintf(&command, "rmdir %s", g_selfmounted_isodir);
    354339            run_program_and_log_output(command, 5);
     340            mr_free(command);
    355341        }
    356342
    357343        if (!g_text_mode) {
    358             log_msg(0, fatalstr);
     344            log_msg(0, "-------FATAL ERROR---------");
    359345            log_msg(0, error_string);
    360346            newtFinished();
     
    362348
    363349        printf("---FATALERROR--- %s\n", error_string);
    364         printf
    365                 ("If you require technical support, please contact the mailing list.\n");
     350        printf("If you require technical support, please contact the mailing list.\n");
    366351        printf("See http://www.mondorescue.org for details.\n");
    367         printf
    368                 ("The list's members can help you, if you attach that file to your e-mail.\n");
     352        printf("The list's members can help you, if you attach that file to your e-mail.\n");
    369353        printf("Log file: %s\n", MONDO_LOGFILE);
    370354        printf("Mondo has aborted.\n");
     
    372356            log_msg(3, "FYI - g_main_pid is blank");
    373357        }
    374         paranoid_free(tmp);
    375         paranoid_free(command);
    376358        finish(254);
    377359    }
     
    405387            mr_asprintf(&command, "umount %s", g_selfmounted_isodir);
    406388            run_program_and_log_output(command, 1);
    407             paranoid_free(command);
     389            mr_free(command);
     390
    408391            mr_asprintf(&command, "rmdir %s", g_selfmounted_isodir);
    409392            run_program_and_log_output(command, 1);
    410             paranoid_free(command);
     393            mr_free(command);
    411394        }
    412395        if (!g_text_mode) {
     
    443426        mr_free(bkpinfo->exclude_paths);
    444427        mr_free(bkpinfo->include_paths);
     428        mr_free(bkpinfo->scratchdir);
    445429
    446430        /* Then free the structure */
    447         paranoid_free(bkpinfo);
     431        mr_free(bkpinfo);
    448432        free_libmondo_global_strings();
    449433        free_newt_stuff();
     
    947931        }
    948932
    949         err_log_lines =
    950             (char **) malloc(sizeof(char *) * g_noof_log_lines);
    951         if (!err_log_lines) {
    952             fatal_error("Out of memory");
    953         }
     933        err_log_lines = (char **) mr_malloc(sizeof(char *) * g_noof_log_lines);
    954934
    955935        for (i = 0; i < g_noof_log_lines; i++) {
    956             err_log_lines[i] = (char *) malloc(MAX_NEWT_COMMENT_LEN);
    957             if (!err_log_lines[i]) {
    958                 fatal_error("Out of memory");
    959             }
     936            err_log_lines[i] = (char *) mr_malloc(MAX_NEWT_COMMENT_LEN);
    960937        }
    961938
     
    10551032        }
    10561033        if (!g_text_mode) {
    1057 //      log_it("refreshing");
    10581034            newtRefresh();
    10591035        }
     
    10801056    void
    10811057     update_progress_form(char *blurb3) {
    1082         /*  log_it("update_progress_form --- called"); */
    10831058        if (g_current_progress == -999) {
    1084             /* log_it("You're trying to update progress form when it ain't open. Aww, that's OK. I'll let it go. It's a bit naughty but it's a nonfatal error. No prob, Bob."); */
    10851059            return;
    10861060        }
     
    11941168        }
    11951169    }
    1196 
    1197 
    1198 
    1199 
    1200 
    1201 
    1202 
    1203 
    1204 
    1205 
    1206 
    1207 
    12081170
    12091171
     
    12801242        }
    12811243        newtPushHelpLine(title_sz);
    1282         //  newtOpenWindow (23, 3, 34, 17, minimsg_sz);
    12831244        newtCenteredWindow(34, 17, minimsg_sz);
    12841245        b1 = newtButton(1, 1, "CD-R disks ");
  • branches/2.2.10/mondo/src/include/mr_mem.h

    r2316 r2320  
    2020#define mr_allocstr(x,y) mr_allocstr_int(x,y,__LINE__,__FILE__)
    2121#define mr_asprintf(x,y,args...) mr_asprintf_int(x,__LINE__,__FILE__,y,## args)
    22 #define mr_getline(x,z) mr_getline_int(x,z,__LINE__,__FILE__)
     22#define mr_getline(x,y) mr_getline_int(x,y,__LINE__,__FILE__)
    2323#define mr_malloc(x) mr_malloc_int((size_t)x,__LINE__,__FILE__)
    2424#define mr_setenv(x,y) mr_setenv_int(x,y,__LINE__,__FILE__)
  • branches/2.2.10/mondo/src/lib/mr_err.c

    r1422 r2320  
    1616#include <stdio.h>
    1717#include <stdlib.h>
     18#include "mr_msg.h"
    1819
    1920/* Pointer to the right cleanup function provided by each main */
    20 extern void (*mr_cleanup)(void);
     21extern void (*mr_cleanup)(int);
    2122
    2223/*
     
    2627
    2728    if (mr_cleanup != NULL) {
    28         mr_cleanup();
     29        mr_cleanup(errorcode);
    2930    }
    3031    if (message != NULL) {
    3132        fprintf(stderr,"%s\n",message);
    3233    }
     34    mr_msg_close();
    3335    exit(errorcode);
    3436}
  • branches/2.2.10/mondo/src/lib/mr_mem.c

    r2316 r2320  
    5757   
    5858    ssize_t ret;
    59     ssize_t *n;
     59    ssize_t n = 0;
    6060
    61     ret = getline(lineptr,n,fd);
     61    ret = getline(lineptr,&n,fd);
    6262    if ((ret == -1) && (! feof(fd))) {
    6363        mr_msg_int(1,line,file,"Unable to alloc memory in mr_getline\nExiting...");
  • branches/2.2.10/mondo/src/mondoarchive/mondoarchive.c

    r2291 r2320  
    5454struct s_bkpinfo *bkpinfo;
    5555
    56 /* No cleanup for the moment */
    57 void (*mr_cleanup)(void) = NULL;
     56/*  Make cleanup the finish function */
     57void (*mr_cleanup)(int) = finish;
    5858
    5959/* To be coded */
  • branches/2.2.10/mondo/src/mondorestore/mondorestore.c

    r2316 r2320  
    2121extern void twenty_seconds_til_yikes(void);
    2222
    23 /* We don't have a cleanup function yet */
    24 void (*mr_cleanup)(void) = NULL;
     23/* Let mr_cleanup pojnt to finish for the moment */
     24void (*mr_cleanup)(int) = finish;
    2525
    2626/* Reference to global bkpinfo */
  • branches/2.2.10/mondo/test/test-mountlist.c

    r2235 r2320  
    4444extern int copy_from_src_to_dest(FILE * f_orig, FILE * f_archived, char direction);
    4545/* We don't have a cleanup function yet */
    46 void (*mr_cleanup)(void) = NULL;
     46void (*mr_cleanup)(int) = NULL;
    4747
    4848void main() {
  • branches/2.2.10/mondo/test/test-truncname.c

    r2236 r2320  
    4343extern char *truncate_to_drive_name(char *);
    4444/* We don't have a cleanup function yet */
    45 void (*mr_cleanup)(void) = NULL;
     45void (*mr_cleanup)(int) = NULL;
    4646void free_MR_global_filenames() {
    4747}
Note: See TracChangeset for help on using the changeset viewer.