Ignore:
Timestamp:
Sep 10, 2009, 2:55:51 AM (15 years ago)
Author:
Bruno Cornec
Message:

call_program_and_get_last_line_of_output is now allocating memory and returning that string

File:
1 edited

Legend:

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

    r2382 r2383  
    539539    if (bkpinfo->exclude_paths) {
    540540        mr_asprintf(tmp, "echo '%s' | tr -s ' ' '\n' | grep -E '^/dev/.*$' | tr -s '\n' ' ' | awk '{print $0\"\\n\";}'", bkpinfo->exclude_paths);
    541         mr_asprintf(devs_to_exclude, "%s", call_program_and_get_last_line_of_output(tmp));
     541        devs_to_exclude = call_program_and_get_last_line_of_output(tmp);
    542542        mr_free(tmp);
    543543
     
    626626
    627627#ifdef __FreeBSD__
    628         mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'"));
     628        bootdev = call_program_and_get_last_line_of_output("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'");
    629629        if (!bootdev[0]) {
    630630            mr_free(bootdev);
    631             mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'"));
     631            bootdev = call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/\\([0-9]\\).*/\\1/'");
    632632        }
    633633#else
    634634        /* Linux */
    635635#ifdef __IA64__
    636         mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' /boot/efi ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"));
     636        bootdev = call_program_and_get_last_line_of_output("mount | grep ' /boot/efi ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'");
    637637#else
    638         mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"));
     638        bootdev = call_program_and_get_last_line_of_output("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'");
    639639#endif
    640640        if (strstr(bootdev, "/dev/cciss/")) {
    641641            mr_free(bootdev);
    642642#ifdef __IA64__
    643             mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' /boot/efi ' | head -1 | cut -d' ' -f1 | cut -dp -f1"));
     643            bootdev = call_program_and_get_last_line_of_output("mount | grep ' /boot/efi ' | head -1 | cut -d' ' -f1 | cut -dp -f1");
    644644#else
    645             mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | cut -dp -f1"));
     645            bootdev = call_program_and_get_last_line_of_output("mount | grep ' /boot ' | head -1 | cut -d' ' -f1 | cut -dp -f1");
    646646#endif
    647647        }
    648648        if (!bootdev[0]) {
    649649            mr_free(bootdev);
    650             mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'"));
     650            bootdev = call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | sed 's/[0-9].*//'");
    651651            if (strstr(bootdev, "/dev/cciss/")) {
    652652                mr_free(bootdev);
    653                 mr_asprintf(bootdev, "%s", call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | cut -dp -f1"));
     653                bootdev = call_program_and_get_last_line_of_output("mount | grep ' / ' | head -1 | cut -d' ' -f1 | cut -dp -f1");
    654654            }
    655655        }
     
    928928        log_to_screen("Mindi failed to create your boot+data disks.");
    929929        mr_asprintf(command, "grep 'Fatal error' /var/log/mindi.log");
    930         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     930        tmp = call_program_and_get_last_line_of_output(command);
    931931        mr_free(command);
    932932
     
    11851185    mr_asprintf(data_disks_file, "%s/all.tar.gz", bkpinfo->tmpdir);
    11861186
    1187     mr_asprintf(g_serial_string, "%s", call_program_and_get_last_line_of_output("dd  if=/dev/urandom bs=16 count=1 2> /dev/null |  hexdump | tr -s ' ' '0' | head -n1"));
     1187    g_serial_string = call_program_and_get_last_line_of_output("dd  if=/dev/urandom bs=16 count=1 2> /dev/null |  hexdump | tr -s ' ' '0' | head -n1");
    11881188    mr_strip_spaces(g_serial_string);
    11891189    mr_strcat(g_serial_string, "...word.");
     
    18921892    mr_asprintf(command, "dd if=%s bs=512 count=1 2> /dev/null | strings | head -n1", bigfile_fname);
    18931893    log_msg(1, "command = '%s'", command);
    1894     mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     1894    tmp = call_program_and_get_last_line_of_output(command);
    18951895    mr_free(command);
    18961896
     
    26602660            mr_asprintf(tmp, "cat %s 2> /dev/null", szserfname);
    26612661            mr_free(our_serial_str);
    2662             mr_asprintf(our_serial_str, "%s", call_program_and_get_last_line_of_output(tmp));
     2662            our_serial_str = call_program_and_get_last_line_of_output(tmp);
    26632663            mr_free(tmp);
    26642664            // FIXME - should be able to use last_line_of_file(), surely?
     
    28592859        mr_asprintf(command, "ntfsresize --force --info %s|grep '^You might resize at '|cut -d' ' -f5", biggie_filename);
    28602860        log_it("command = %s", command);
    2861         mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
     2861        tmp = call_program_and_get_last_line_of_output(command);
    28622862        mr_free(command);
    28632863        log_it("res of it = %s", tmp);
Note: See TracChangeset for help on using the changeset viewer.