Changeset 2351 in MondoRescue for branches/2.2.10/mondo/src/common/libmondo-devices.c
- Timestamp:
- Aug 28, 2009, 2:41:30 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-devices.c
r2349 r2351 313 313 /*@ buffers **************************************************** */ 314 314 char *program = NULL; 315 char *incoming ;315 char *incoming = NULL; 316 316 char *searchstr = NULL; 317 317 char *tmp = NULL; … … 327 327 assert_string_is_neither_NULL_nor_zerolength(drive); 328 328 assert(partno >= 0 && partno < 999); 329 330 malloc_string(incoming);331 329 332 330 #ifdef __FreeBSD__ … … 356 354 searchstr = build_partition_name(drive, partno); 357 355 mr_strcat(searchstr, " "); 358 for (res = 0 ; !res && fgets(incoming, MAX_STR_LEN - 1, fin);) {356 for (res = 0, mr_getline(incoming, fin); !res && !feof(fin) ; mr_getline(incoming, fin)) { 359 357 if (strstr(incoming, searchstr)) { 360 358 res = 1; 361 359 } 362 } 360 mr_free(incoming); 361 } 362 mr_free(incoming); 363 363 mr_free(searchstr); 364 364 … … 366 366 log_OS_error("Cannot pclose fin"); 367 367 } 368 paranoid_free(incoming);369 368 return (res); 370 369 } … … 567 566 /*@ buffers ***************************************************** */ 568 567 char *tmp = NULL; 569 char *tmp1 = NULL;570 568 char *output = NULL; 571 569 char *cdr_exe = NULL; … … 634 632 } 635 633 636 malloc_string(tmp); 637 tmp[0] = '\0'; 638 for ((void)fgets(tmp, MAX_STR_LEN, fin); !feof(fin); 639 (void)fgets(tmp, MAX_STR_LEN, fin)) { 634 for (mr_getline(tmp, fin); !feof(fin); mr_getline(tmp, fin)) { 640 635 p = strchr(tmp, '\''); 641 636 if (p) { … … 657 652 } 658 653 } 659 } 654 mr_free(tmp); 655 } 656 mr_free(tmp); 660 657 paranoid_pclose(fin); 661 658 … … 671 668 log_msg(4, "Cannot run 2nd command - non-fatal, fortunately"); 672 669 } else { 673 for ((void)fgets(tmp, MAX_STR_LEN, fin); !feof(fin); 674 (void)fgets(tmp, MAX_STR_LEN, fin)) { 670 for (mr_getline(tmp, fin); !feof(fin); mr_getline(tmp, fin)) { 675 671 log_msg(5, "--> '%s'", tmp); 676 672 if (tmp[0] != ' ' && tmp[1] != ' ') { … … 688 684 } 689 685 } 686 mr_free(tmp); 690 687 } 691 688 paranoid_pclose(fin); 689 mr_free(tmp); 692 690 } 693 691 } 694 692 mr_free(phrase_two); 695 paranoid_free(tmp);696 693 697 694 #endif … … 725 722 726 723 if (found_it) { 727 mr_asprintf(tmp 1, "grep \"%s=ide-scsi\" " CMDLINE " &> /dev/null", strrchr(output, '/') + 1);728 if (system(tmp 1) == 0) {724 mr_asprintf(tmp, "grep \"%s=ide-scsi\" " CMDLINE " &> /dev/null", strrchr(output, '/') + 1); 725 if (system(tmp) == 0) { 729 726 log_msg(4, "%s is not right. It's being SCSI-emulated. Continuing.", output); 730 727 found_it = FALSE; 731 728 mr_free(output); 732 729 } 733 mr_free(tmp 1);730 mr_free(tmp); 734 731 } 735 732 … … 772 769 mr_free(output); 773 770 } else { 774 mr_asprintf(tmp 1, "%s/archives", mountpoint);771 mr_asprintf(tmp, "%s/archives", mountpoint); 775 772 if (!does_file_exist(tmp)) { 776 773 log_msg(4, "[Cardigans] I'll take it back"); … … 784 781 log_msg(4, "I'm confident the Mondo CD is in %s", output); 785 782 } 786 mr_free(tmp 1);783 mr_free(tmp); 787 784 } 788 785 } … … 808 805 809 806 log_msg(1, "command=%s", command); 810 mr_asprintf(tmp 1, "%s", call_program_and_get_last_line_of_output(command));807 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command)); 811 808 mr_free(command); 812 809 813 810 mr_free(output); 814 if (strlen(tmp 1) > 0) {815 mr_asprintf(output, "%s", tmp 1);811 if (strlen(tmp) > 0) { 812 mr_asprintf(output, "%s", tmp); 816 813 log_msg(4, "Finally found it at %s", output); 817 814 } else { 818 815 log_msg(4, "Still couldn't find it."); 819 816 } 820 mr_free(tmp 1);817 mr_free(tmp); 821 818 822 819 return (output); … … 1026 1023 1027 1024 /*@ buffers ***************************************************** */ 1028 char *incoming ;1025 char *incoming = NULL; 1029 1026 char *device_with_tab = NULL; 1030 1027 char *device_with_space = NULL; … … 1044 1041 } 1045 1042 1046 malloc_string(incoming);1047 1043 if (device_raw[0] != '/' && !strstr(device_raw, ":/")) { 1048 1044 log_msg(1, "%s needs to have a '/' prefixed - I'll do it", … … 1067 1063 return(FALSE); 1068 1064 } 1069 for ((void)fgets(incoming, MAX_STR_LEN - 1, fin); !feof(fin); 1070 (void)fgets(incoming, MAX_STR_LEN - 1, fin)) { 1071 if (strstr(incoming, device_with_space) //> incoming 1072 || strstr(incoming, device_with_tab)) // > incoming) 1073 { 1065 1066 for (mr_getline(incoming, fin); !feof(fin); mr_getline(incoming, fin)) { 1067 if (strstr(incoming, device_with_space) || strstr(incoming, device_with_tab)) { 1074 1068 paranoid_pclose(fin); 1075 paranoid_free(incoming);1069 mr_free(incoming); 1076 1070 return(TRUE); 1077 1071 } 1078 } 1072 mr_free(incoming); 1073 } 1074 mr_free(incoming); 1079 1075 mr_free(device_with_tab); 1080 1076 mr_free(device_with_space); … … 1086 1082 } 1087 1083 mr_free(tmp); 1088 paranoid_free(incoming);1089 1084 return(retval); 1090 1085 } … … 2308 2303 char *list_drives_cmd = NULL; 2309 2304 char *tmp = NULL; 2310 char *current_drive ;2305 char *current_drive = NULL; 2311 2306 2312 2307 /*@ pointers *************************************************** */ 2313 FILE *pdrives ;2308 FILE *pdrives = NULL; 2314 2309 2315 2310 /*@ int ******************************************************** */ … … 2338 2333 } 2339 2334 2340 malloc_string(current_drive); 2341 for ((void)fgets(current_drive, MAX_STR_LEN, pdrives); !feof(pdrives); 2342 (void)fgets(current_drive, MAX_STR_LEN, pdrives)) { 2343 strip_spaces(current_drive); 2335 for (mr_getline(current_drive, pdrives); !feof(pdrives); mr_getline(current_drive, pdrives)) { 2336 mr_strip_spaces(current_drive); 2344 2337 log_it("looking at drive %s's MBR", current_drive); 2345 2338 if (does_string_exist_in_boot_block(current_drive, "GRUB")) { … … 2349 2342 mr_asprintf(which_device, "%s", current_drive); 2350 2343 */ 2344 mr_free(current_drive); 2351 2345 break; 2352 2346 } … … 2357 2351 mr_asprintf(which_device, "%s", current_drive); 2358 2352 */ 2353 mr_free(current_drive); 2359 2354 break; 2360 2355 } 2361 } 2356 mr_free(current_drive); 2357 } 2358 mr_free(current_drive); 2359 2362 2360 if (pclose(pdrives)) { 2363 2361 log_OS_error("Cannot pclose pdrives"); … … 2365 2363 log_it("%d grubs and %d lilos\n", count_grubs, count_lilos); 2366 2364 if (count_grubs && !count_lilos) { 2367 paranoid_free(current_drive);2368 2365 return ('G'); 2369 2366 } else if (count_lilos && !count_grubs) { 2370 paranoid_free(current_drive);2371 2367 return ('L'); 2372 2368 } else if (count_grubs == 1 && count_lilos == 1) { 2373 2369 log_it("I'll bet you used to use LILO but switched to GRUB..."); 2374 paranoid_free(current_drive);2375 2370 return ('G'); 2376 2371 } else { … … 2382 2377 log_OS_error("Unable to open list of drives"); 2383 2378 mr_free(list_drives_cmd); 2384 paranoid_free(current_drive);2385 2379 return ('\0'); 2386 2380 } 2387 2381 mr_free(list_drives_cmd); 2388 2382 2389 for ((void)fgets(current_drive, MAX_STR_LEN, pdrives); !feof(pdrives); 2390 (void)fgets(current_drive, MAX_STR_LEN, pdrives)) { 2391 strip_spaces(current_drive); 2383 for (mr_getline(current_drive, pdrives); !feof(pdrives); mr_getline(current_drive, pdrives)) { 2384 mr_strip_spaces(current_drive); 2392 2385 log_it("looking at partition %s's BR", current_drive); 2393 2386 if (does_string_exist_in_boot_block(current_drive, "GRUB")) { … … 2397 2390 mr_asprintf(which_device, "%s", current_drive); 2398 2391 */ 2392 mr_free(current_drive); 2399 2393 break; 2400 2394 } … … 2405 2399 mr_asprintf(which_device, "%s", current_drive); 2406 2400 */ 2401 mr_free(current_drive); 2407 2402 break; 2408 2403 } 2409 } 2404 mr_free(current_drive); 2405 } 2406 mr_free(current_drive); 2407 2410 2408 if (pclose(pdrives)) { 2411 2409 log_OS_error("Cannot pclose pdrives"); 2412 2410 } 2413 2411 log_it("%d grubs and %d lilos\n", count_grubs, count_lilos); 2414 paranoid_free(current_drive);2415 2412 if (count_grubs && !count_lilos) { 2416 2413 return ('G');
Note:
See TracChangeset
for help on using the changeset viewer.