Changeset 1127 in MondoRescue
- Timestamp:
- Feb 10, 2007, 1:33:28 AM (18 years ago)
- Location:
- branches/stable/mondo/src/common
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/mondo/src/common/libmondo-devices-EXT.h
r128 r1127 71 71 72 72 extern char *which_partition_format(const char *drive); 73 extern char *bkptype_to_string(t_bkptype bt); -
branches/stable/mondo/src/common/libmondo-devices.c
r1126 r1127 2267 2267 2268 2268 2269 2270 2271 2272 2273 2274 2269 /** 2275 2270 * Find out what device is mounted as root (/). … … 2361 2356 /*@ buffer ***************************************************** */ 2362 2357 char *list_drives_cmd; 2363 char *current_drive ;2358 char *current_drive = NULL; 2364 2359 2365 2360 /*@ pointers *************************************************** */ … … 2369 2364 int count_lilos = 0; 2370 2365 int count_grubs = 0; 2366 size_t n = 0; 2371 2367 2372 2368 /*@ end vars *************************************************** */ 2373 2374 malloc_string(list_drives_cmd);2375 malloc_string(current_drive);2376 2369 2377 2370 #ifdef __IA64__ … … 2380 2373 #endif 2381 2374 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, 2386 2376 "parted2fdisk -l 2>/dev/null | grep \"/dev/.*:\" | tr -s ':' ' ' | tr -s ' ' '\n' | grep /dev/; echo %s", 2387 2377 where_is_root_mounted()); … … 2391 2381 log_OS_error("Unable to open list of drives"); 2392 2382 mr_free(list_drives_cmd); 2393 mr_free(current_drive);2394 2383 return ('\0'); 2395 2384 } 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(¤t_drive, &n, pdrives); !feof(pdrives); 2388 mr_getline(¤t_drive, &n, pdrives)) { 2398 2389 strip_spaces(current_drive); 2399 2390 log_it("looking at drive %s's MBR", current_drive); … … 2409 2400 } 2410 2401 } 2402 2411 2403 if (pclose(pdrives)) { 2412 2404 log_OS_error("Cannot pclose pdrives"); 2413 2405 } 2414 2406 log_it("%d grubs and %d lilos\n", count_grubs, count_lilos); 2415 mr_free(list_drives_cmd);2416 mr_free(current_drive);2417 2407 if (count_grubs && !count_lilos) { 2418 2408 return ('G'); … … 2430 2420 2431 2421 2432 2433 2434 2422 /** 2435 2423 * Write zeroes over the first 16K of @p device. … … 2456 2444 return (0); 2457 2445 } 2446 2458 2447 2459 2448 /** … … 2467 2456 { 2468 2457 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; 2474 2463 2475 2464 struct stat statbuf; 2476 command = malloc(1000);2477 2465 malloc_string(tmp); 2478 2466 malloc_string(scratch); … … 2487 2475 while (S_ISLNK(statbuf.st_mode)) { 2488 2476 mr_msg(1, "curr_fname = %s", curr_fname); 2489 sprintf(command, "file %s", curr_fname);2477 mr_asprintf(&command, "file %s", curr_fname); 2490 2478 strcpy(tmp, call_program_and_get_last_line_of_output(command)); 2479 mr_free(command); 2480 2491 2481 for (p = tmp + strlen(tmp); p != tmp && *p != '`' && *p != ' '; 2492 2482 p--); … … 2514 2504 log_it("resolved %s to %s", incoming, output); 2515 2505 } 2516 mr_free(command);2517 2506 mr_free(curr_fname); 2518 2507 mr_free(tmp);
Note:
See TracChangeset
for help on using the changeset viewer.