Changeset 1185 in MondoRescue for trunk/mondo/src/common/libmondo-tools.c


Ignore:
Timestamp:
Feb 19, 2007, 1:51:26 AM (17 years ago)
Author:
Bruno Cornec
Message:

Merges in trunk modifications coming from stable (common)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/mondo/src/common/libmondo-tools.c

    r1106 r1185  
    1010#include "my-stuff.h"
    1111#include "mr_mem.h"
     12#include "mr_msg.h"
    1213#include "mr_file.h"
    1314
     
    2425#include <arpa/inet.h>
    2526#endif
    26 #include "mr_mem.h"
    2727
    2828/*@unused@*/
     
    199199
    200200
    201 char *get_architecture()
     201char *get_architecture(void)
    202202{
    203203#ifdef __IA32__
     
    205205#endif
    206206#ifdef __X86_64__
    207     return ("x86-64");
     207    return ("x86_64");
    208208#endif
    209209#ifdef __IA64__
     
    215215
    216216
    217 double get_kernel_version()
     217double get_kernel_version(void)
    218218{
    219219    char *p, *tmp;
     
    242242
    243243
    244 
    245 
    246 
    247244/**
    248245 * Get the current time.
    249246 * @return number of seconds since the epoch.
    250247 */
    251 long get_time()
     248long get_time(void)
    252249{
    253250    return (long) time((void *) 0);
    254251}
    255 
    256 
    257 
    258 
    259 
    260252
    261253
     
    298290}
    299291#endif
    300 
    301 
    302292
    303293
     
    354344    char *mondo_mkisofs_sz = NULL;
    355345    char *command = NULL;
    356     char *hostname = NULL, *ip_address = NULL;
     346    char *hostname = NULL;
     347    char *ip_address = NULL;
    357348    int retval = 0;
    358349    long avm = 0;
     
    363354    char *call_before_iso_user = NULL;
    364355    int rdsiz_MB;
     356    char *iso_dev = NULL;
     357    char *iso_mnt = NULL;
     358    char *iso_tmp = NULL;
    365359    char *iso_path = NULL;
    366360    FILE *fd1 = NULL;
     
    400394    avm += atol(tmp);
    401395    mr_free(tmp);
    402     tmp = call_program_and_get_last_line_of_output
     396    tmp1 = call_program_and_get_last_line_of_output
    403397             ("swapinfo | grep -v Device | tr -s ' ' | cut -d' ' -f4 | tr '\n' '+' | sed 's/+$//' | bc");
    404398    avm += atol(tmp);
     
    412406    mr_free(tmp);
    413407    mr_asprintf(&command, "mount /dev/shm -t tmpfs %s -o size=%d%c",
    414              g_tmpfs_mountpt, rdsiz_MB, 'm');
     408            g_tmpfs_mountpt, rdsiz_MB, 'm');
    415409    run_program_and_log_output("cat /proc/cpuinfo", 5);
    416410    /* BERLIOS: rpm is not necessarily there ! */
     
    495489                popup_and_OK("Fatal Error: Can't write DVDs as sudo because growisofs doesn't support this - see the growisofs manpage for details.");
    496490                fatal_error("Can't write DVDs as sudo because growisofs doesn't support this - see the growisofs manpage for details.");
    497             }       
     491            }
    498492            mr_free(tmp);
    499493            mr_free(command);
     
    507501        || bkpinfo->backup_media_type == cdr) {
    508502        if (!bkpinfo->manual_cd_tray) {
    509             mr_asprintf(&extra_cdrom_params, "-waiti ");
     503            mr_strcat(extra_cdrom_params, "-waiti ");
    510504        }
    511505        if (bkpinfo->backup_media_type == cdrw) {
    512             if (extra_cdrom_params != NULL) {
    513                 mr_asprintf(&tmp, extra_cdrom_params);
    514                 mr_free(extra_cdrom_params);
    515                 mr_asprintf(&extra_cdrom_params, "%s blank=fast ", tmp);
    516             } else {
    517                 mr_asprintf(&extra_cdrom_params, "blank=fast ");
    518             }
     506            mr_strcat(extra_cdrom_params, "blank=fast ");
    519507        }
    520508        tmp = find_home_of_exe("cdrecord");
     
    600588
    601589        fd1 = mr_fopen(MONDORESTORECFG, "a");
    602         mr_fprintf(fd1, "iso-dev %s\n", iso_dev);
     590        mr_fprintf(fd1, "iso-dev=%s\n", iso_dev);
    603591
    604592        mr_asprintf(&command, "mount | grep -w %s | tail -n1 | cut -d' ' -f3",
     
    611599
    612600        log_it("res of it = %s", iso_mnt);
    613         mr_fprintf(fd1, "iso-mnt %s\n", iso_mnt);
     601        mr_fprintf(fd1, "iso-mnt=%s\n", iso_mnt);
    614602        log_it("isomnt: %s, %d", iso_mnt, strlen(iso_mnt));
    615603
     
    617605        if (strlen(iso_tmp) >= strlen(iso_mnt)) {
    618606            mr_asprintf(&iso_path, "%s", iso_tmp + strlen(iso_mnt));
     607        } else {
     608            mr_asprintf(&iso_path, "");
    619609        }
    620610        mr_free(iso_tmp);
     
    622612
    623613        log_it("isodir: %s", iso_path);
    624         mr_fprintf(fd1, "isodir %s\n", iso_path);
     614        mr_fprintf(fd1, "isodir=%s\n", iso_path);
    625615        mr_free(iso_path);
    626616
    627617        log_it("iso-prefix: %s",  bkpinfo->prefix);
    628         mr_fprintf(fd1, "iso-prefix %s\n", bkpinfo->prefix);
     618        mr_fprintf(fd1, "iso-prefix=%s\n", bkpinfo->prefix);
    629619
    630620        mr_fclose(fd1);
     
    648638            } else {
    649639                mr_asprintf(&ip_address, "%s%s", inet_ntoa((struct in_addr)
    650                                                         *((struct in_addr
    651                                                            *) hent->
    652                                                           h_addr)),
    653                          strchr(bkpinfo->nfs_mount, ':'));
     640                                                *((struct in_addr *) hent->h_addr)),
     641                                                strchr(bkpinfo->nfs_mount, ':'));
    654642                mr_allocstr(bkpinfo->nfs_mount, ip_address);
    655643                mr_free(ip_address);
     
    684672    return (retval);
    685673}
    686 
    687674
    688675
     
    710697    }
    711698
    712     unlink(MONDO_TRACEFILE);
    713699    run_program_and_log_output("rm -Rf /tmp/changed.files*", FALSE);
    714700    if ((g_mondo_home = find_and_store_mondoarchives_home()) == NULL) {
     
    811797    char *command = NULL;
    812798    char *out_sz = NULL;
    813     long res;
     799    long res = 0L;
    814800
    815801    assert_string_is_neither_NULL_nor_zerolength(partition);
     
    822808
    823809    mr_asprintf(&command, "df -m -P %s | tail -n1 | tr -s ' ' '\t' | cut -f4",
    824              partition);
     810            partition);
    825811    out_sz = call_program_and_get_last_line_of_output(command);
    826812    mr_free(command);
     813
    827814    if (strlen(out_sz) == 0) {
    828815        return (-1);
     
    832819    return (res);
    833820}
    834 
    835821
    836822
     
    10621048        return (0);
    10631049    */ } else {
    1064         mr_asprintf(&command, "grep '%s .*' %s| cut -d' ' -f2,3,4,5",
     1050        mr_asprintf(&command, "grep '%s .*' %s| cut -d'=' -f2,3,4,5",
    10651051                label, config_file);
    10661052        value = call_program_and_get_last_line_of_output(command);
     
    11101096void mount_boot_if_necessary()
    11111097{
    1112     char *tmp;
    1113     char *tmp1;
    1114     char *command;
     1098    char *tmp = NULL;
     1099    char *tmp1 = NULL;
     1100    char *command = NULL;
    11151101
    11161102    mr_msg(1, "Started sub");
     
    11401126                mr_asprintf(&g_boot_mountpt, tmp);
    11411127                mr_asprintf(&tmp1,
    1142                          "%s (your /boot partition) is not mounted. I'll mount it before backing up",
    1143                          g_boot_mountpt);
     1128                        "%s (your /boot partition) is not mounted. I'll mount it before backing up",
     1129                        g_boot_mountpt);
    11441130                log_it(tmp1);
    11451131                mr_free(tmp1);
     
    11901176
    11911177
    1192 
    11931178/**
    11941179 * Write a line to a configuration file. Writes a line of the form,
     
    12021187{
    12031188    /*@ buffers ***************************************************** */
    1204     char *command;
    1205     char *tempfile;
    1206     char *tmp;
     1189    char *command = NULL;
     1190    char *tempfile = NULL;
     1191    char *tmp = NULL;
    12071192
    12081193
     
    12381223    return (0);
    12391224}
     1225
    12401226
    12411227/**
Note: See TracChangeset for help on using the changeset viewer.