Changeset 2330 in MondoRescue
- Timestamp:
- Aug 18, 2009, 3:20:49 PM (16 years ago)
- Location:
- branches/2.2.10/mondo/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-archive.c
r2328 r2330 2559 2559 * @return 0 (there was an OK CD in the drive) or 1 (there wasn't). 2560 2560 */ 2561 int interrogate_disk_currently_in_cdrw_drive(char *cdrw_dev, 2562 bool keep_looping) 2563 { 2561 int interrogate_disk_currently_in_cdrw_drive(char *cdrw_dev, bool keep_looping) { 2564 2562 int res = 0; 2565 2563 char *bkp = NULL; … … 2823 2821 /*@ buffers ************************************************** */ 2824 2822 char *tmp = NULL; 2825 char *checksum_line, *command; 2823 char *checksum_line = NULL; 2824 char *command; 2826 2825 char *tempblock; 2827 2826 char *curr_slice_fname_uncompressed = NULL; … … 2859 2858 assert(bkpinfo != NULL); 2860 2859 assert_string_is_neither_NULL_nor_zerolength(biggie_filename); 2861 malloc_string(checksum_line);2862 2860 2863 2861 biggiestruct.for_backward_compatibility = '\n'; … … 2877 2875 if (ntfsprog_fifo) { 2878 2876 file_to_openin = ntfsprog_fifo; 2879 strcpy(checksum_line, "IGNORE"); 2880 log_msg(2, 2881 "Not calculating checksum for %s: it would take too long", 2882 biggie_filename); 2877 mr_asprintf(checksum_line, "IGNORE"); 2878 log_msg(2, "Not calculating checksum for %s: it would take too long", biggie_filename); 2883 2879 if ( !find_home_of_exe("ntfsresize")) { 2884 2880 fatal_error("ntfsresize not found"); … … 2904 2900 } 2905 2901 mr_free(command); 2906 (void) fgets(checksum_line, MAX_STR_LEN, fin);2902 mr_getline(checksum_line, fin); 2907 2903 pclose(fin); 2908 2904 totallength = length_of_file (biggie_filename); … … 2918 2914 } 2919 2915 strcpy(biggiestruct.checksum, checksum_line); 2916 mr_free(checksum_line); 2920 2917 2921 2918 mr_asprintf(tmp, "%s", slice_fname(biggie_file_number, 0, bkpinfo->tmpdir, "")); … … 2940 2937 log_to_screen("Cannot archive bigfile '%s': not found", biggie_filename); 2941 2938 2942 paranoid_free(checksum_line);2943 2939 mr_free(suffix); 2944 2940 return (1); … … 3074 3070 mr_free(tmp); 3075 3071 3076 paranoid_free(checksum_line);3077 3072 return (retval); 3078 3073 } -
branches/2.2.10/mondo/src/common/libmondo-cli.c
r2328 r2330 908 908 } 909 909 if (!flag_set['d']) { 910 if ((tmp = find_dvd_device(flag_val['d'])) != NULL) {911 strcpy(flag_val['d'],tmp );912 mr_free(tmp );910 if ((tmp1 = find_dvd_device(flag_val['d'])) != NULL) { 911 strcpy(flag_val['d'],tmp1); 912 mr_free(tmp1); 913 913 flag_set['d'] = TRUE; 914 914 log_to_screen("I guess DVD drive is at %s", flag_val['d']); … … 1323 1323 if (flag_set['f']) { 1324 1324 mr_free(bkpinfo->boot_device); 1325 mr_asprintf(bkpinfo->boot_device, "%s", resolve_softlinks_to_get_to_actual_device_file(flag_val['f']));1325 bkpinfo->boot_device = resolve_softlinks_to_get_to_actual_device_file(flag_val['f']); 1326 1326 } 1327 1327 … … 1332 1332 1333 1333 if (flag_set['Q']) { 1334 i = which_boot_loader(tmp); 1335 log_msg(3, "boot loader is %c, residing at %s", i, tmp); 1336 printf("boot loader is %c, residing at %s\n", i, tmp); 1334 i = which_boot_loader(tmp1); 1335 log_msg(3, "boot loader is %c, residing at %s", i, tmp1); 1336 printf("boot loader is %c, residing at %s\n", i, tmp1); 1337 mr_free(tmp1); 1337 1338 finish(0); 1338 1339 } -
branches/2.2.10/mondo/src/common/libmondo-devices-EXT.h
r2325 r2330 61 61 extern int inject_device(char *dev); 62 62 extern bool does_nonMS_partition_exist(void); 63 extern char *resolve_softlinks_to_get_to_actual_device_file(char 64 *incoming); 63 extern char *resolve_softlinks_to_get_to_actual_device_file(char *incoming); 65 64 66 65 extern void set_g_cdrom_and_g_dvd_to_bkpinfo_value(); -
branches/2.2.10/mondo/src/common/libmondo-devices.c
r2329 r2330 112 112 bool is_this_a_ramdisk = FALSE; 113 113 114 mr_asprintf(tmp, "%s", where_is_root_mounted());114 tmp = where_is_root_mounted(); 115 115 log_msg(0, "root is currently mounted at %s\n", tmp); 116 116 … … 156 156 static char *bkptype_to_string(t_bkptype bt) 157 157 { 158 static char output[MAX_STR_LEN / 4];158 char *output; 159 159 switch (bt) { 160 160 case none: 161 strcpy(output, "none");161 mr_asprintf(output, "none"); 162 162 break; 163 163 case iso: 164 strcpy(output, "iso");164 mr_asprintf(output, "iso"); 165 165 break; 166 166 case cdr: 167 strcpy(output, "cdr");167 mr_asprintf(output, "cdr"); 168 168 break; 169 169 case cdrw: 170 strcpy(output, "cdrw");170 mr_asprintf(output, "cdrw"); 171 171 break; 172 172 case cdstream: 173 strcpy(output, "cdstream");173 mr_asprintf(output, "cdstream"); 174 174 break; 175 175 case nfs: 176 strcpy(output, "nfs");176 mr_asprintf(output, "nfs"); 177 177 break; 178 178 case tape: 179 strcpy(output, "tape");179 mr_asprintf(output, "tape"); 180 180 break; 181 181 case udev: 182 strcpy(output, "udev");182 mr_asprintf(output, "udev"); 183 183 break; 184 184 case usb: 185 strcpy(output, "usb");185 mr_asprintf(output, "usb"); 186 186 break; 187 187 default: 188 strcpy(output, "default");188 mr_asprintf(output, "default"); 189 189 } 190 190 return (output); … … 572 572 char *output = NULL; 573 573 char *cdr_exe = NULL; 574 char *phrase_one = NULL;575 574 char *phrase_two = NULL; 576 575 char *command = NULL; … … 634 633 } 635 634 636 malloc_string(phrase_one);637 phrase_one[0] = '\0';638 malloc_string(phrase_two);639 phrase_two[0] = '\0';640 641 635 malloc_string(tmp); 642 636 tmp[0] = '\0'; … … 649 643 for (r = q; *(r - 1) == ' '; r--); 650 644 *r = '\0'; 651 strcpy(phrase_one, p);652 645 p = strchr(++q, '\''); 653 646 if (p) { … … 658 651 } 659 652 *q = '\0'; 660 strcpy(phrase_two, p);653 mr_asprintf(phrase_two, "%s", p); 661 654 } 662 655 } … … 665 658 } 666 659 paranoid_pclose(fin); 667 paranoid_free(phrase_one);668 660 669 661 #ifndef __FreeBSD__ 670 if ( strlen(phrase_two) == 0) {662 if (!phrase_two || strlen(phrase_two) == 0) { 671 663 log_msg(4, "Not running phase two. String is empty."); 672 664 } else { … … 699 691 } 700 692 } 701 paranoid_free(phrase_two);693 mr_free(phrase_two); 702 694 paranoid_free(tmp); 703 695 … … 1438 1430 } 1439 1431 */ 1440 log_msg(3, "media type = %s", bkptype_to_string(bkpinfo->backup_media_type)); 1432 tmp = bkptype_to_string(bkpinfo->backup_media_type); 1433 log_msg(3, "media type = %s", tmp); 1434 mr_free(tmp); 1435 1441 1436 bkpinfo->cdrw_speed = (bkpinfo->backup_media_type == cdstream) ? 2 : 4; 1442 bkpinfo->compression_level = 1443 (bkpinfo->backup_media_type == cdstream) ? 1 : 5; 1444 bkpinfo->use_lzo = 1445 (bkpinfo->backup_media_type == cdstream) ? TRUE : FALSE; 1437 bkpinfo->compression_level = (bkpinfo->backup_media_type == cdstream) ? 1 : 5; 1438 bkpinfo->use_lzo = (bkpinfo->backup_media_type == cdstream) ? TRUE : FALSE; 1446 1439 mvaddstr_and_log_it(2, 0, " "); 1447 1440 … … 1973 1966 log_it("media device = %s", bkpinfo->media_device); 1974 1967 log_it("media size = %ld", bkpinfo->media_size[1]); 1975 log_it("media type = %s", bkptype_to_string(bkpinfo->backup_media_type)); 1968 tmp = bkptype_to_string(bkpinfo->backup_media_type); 1969 log_it("media type = %s", tmp); 1970 mr_free(tmp); 1971 1976 1972 if (bkpinfo->prefix) { 1977 1973 log_it("prefix = %s", bkpinfo->prefix); … … 2235 2231 * The mountpoint (where it's mounted) will obviously be '/'. 2236 2232 */ 2237 char *where_is_root_mounted() 2238 { 2233 char *where_is_root_mounted() { 2239 2234 /*@ buffers **************** */ 2240 static char tmp[MAX_STR_LEN];2235 char *output; 2241 2236 2242 2237 2243 2238 #ifdef __FreeBSD__ 2244 strcpy(tmp, call_program_and_get_last_line_of_output 2245 ("mount | grep \" on / \" | cut -d' ' -f1")); 2239 mr_asprintf(output, call_program_and_get_last_line_of_output("mount | grep \" on / \" | cut -d' ' -f1")); 2246 2240 #else 2247 strcpy(tmp, call_program_and_get_last_line_of_output 2248 ("mount | grep \" on / \" | cut -d' ' -f1 | sed s/[0-9]// | sed s/[0-9]//")); 2249 if (strstr(tmp, "/dev/cciss/")) { 2250 strcpy(tmp, call_program_and_get_last_line_of_output 2251 ("mount | grep \" on / \" | cut -d' ' -f1 | cut -dp -f1")); 2252 } 2253 if (strstr(tmp, "/dev/md")) { 2254 strcpy(tmp, 2255 call_program_and_get_last_line_of_output 2256 ("mount | grep \" on / \" | cut -d' ' -f1")); 2257 } 2258 #endif 2259 2260 return (tmp); 2241 mr_asprintf(output, call_program_and_get_last_line_of_output("mount | grep \" on / \" | cut -d' ' -f1 | sed s/[0-9]// | sed s/[0-9]//")); 2242 if (strstr(output, "/dev/cciss/")) { 2243 mr_free(output); 2244 mr_asprintf(output, call_program_and_get_last_line_of_output("mount | grep \" on / \" | cut -d' ' -f1 | cut -dp -f1")); 2245 } 2246 if (strstr(output, "/dev/md")) { 2247 mr_free(output); 2248 mr_asprintf(output, call_program_and_get_last_line_of_output("mount | grep \" on / \" | cut -d' ' -f1")); 2249 } 2250 #endif 2251 2252 return (output); 2261 2253 } 2262 2254 … … 2269 2261 */ 2270 2262 #ifdef __FreeBSD__ 2271 char which_boot_loader(char *which_device) 2272 { 2263 char which_boot_loader(char *which_device) { 2273 2264 int count_lilos = 0; 2274 2265 int count_grubs = 0; … … 2286 2277 count_boot0s++; 2287 2278 } 2288 if (does_string_exist_in_first_N_blocks 2289 (which_device, "FreeBSD/i386", 17)) { 2279 if (does_string_exist_in_first_N_blocks(which_device, "FreeBSD/i386", 17)) { 2290 2280 count_dangerouslydedicated++; 2291 2281 } … … 2313 2303 #else 2314 2304 2315 char which_boot_loader(char *which_device) 2316 { 2305 char which_boot_loader(char *which_device) { 2317 2306 /*@ buffer ***************************************************** */ 2318 2307 char *list_drives_cmd = NULL; 2308 char *tmp = NULL; 2319 2309 char *current_drive; 2320 2310 … … 2328 2318 /*@ end vars *************************************************** */ 2329 2319 2330 malloc_string(current_drive);2331 2320 2332 2321 #ifdef __IA64__ … … 2334 2323 return ('E'); 2335 2324 #endif 2336 assert(which_device != NULL); 2337 2338 mr_asprintf(list_drives_cmd, "parted2fdisk -l 2>/dev/null | grep \"/dev/.*:\" | tr -s ':' ' ' | tr -s ' ' '\n' | grep /dev/; echo %s", where_is_root_mounted()); 2325 2326 tmp = where_is_root_mounted(); 2327 mr_asprintf(list_drives_cmd, "parted2fdisk -l 2>/dev/null | grep \"/dev/.*:\" | tr -s ':' ' ' | tr -s ' ' '\n' | grep /dev/; echo %s", tmp); 2328 mr_free(tmp); 2339 2329 log_it("list_drives_cmd = %s", list_drives_cmd); 2340 2330 2341 if (!(pdrives = popen(list_drives_cmd, "r"))) { 2331 pdrives = popen(list_drives_cmd, "r"); 2332 mr_free(list_drives_cmd); 2333 2334 if (!pdrives) { 2342 2335 log_OS_error("Unable to open list of drives"); 2343 mr_free(list_drives_cmd);2344 paranoid_free(current_drive);2345 2336 return ('\0'); 2346 2337 } 2347 mr_free(list_drives_cmd); 2348 2338 2339 malloc_string(current_drive); 2349 2340 for ((void)fgets(current_drive, MAX_STR_LEN, pdrives); !feof(pdrives); 2350 2341 (void)fgets(current_drive, MAX_STR_LEN, pdrives)) { … … 2353 2344 if (does_string_exist_in_boot_block(current_drive, "GRUB")) { 2354 2345 count_grubs++; 2355 strcpy(which_device, current_drive); 2346 mr_free(which_device); 2347 mr_asprintf(which_device, "%s", current_drive); 2356 2348 break; 2357 2349 } 2358 2350 if (does_string_exist_in_boot_block(current_drive, "LILO")) { 2359 2351 count_lilos++; 2360 strcpy(which_device, current_drive); 2352 mr_free(which_device); 2353 mr_asprintf(which_device, "%s", current_drive); 2361 2354 break; 2362 2355 } … … 2395 2388 if (does_string_exist_in_boot_block(current_drive, "GRUB")) { 2396 2389 count_grubs++; 2397 strcpy(which_device, current_drive); 2390 mr_free(which_device); 2391 mr_asprintf(which_device, "%s", current_drive); 2398 2392 break; 2399 2393 } 2400 2394 if (does_string_exist_in_boot_block(current_drive, "LILO")) { 2401 2395 count_lilos++; 2402 strcpy(which_device, current_drive); 2396 mr_free(which_device); 2397 mr_asprintf(which_device, "%s", current_drive); 2403 2398 break; 2404 2399 } … … 2461 2456 char *resolve_softlinks_to_get_to_actual_device_file(char *incoming) 2462 2457 { 2463 static char output[MAX_STR_LEN];2458 char *output; 2464 2459 char *command = NULL; 2465 2460 char *curr_fname; … … 2471 2466 malloc_string(curr_fname); 2472 2467 if (!does_file_exist(incoming)) { 2473 log_it 2474 ("resolve_softlinks_to_get_to_actual_device_file --- device not found"); 2475 strcpy(output, incoming); 2468 log_it("resolve_softlinks_to_get_to_actual_device_file --- device not found"); 2469 mr_asprintf(output, "%s", incoming); 2476 2470 } else { 2477 2471 strcpy(curr_fname, incoming); … … 2482 2476 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command)); 2483 2477 mr_free(command); 2484 for (p = tmp + strlen(tmp); p != tmp && *p != '`' && *p != ' '; 2485 p--); 2478 for (p = tmp + strlen(tmp); p != tmp && *p != '`' && *p != ' '; p--); 2486 2479 p++; 2487 2480 mr_asprintf(scratch, "%s", p); … … 2506 2499 lstat(curr_fname, &statbuf); 2507 2500 } 2508 strcpy(output, curr_fname);2501 mr_asprintf(output, "%s", curr_fname); 2509 2502 log_it("resolved %s to %s", incoming, output); 2510 2503 } … … 2521 2514 char *which_partition_format(const char *drive) 2522 2515 { 2523 static char output[4];2516 char *output; 2524 2517 char *tmp = NULL; 2525 2518 char *command = NULL; … … 2538 2531 2539 2532 if (strstr(tmp, "GPT") == NULL) { 2540 strcpy(output, "MBR");2533 mr_asprintf(output, "MBR"); 2541 2534 } else { 2542 strcpy(output, "GPT");2535 mr_asprintf(output, "GPT"); 2543 2536 } 2544 2537 mr_free(tmp); -
branches/2.2.10/mondo/src/common/libmondo-mountlist.c
r2324 r2330 430 430 part_table_fmt = which_partition_format(drive); 431 431 /* no spare primary partitions to help accommodate the logical(s)? */ 432 if ((curr_part_no >= 5 && prev_part_no == 4) 433 && (strcmp(part_table_fmt, "MBR") == 0)) { 432 if ((curr_part_no >= 5 && prev_part_no == 4) && (strcmp(part_table_fmt, "MBR") == 0)) { 434 433 mr_asprintf(tmp, " Partition 4 of %s is occupied.", drive); 435 434 log_it(tmp); … … 438 437 res++; 439 438 } 439 mr_free(part_table_fmt); 440 440 441 /* does partition /dev/hdNX exist more than once in the mountlist? */ 441 442 for (i = 0, mountpoint_copies = 0, device_copies = 0; -
branches/2.2.10/mondo/src/mondorestore/mondo-prep.c
r2325 r2330 1652 1652 /** pointers **********************************************************/ 1653 1653 char *p; 1654 char *part_table_fmt ;1654 char *part_table_fmt = NULL; 1655 1655 FILE *fout; 1656 1656 … … 1699 1699 log_to_screen("You need to leave at least one partition free, for 'extended/logical'"); 1700 1700 mr_free(partition_name); 1701 paranoid_free(output); 1701 mr_free(output); 1702 mr_free(part_table_fmt); 1702 1703 return (1); 1703 1704 } else { … … 1711 1712 } 1712 1713 } 1714 mr_free(part_table_fmt); 1715 1713 1716 mr_strcat(output, "\n"); /*start block (ENTER for next free blk */ 1714 1717 if (partsize > 0) {
Note:
See TracChangeset
for help on using the changeset viewer.