Ignore:
Timestamp:
Feb 10, 2007, 1:33:28 AM (17 years ago)
Author:
Bruno Cornec
Message:

End on memory mngt for libmondo-devices.c for the moment

File:
1 edited

Legend:

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

    r1126 r1127  
    22672267
    22682268
    2269 
    2270 
    2271 
    2272 
    2273 
    22742269/**
    22752270 * Find out what device is mounted as root (/).
     
    23612356    /*@ buffer ***************************************************** */
    23622357    char *list_drives_cmd;
    2363     char *current_drive;
     2358    char *current_drive = NULL;
    23642359
    23652360    /*@ pointers *************************************************** */
     
    23692364    int count_lilos = 0;
    23702365    int count_grubs = 0;
     2366    size_t n = 0;
    23712367
    23722368    /*@ end vars *************************************************** */
    2373 
    2374     malloc_string(list_drives_cmd);
    2375     malloc_string(current_drive);
    23762369
    23772370#ifdef __IA64__
     
    23802373#endif
    23812374    assert(which_device != NULL);
    2382     //  sprintf (list_drives_cmd,
    2383     //       "fdisk -l | grep /dev | grep cyl | tr ':' ' ' | cut -d' ' -f2");
    2384 
    2385     sprintf(list_drives_cmd,
     2375    mr_asprintf(&list_drives_cmd,
    23862376            "parted2fdisk -l 2>/dev/null | grep \"/dev/.*:\" | tr -s ':' ' ' | tr -s ' ' '\n' | grep /dev/; echo %s",
    23872377            where_is_root_mounted());
     
    23912381        log_OS_error("Unable to open list of drives");
    23922382        mr_free(list_drives_cmd);
    2393         mr_free(current_drive);
    23942383        return ('\0');
    23952384    }
    2396     for (fgets(current_drive, MAX_STR_LEN, pdrives); !feof(pdrives);
    2397          fgets(current_drive, MAX_STR_LEN, pdrives)) {
     2385    mr_free(list_drives_cmd);
     2386
     2387    for (mr_getline(&current_drive, &n, pdrives); !feof(pdrives);
     2388         mr_getline(&current_drive, &n, pdrives)) {
    23982389        strip_spaces(current_drive);
    23992390        log_it("looking at drive %s's MBR", current_drive);
     
    24092400        }
    24102401    }
     2402
    24112403    if (pclose(pdrives)) {
    24122404        log_OS_error("Cannot pclose pdrives");
    24132405    }
    24142406    log_it("%d grubs and %d lilos\n", count_grubs, count_lilos);
    2415     mr_free(list_drives_cmd);
    2416     mr_free(current_drive);
    24172407    if (count_grubs && !count_lilos) {
    24182408        return ('G');
     
    24302420
    24312421
    2432 
    2433 
    24342422/**
    24352423 * Write zeroes over the first 16K of @p device.
     
    24562444    return (0);
    24572445}
     2446
    24582447
    24592448/**
     
    24672456{
    24682457    static char output[MAX_STR_LEN];
    2469     char *command;
    2470     char *curr_fname;
    2471     char *scratch;
    2472     char *tmp;
    2473     char *p;
     2458    char *command = NULL;
     2459    char *curr_fname = NULL;
     2460    char *scratch = NULL;
     2461    char *tmp = NULL;
     2462    char *p = NULL;
    24742463
    24752464    struct stat statbuf;
    2476     command = malloc(1000);
    24772465    malloc_string(tmp);
    24782466    malloc_string(scratch);
     
    24872475        while (S_ISLNK(statbuf.st_mode)) {
    24882476            mr_msg(1, "curr_fname = %s", curr_fname);
    2489             sprintf(command, "file %s", curr_fname);
     2477            mr_asprintf(&command, "file %s", curr_fname);
    24902478            strcpy(tmp, call_program_and_get_last_line_of_output(command));
     2479            mr_free(command);
     2480
    24912481            for (p = tmp + strlen(tmp); p != tmp && *p != '`' && *p != ' ';
    24922482                 p--);
     
    25142504        log_it("resolved %s to %s", incoming, output);
    25152505    }
    2516     mr_free(command);
    25172506    mr_free(curr_fname);
    25182507    mr_free(tmp);
Note: See TracChangeset for help on using the changeset viewer.