Ignore:
Timestamp:
Feb 9, 2007, 8:09:40 AM (17 years ago)
Author:
Bruno Cornec
Message:

fix linker errors
begining of rewrite for libmondo-devices.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/mondo/src/common/libmondo-devices.c

    r1116 r1120  
    1414#include "libmondo-string-EXT.h"
    1515#include "libmondo-tools-EXT.h"
    16 #include "libmondo-gui-EXT.h"
     16#include "newt-specific-EXT.h"
    1717#include "libmondo-fork-EXT.h"
    1818#include "libmondo-stream-EXT.h"
    19 
     19#include "mr_mem.h"
     20
     21#include <sys/ioctl.h>
    2022#include <sys/types.h>
     23#include <unistd.h>
    2124#ifdef __FreeBSD__
    2225#define DKTYPENAMES
     
    100103bool am_I_in_disaster_recovery_mode(void)
    101104{
    102     char *tmp, *comment;
     105    char *tmp = NULL;
     106    char *comment = NULL;
    103107    bool is_this_a_ramdisk = FALSE;
    104108
    105     malloc_string(tmp);
    106     malloc_string(comment);
    107     strcpy(tmp, where_is_root_mounted());
    108     sprintf(comment, "root is mounted at %s\n", tmp);
     109    mr_asprintf(&tmp, where_is_root_mounted());
     110    mr_asprintf(&comment, "root is mounted at %s\n", tmp);
    109111    mr_msg(0, comment);
     112    mr_free(comment);
     113
    110114    mr_msg(0,
    111115            "No, Schlomo, that doesn't mean %s is the root partition. It's just a debugging message. Relax. It's part of am_I_in_disaster_recovery_mode().",
     
    126130    }
    127131#endif
     132    mr_free(tmp);
    128133
    129134    if (is_this_a_ramdisk) {
     
    131136            && !does_file_exist("/tmp/mountlist.txt.sample")) {
    132137            log_to_screen
    133                 ("Using /dev/root is stupid of you but I'll forgive you.");
     138                (_("Using /dev/root is stupid of you but I'll forgive you."));
    134139            is_this_a_ramdisk = FALSE;
    135140        }
     
    138143        is_this_a_ramdisk = TRUE;
    139144    }
    140     mr_free(tmp);
    141     mr_free(comment);
    142145    mr_msg(1, "Is this a ramdisk? result = %d", is_this_a_ramdisk);
    143146    return (is_this_a_ramdisk);
    144147}
    145 
    146 
    147 
    148148
    149149
     
    182182        strcpy(output, "udev");
    183183        break;
     184    case usb:
     185        strcpy(output, "usb");
     186        break;
    184187    default:
    185188        strcpy(output, "default");
     
    187190    return (output);
    188191}
    189 
    190192
    191193
     
    201203int eject_device(char *dev)
    202204{
    203     char *command;
     205    char *command = NULL;
    204206    int res1 = 0, res2 = 0;
    205 
    206     malloc_string(command);
    207207
    208208    if (IS_THIS_A_STREAMING_BACKUP(g_backup_media_type)
    209209        && g_backup_media_type != udev) {
    210         sprintf(command, "mt -f %s offline", dev);
     210        mr_asprintf(&command, "mt -f %s offline", dev);
    211211        res1 = run_program_and_log_output(command, 1);
     212        mr_free(command);
    212213    } else {
    213214        res1 = 0;
     
    216217#ifdef __FreeBSD__
    217218    if (strstr(dev, "acd")) {
    218         sprintf(command, "cdcontrol -f %s eject", dev);
    219     } else {
    220         sprintf(command, "camcontrol eject `echo %s | sed 's|/dev/||'`",
     219        mr_asprintf(&command, "cdcontrol -f %s eject", dev);
     220    } else {
     221        mr_asprintf(&command, "camcontrol eject `echo %s | sed 's|/dev/||'`",
    221222                dev);
    222223    }
    223224#else
    224     sprintf(command, "eject %s", dev);
     225    mr_asprintf(&command, "eject %s", dev);
    225226#endif
    226227
     
    235236}
    236237
     238
    237239/**
    238240 * Load (inject) the tray of the specified CD device.
     
    242244int inject_device(char *dev)
    243245{
    244     char *command;
     246    char *command = NULL;
    245247    int i;
    246 
    247     malloc_string(command);
    248 
    249248
    250249#ifdef __FreeBSD__
    251250    if (strstr(dev, "acd")) {
    252         sprintf(command, "cdcontrol -f %s close", dev);
    253     } else {
    254         sprintf(command, "camcontrol load `echo %s | sed 's|/dev/||'`",
     251        mr_asprintf(&command, "cdcontrol -f %s close", dev);
     252    } else {
     253        mr_asprintf(&command, "camcontrol load `echo %s | sed 's|/dev/||'`",
    255254                dev);
    256255    }
    257256#else
    258     sprintf(command, "eject -t %s", dev);
     257    mr_asprintf(&command, "eject -t %s", dev);
    259258#endif
    260259    i = run_program_and_log_output(command, FALSE);
     
    273272
    274273    /*@ buffers *********************************************************** */
    275     char *tmp;
    276     bool ret;
    277 
    278     malloc_string(tmp);
     274    char *tmp = NULL;
     275    bool ret = FALSE;
     276
    279277    assert_string_is_neither_NULL_nor_zerolength(device);
    280278
    281     sprintf(tmp, "ls %s > /dev/null 2> /dev/null", device);
     279    mr_asprintf(&tmp, "ls %s > /dev/null 2> /dev/null", device);
    282280
    283281    if (system(tmp)) {
     
    287285    }
    288286    mr_free(tmp);
    289     return (ret);
     287    return(ret);
    290288}
    291289
     
    318316    /*@ buffers **************************************************** */
    319317    char *program;
    320     char *incoming;
     318    char *incoming = NULL;
    321319    char *searchstr;
    322     char *tmp;
     320    char *tmp = NULL;
    323321
    324322    /*@ ints ******************************************************* */
    325323    int res = 0;
     324    size_t n = 0;
    326325
    327326    /*@ pointers *************************************************** */
     
    333332    assert(partno >= 0 && partno < 999);
    334333
    335     malloc_string(program);
    336334    malloc_string(incoming);
    337335    malloc_string(searchstr);
     
    340338#ifdef __FreeBSD__
    341339    // We assume here that this is running from mondorestore. (It is.)
    342     sprintf(program, "ls %s >/dev/null 2>&1", drive,
     340    // BERLIOS: This is BROKEN - 1 %s - 2 params !!
     341    mr_asprintf(&program, "ls %s >/dev/null 2>&1", drive,
    343342            build_partition_name(tmp, drive, partno));
    344343    return system(program);
Note: See TracChangeset for help on using the changeset viewer.