Changeset 2241 in MondoRescue for branches/2.2.9/mondo/src/common/libmondo-devices.c
- Timestamp:
- Jun 29, 2009, 7:19:14 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mondo/src/common/libmondo-devices.c
r2226 r2241 2406 2406 { 2407 2407 /*@ buffer ***************************************************** */ 2408 char *list_drives_cmd ;2408 char *list_drives_cmd = NULL; 2409 2409 char *current_drive; 2410 2410 … … 2418 2418 /*@ end vars *************************************************** */ 2419 2419 2420 malloc_string(list_drives_cmd);2421 2420 malloc_string(current_drive); 2422 2421 … … 2426 2425 #endif 2427 2426 assert(which_device != NULL); 2428 // sprintf (list_drives_cmd, 2429 // "fdisk -l | grep /dev | grep cyl | tr ':' ' ' | cut -d' ' -f2"); 2430 2431 sprintf(list_drives_cmd, 2427 2428 mr_asprintf(&list_drives_cmd, 2432 2429 "parted2fdisk -l 2>/dev/null | grep \"/dev/.*:\" | tr -s ':' ' ' | tr -s ' ' '\n' | grep /dev/; echo %s", 2433 2430 where_is_root_mounted()); … … 2436 2433 if (!(pdrives = popen(list_drives_cmd, "r"))) { 2437 2434 log_OS_error("Unable to open list of drives"); 2438 paranoid_free(list_drives_cmd);2435 mr_free(list_drives_cmd); 2439 2436 paranoid_free(current_drive); 2440 2437 return ('\0'); 2441 2438 } 2439 mr_free(list_drives_cmd); 2440 2442 2441 for ((void)fgets(current_drive, MAX_STR_LEN, pdrives); !feof(pdrives); 2443 2442 (void)fgets(current_drive, MAX_STR_LEN, pdrives)) { … … 2460 2459 log_it("%d grubs and %d lilos\n", count_grubs, count_lilos); 2461 2460 if (count_grubs && !count_lilos) { 2461 paranoid_free(current_drive); 2462 2462 return ('G'); 2463 2463 } else if (count_lilos && !count_grubs) { 2464 paranoid_free(current_drive); 2464 2465 return ('L'); 2465 2466 } else if (count_grubs == 1 && count_lilos == 1) { 2466 2467 log_it("I'll bet you used to use LILO but switched to GRUB..."); 2468 paranoid_free(current_drive); 2467 2469 return ('G'); 2468 2470 } else { 2469 2471 // We need to look on each partition then 2470 sprintf(list_drives_cmd,2472 mr_asprintf(&list_drives_cmd, 2471 2473 "parted2fdisk -l 2>/dev/null | grep -E \"^/dev/\" | tr -s ':' ' ' | tr -s ' ' '\n' | grep /dev/"); 2472 2474 log_it("list_drives_cmd = %s", list_drives_cmd); … … 2474 2476 if (!(pdrives = popen(list_drives_cmd, "r"))) { 2475 2477 log_OS_error("Unable to open list of drives"); 2476 paranoid_free(list_drives_cmd);2478 mr_free(list_drives_cmd); 2477 2479 paranoid_free(current_drive); 2478 2480 return ('\0'); 2479 2481 } 2482 mr_free(list_drives_cmd); 2483 2480 2484 for ((void)fgets(current_drive, MAX_STR_LEN, pdrives); !feof(pdrives); 2481 2485 (void)fgets(current_drive, MAX_STR_LEN, pdrives)) { … … 2497 2501 } 2498 2502 log_it("%d grubs and %d lilos\n", count_grubs, count_lilos); 2499 paranoid_free(list_drives_cmd);2500 2503 paranoid_free(current_drive); 2501 2504 if (count_grubs && !count_lilos) {
Note:
See TracChangeset
for help on using the changeset viewer.