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


Ignore:
Timestamp:
Nov 18, 2016, 5:31:42 PM (9 years ago)
Author:
Bruno Cornec
Message:

Add function mr_getcwd and use it to allow use o dynamically allocated memory
instead of getcwd

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

Legend:

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

    r3610 r3613  
    1515#include "mr_str.h"
    1616#include "mr_sys.h"
     17#include "mr_file.h"
    1718#include "mondostructures.h"
    1819#include "libmondo-string-EXT.h"
     
    14501451    char *result_sz = NULL;
    14511452    char *message_to_screen = NULL;
    1452     char *old_pwd;
     1453    char *old_pwd = NULL;
    14531454    char *mds = NULL;
    14541455
    1455     malloc_string(old_pwd);
    14561456    assert(bkpinfo != NULL);
    14571457
    14581458    log_msg(2, "make_usb_fs --- scratchdir=%s", bkpinfo->scratchdir);
    1459     tmp1 = getcwd(old_pwd, MAX_STR_LEN - 1);
     1459    old_pwd = mr_getcwd();
    14601460    mr_asprintf(tmp, "chmod 700 %s", bkpinfo->scratchdir);
    14611461    run_program_and_log_output(tmp, FALSE);
     
    15331533        // FIXME
    15341534    }
     1535    mr_free(old_pwd);
    15351536    if (retval) {
    15361537        log_msg(1, "WARNING - make_usb_fs returned an error");
    15371538    }
    1538     paranoid_free(old_pwd);
    1539     return (retval);
     1539    return(retval);
    15401540}
    15411541
     
    15581558 * @return The number of errors encountered (0 for success)
    15591559 */
    1560 int make_iso_fs(char *destfile)
    1561 {
     1560int make_iso_fs(char *destfile) {
    15621561    /*@ int ********************************************** */
    15631562    int retval = 0;
     
    15661565    /*@ buffers ****************************************** */
    15671566    char *tmp = NULL;
    1568     char *tmp2 = NULL;
    1569     char *old_pwd;
     1567    char *old_pwd = NULL;
    15701568    char *result_sz = NULL;
    15711569    char *message_to_screen = NULL;
    15721570    char *sz_blank_disk = NULL;
    1573     char *fnam = NULL;
    15741571    char *isofs_cmd = NULL;
    15751572    char *full_isofs_cmd = NULL;
     
    15781575    bool cd_is_mountable;
    15791576
    1580     malloc_string(old_pwd);
    1581     malloc_string(fnam);
    15821577    assert(bkpinfo != NULL);
    15831578    assert_string_is_neither_NULL_nor_zerolength(destfile);
     
    15881583
    15891584    log_msg(2, "make_iso_fs --- scratchdir=%s --- destfile=%s", bkpinfo->scratchdir, destfile);
    1590     tmp2 = getcwd(old_pwd, MAX_STR_LEN - 1);
    1591     if (! tmp2) {
    1592         //FIXME
    1593     }
     1585    old_pwd = mr_getcwd();
    15941586    mr_asprintf(tmp, "chmod 700 %s", bkpinfo->scratchdir);
    15951587    run_program_and_log_output(tmp, FALSE);
     
    18251817        // FIXME
    18261818    }
     1819    mr_free(old_pwd);
    18271820    if (retval) {
    18281821        log_msg(1, "WARNING - make_iso_fs returned an error");
    18291822    }
    1830     paranoid_free(old_pwd);
    1831     paranoid_free(fnam);
    1832     paranoid_free(tmp);
    18331823    return (retval);
    18341824}
  • branches/3.2/mondo/src/common/libmondo-files.c

    r3611 r3613  
    1111#include "my-stuff.h"
    1212#include "mr_mem.h"
     13#include "mr_file.h"
    1314#include "mondostructures.h"
    1415#include "libmondo-files.h"
     
    10131014    char *command = NULL;
    10141015    char *tmp = NULL;
    1015     char old_pwd[MAX_STR_LEN];
     1016    char *old_pwd = NULL;
    10161017    int res = 0;
    10171018
     
    10351036    if (does_file_exist(tmp)) {
    10361037        log_it("Untarring payload %s to scratchdir %s", tmp, bkpinfo->scratchdir);
    1037         if (getcwd(old_pwd, MAX_STR_LEN - 1)) {
    1038             // FIXME
    1039         }
     1038        old_pwd = mr_getcwd();
    10401039        if (chdir(bkpinfo->scratchdir)) {
    10411040            // FIXME
     
    10521051            // FIXME
    10531052        }
     1053        mr_free(old_pwd);
    10541054    }
    10551055    mr_free(tmp);
  • branches/3.2/mondo/src/common/libmondo-stream.c

    r3611 r3613  
    1414#include "my-stuff.h"
    1515#include "mr_mem.h"
     16#include "mr_file.h"
    1617#include "mondostructures.h"
    1718#include "libmondo-devices.h"
     
    764765    char *datablock;
    765766    char *tmp = NULL;
    766     char old_cwd[MAX_STR_LEN];
     767    char *old_pwd = NULL;
    767768    char *outfname = NULL;
    768769    /*@ int ******************************************************* */
     
    865866    close_evalcall_form();
    866867    log_it("Saved all.tar.gz to '%s'", outfname);
    867     if (getcwd(old_cwd, MAX_STR_LEN)) {
    868         // FIXME
    869     }
     868    old_pwd = mr_getcwd();
    870869    if (chdir(bkpinfo->tmpdir)) {
    871870        // FIXME
     
    876875
    877876    paranoid_system("cp -f tmp/mondorestore.cfg . 2> /dev/null");
    878     if (chdir(old_cwd)) {
     877    if (chdir(old_pwd)) {
    879878        // FIXME
    880879    }
     880    mr_free(old_pwd);
    881881    unlink(outfname);
    882882    mr_free(outfname);
  • branches/3.2/mondo/src/common/libmondo-tools.c

    r3610 r3613  
    107107    bool is_valid = TRUE;
    108108
    109     log_it("ASSERTION FAILED: `%s' at %s:%d in %s", exp, file, line,
    110            function);
     109    log_it("ASSERTION FAILED: `%s' at %s:%d in %s", exp, file, line, function);
    111110    if (ignoring_assertions) {
    112111        log_it("Well, the user doesn't care...");
     
    143142             */
    144143        case '\n':
    145             printf
    146                 ("(I)gnore, ignore (A)ll, (D)ebug, a(B)ort, or (E)xit? ");
     144            printf("(I)gnore, ignore (A)ll, (D)ebug, a(B)ort, or (E)xit? ");
    147145            break;
    148146        default:
     
    938936    if (system("which " MKE2FS_OR_NEWFS " > /dev/null 2> /dev/null")) {
    939937        retval++;
    940         log_to_screen
    941             ("Unable to find " MKE2FS_OR_NEWFS " in system path.");
    942         fatal_error
    943             ("Please use \"su -\", not \"su\" to become root. OK? ...and please don't e-mail the mailing list or me about this. Just read the message. :)");
     938        log_to_screen("Unable to find " MKE2FS_OR_NEWFS " in system path.");
     939        fatal_error("Please use \"su -\", not \"su\" to become root. OK?\n...and please don't e-mail the mailing list about this. Just read the message. :)");
    944940    }
    945941#ifndef __FreeBSD__
    946     if (run_program_and_log_output
    947         ("grep ramdisk /proc/devices", FALSE)) {
     942    if (run_program_and_log_output("grep ramdisk /proc/devices", FALSE)) {
    948943        /* Some SuSE have ramdisk as modules, so insert it first, then test again */
    949944        run_program_and_log_output("modprobe brd 2> /dev/null > /dev/null",FALSE);
  • branches/3.2/mondo/src/common/libmondo-verify.c

    r3380 r3613  
    418418    /*@ long *********************************************************** */
    419419    long diffs = 0;
    420     /*  getcwd(old_pwd,MAX_STR_LEN-1); */
    421420
    422421    assert(bkpinfo != NULL);
Note: See TracChangeset for help on using the changeset viewer.