Changeset 3822 in MondoRescue for branches/3.3/mondo
- Timestamp:
- Mar 3, 2024, 2:44:57 AM (6 months ago)
- Location:
- branches/3.3/mondo/src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3/mondo/src/common/libmondo-archive.c
r3798 r3822 487 487 ntapedev = get_non_rewind_dev(bkpinfo->media_device); 488 488 if ((bkpinfo->use_obdr) && (ntapedev != NULL)) { 489 strncpy(bkpinfo->media_device,ntapedev,(size_t)((MAX_STR_LEN / 4)-1));489 mr_asprintf(bkpinfo->media_device, "%s", ntapedev); 490 490 } else { 491 491 if (ntapedev == NULL) { -
branches/3.3/mondo/src/common/libmondo-cli.c
r3821 r3822 695 695 mr_asprintf(bkpinfo->netfs_remote_dir, "%s", flag_val['d']); 696 696 } else { /* backup device (if tape/CD-R/CD-RW) */ 697 strncpy(bkpinfo->media_device, flag_val['d'],(MAX_STR_LEN / 4)-1);697 mr_asprintf(bkpinfo->media_device, "%s", flag_val['d']); 698 698 } 699 699 } … … 719 719 if (!flag_set['d'] && (flag_set['c'] || flag_set['w'] || flag_set['C'])) { 720 720 if (g_kernel_version >= 2.6) { 721 if (popup_and_get_string 722 ("Device", "Please specify the device", 723 bkpinfo->media_device, MAX_STR_LEN / 4)) { 721 tmp1 = popup_and_get_string("Device", "Please specify the device",bkpinfo->media_device, MAX_STR_LEN / 4); 722 if (tmp1 == NULL) { 724 723 retval++; 725 724 log_to_screen("User opted to cancel."); 725 } else { 726 mr_free(bkpinfo->media_device); 727 bkpinfo->media_device = tmp1; 726 728 } 727 729 } else if (find_cdrw_device(bkpinfo->media_device)) { 728 730 retval++; 729 log_to_screen 730 ("Tried and failed to find CD-R[W] drive automatically.\n"); 731 log_to_screen("Tried and failed to find CD-R[W] drive automatically.\n"); 731 732 } else { 732 733 flag_set['d'] = TRUE; -
branches/3.3/mondo/src/common/libmondo-devices.c
r3821 r3822 1407 1407 if (bkpinfo->disaster_recovery 1408 1408 && does_file_exist("/tmp/CDROM-LIVES-HERE")) { 1409 strcpy(bkpinfo->media_device, 1410 last_line_of_file("/tmp/CDROM-LIVES-HERE")); 1409 mr_asprintf(bkpinfo->media_device, "%s", last_line_of_file("/tmp/CDROM-LIVES-HERE")); 1411 1410 } else { 1412 1411 find_cdrom_device(bkpinfo->media_device, TRUE); … … 2174 2173 char *tmpro = NULL; 2175 2174 char *tmp1 = NULL; 2175 char *tmp2 = NULL; 2176 2176 char *mds = NULL; 2177 2177 char *oldtmp = NULL; … … 2263 2263 log_msg(1, "Setting to DVD defaults"); 2264 2264 } else { 2265 strcpy(bkpinfo->media_device, VANILLA_SCSI_CDROM);2265 mr_asprintf(bkpinfo->media_device, "%s", VANILLA_SCSI_CDROM); 2266 2266 strcpy(tmp1, "4"); 2267 2267 mr_asprintf(sz_size, "%d", 650); … … 2298 2298 2299 2299 if ((bkpinfo->disaster_recovery) && (bkpinfo->backup_media_type != usb)) { 2300 strcpy(bkpinfo->media_device, "/dev/cdrom");2300 mr_asprintf(bkpinfo->media_device, "%s", "/dev/cdrom"); 2301 2301 log_msg(2, "CD-ROM device assumed to be at %s", bkpinfo->media_device); 2302 2302 } else if ((bkpinfo->restore_data && (bkpinfo->backup_media_type != usb)) || bkpinfo->backup_media_type == dvd) { 2303 if ( !bkpinfo->media_device[0]) {2304 strcpy(bkpinfo->media_device, "/dev/cdrom");2303 if (bkpinfo->media_device == NULL) { 2304 mr_asprintf(bkpinfo->media_device, "%s", "/dev/cdrom"); 2305 2305 } // just for the heck of it :) 2306 2306 log_msg(1, "bkpinfo->media_device = %s", bkpinfo->media_device); … … 2308 2308 log_msg(1, "bkpinfo->media_device = %s", bkpinfo->media_device); 2309 2309 mr_asprintf(comment, "Please specify your %s drive's /dev entry", mds); 2310 if (!popup_and_get_string("Device?", comment, bkpinfo->media_device,(MAX_STR_LEN / 4)-1)) { 2310 tmp2 = popup_and_get_string("Device?", comment, bkpinfo->media_device,(MAX_STR_LEN / 4)-1); 2311 if (!tmp2) { 2311 2312 log_to_screen("User has chosen not to backup the machine"); 2312 2313 finish(1); 2314 } else { 2315 mr_free(bkpinfo->media_device); 2316 bkpinfo->media_device = tmp2; 2313 2317 } 2314 2318 } … … 2316 2320 } else { 2317 2321 if ((find_cdrw_device(bkpinfo->media_device)) && (bkpinfo->backup_media_type != usb)) { 2318 bkpinfo->media_device[0] = '\0';2319 } 2320 if (bkpinfo->media_device [0]) {2322 mr_free(bkpinfo->media_device); 2323 } 2324 if (bkpinfo->media_device != NULL) { 2321 2325 if (bkpinfo->backup_media_type == usb) { 2322 2326 mr_asprintf(tmp, "I think your %s media corresponds to %s. Is this correct?", mds, bkpinfo->media_device); … … 2325 2329 } 2326 2330 if (!ask_me_yes_or_no(tmp)) { 2327 bkpinfo->media_device[0] = '\0';2331 mr_free(bkpinfo->media_device); 2328 2332 } 2329 2333 mr_free(tmp); 2330 2334 } 2331 if ( !bkpinfo->media_device[0]) {2335 if (bkpinfo->media_device != NULL) { 2332 2336 if (bkpinfo->backup_media_type == usb) { 2333 i= popup_and_get_string("/dev entry?", "What is the /dev entry of your USB Disk/Key, please?", bkpinfo->media_device, (MAX_STR_LEN / 4)-1);2337 tmp2 = popup_and_get_string("/dev entry?", "What is the /dev entry of your USB Disk/Key, please?", bkpinfo->media_device, (MAX_STR_LEN / 4)-1); 2334 2338 } else { 2335 2339 if (g_kernel_version < 2.6) { 2336 i= popup_and_get_string("Device node?", "What is the SCSI node of your CD (re)writer, please?", bkpinfo->media_device,(MAX_STR_LEN / 4)-1);2340 tmp2 = popup_and_get_string("Device node?", "What is the SCSI node of your CD (re)writer, please?", bkpinfo->media_device,(MAX_STR_LEN / 4)-1); 2337 2341 } else { 2338 i= popup_and_get_string("/dev entry?", "What is the /dev entry of your CD (re)writer, please?", bkpinfo->media_device,(MAX_STR_LEN / 4)-1);2342 tmp2 = popup_and_get_string("/dev entry?", "What is the /dev entry of your CD (re)writer, please?", bkpinfo->media_device,(MAX_STR_LEN / 4)-1); 2339 2343 } 2340 2344 } 2341 if ( !i) {2345 if (tmp2 == NULL) { 2342 2346 log_to_screen("User has chosen not to backup the machine"); 2343 2347 finish(1); 2348 } else { 2349 mr_free(bkpinfo->media_device); 2350 bkpinfo->media_device = tmp2; 2344 2351 } 2345 2352 } … … 2361 2368 if ((!bkpinfo->restore_mode) && (find_tape_device_and_size(bkpinfo->media_device, sz_size))) { 2362 2369 log_msg(3, "Ok, using vanilla scsi tape."); 2363 strcpy(bkpinfo->media_device, VANILLA_SCSI_TAPE);2370 mr_asprintf(bkpinfo->media_device, "%s", VANILLA_SCSI_TAPE); 2364 2371 if ((fin = fopen(bkpinfo->media_device, "r"))) { 2365 2372 paranoid_fclose(fin); 2366 2373 } else { 2367 strcpy(bkpinfo->media_device, "/dev/osst0");2368 } 2369 } 2370 if (bkpinfo->media_device [0]) {2374 mr_asprintf(bkpinfo->media_device, "%s", "/dev/osst0"); 2375 } 2376 } 2377 if (bkpinfo->media_device != NULL) { 2371 2378 if ((fin = fopen(bkpinfo->media_device, "r"))) { 2372 2379 paranoid_fclose(fin); … … 2377 2384 } 2378 2385 } 2379 if (bkpinfo->media_device [0]) {2386 if (bkpinfo->media_device != NULL) { 2380 2387 mr_asprintf(tmp, "I think I've found your tape streamer at %s; am I right on the money?", bkpinfo->media_device); 2381 2388 if (!ask_me_yes_or_no(tmp)) { 2382 bkpinfo->media_device[0] = '\0';2389 mr_free(bkpinfo->media_device); 2383 2390 } 2384 2391 mr_free(tmp); 2385 2392 } 2386 if (!bkpinfo->media_device[0]) { 2387 if (!popup_and_get_string("Device name?", "What is the /dev entry of your tape streamer?", bkpinfo->media_device,(MAX_STR_LEN / 4)-1)) { 2393 if (bkpinfo->media_device == NULL) { 2394 tmp2 = popup_and_get_string("Device name?", "What is the /dev entry of your tape streamer?", bkpinfo->media_device,(MAX_STR_LEN / 4)-1); 2395 if (tmp2 == NULL) { 2388 2396 log_to_screen("User has chosen not to backup the machine"); 2389 2397 finish(1); 2398 } else { 2399 mr_free(bkpinfo->media_device); 2400 bkpinfo->media_device = tmp2; 2390 2401 } 2391 2402 } … … 2736 2747 finish(1); 2737 2748 } 2738 mr_asprint (bkpinfo->image_devs, "%s", tmp1);2749 mr_asprintf(bkpinfo->image_devs, "%s", tmp1); 2739 2750 } 2740 2751 … … 3022 3033 } 3023 3034 3024 if ( !bkpinfo->media_device[0]) {3035 if (bkpinfo->media_device == NULL) { 3025 3036 log_it("ERROR: bkpinfo->media_device shoulnd't be empty here\n"); 3026 3037 return(0); -
branches/3.3/mondo/src/common/libmondo-tools.c
r3821 r3822 814 814 memset((void *) bkpinfo, 0, sizeof(struct s_bkpinfo)); 815 815 816 bkpinfo->media_device [0] = '\0';816 bkpinfo->media_device = NULL; 817 817 bkpinfo->media_size = -1; 818 818 bkpinfo->boot_loader = '\0'; -
branches/3.3/mondo/src/common/mondostructures.h
r3821 r3822 343 343 * If backup_media_type is anything else, this should be blank. 344 344 */ 345 char media_device[MAX_STR_LEN / 4];345 char *media_device; 346 346 347 347 /** -
branches/3.3/mondo/src/common/newt-specific.c
r3821 r3822 429 429 mr_free(bkpinfo->subdir); 430 430 mr_free(bkpinfo->image_devs); 431 mr_free(bkpinfo->media_device); 431 432 /* Then free the structure */ 432 433 paranoid_free(bkpinfo); -
branches/3.3/mondo/src/mondorestore/mondo-rstr-compare.c
r3613 r3822 656 656 if (bkpinfo->disaster_recovery 657 657 && does_file_exist("/tmp/CDROM-LIVES-HERE")) { 658 strcpy(bkpinfo->media_device, 659 last_line_of_file("/tmp/CDROM-LIVES-HERE")); 658 mr_asprintf(bkpinfo->media_device, "%s", last_line_of_file("/tmp/CDROM-LIVES-HERE")); 660 659 } else { 661 660 find_cdrom_device(bkpinfo->media_device, FALSE); -
branches/3.3/mondo/src/mondorestore/mondo-rstr-tools.c
r3790 r3822 734 734 if (bkpinfo->disaster_recovery) { 735 735 if (bkpinfo->backup_media_type == cdstream) { 736 sprintf(bkpinfo->media_device, "/dev/cdrom");736 mr_asprintf(bkpinfo->media_device, "%s", "/dev/cdrom"); 737 737 bkpinfo->media_size = 650; /* good guess */ 738 738 } else if (bkpinfo->backup_media_type == usb) { … … 745 745 strcpy(value,envtmp1); 746 746 } 747 sprintf(bkpinfo->media_device, "%s1", value);747 mr_asprintf(bkpinfo->media_device, "%s1", value); 748 748 log_msg(2, "Backup medium is USB --- dev=%s", bkpinfo->media_device); 749 749 } else if (bkpinfo->backup_media_type == tape || bkpinfo->backup_media_type == udev) { … … 751 751 fatal_error("Cannot get tape device name from cfg file"); 752 752 } 753 strcpy(bkpinfo->media_device, value);753 mr_asprintf(bkpinfo->media_device, "%s", value); 754 754 read_cfg_var(cfg_file, "media-size", value); 755 755 bkpinfo->media_size = atol(value); 756 756 log_msg(2, "Backup medium is TAPE --- dev=%s", bkpinfo->media_device); 757 757 } else { 758 strcpy(bkpinfo->media_device, "/dev/cdrom"); /* we don't really need this var */758 mr_asprintf(bkpinfo->media_device, "%s", "/dev/cdrom"); /* we don't really need this var */ 759 759 bkpinfo->media_size = 1999 * 1024; /* 650, probably, but we don't need this var anyway */ 760 760 log_msg(2, "Backup medium is similar to CD-R[W]"); … … 968 968 log_msg(1, "Unable to mount isodir. Perhaps this is really a CD backup?"); 969 969 bkpinfo->backup_media_type = cdr; 970 strcpy(bkpinfo->media_device, "/dev/cdrom"); /* superfluous */970 mr_asprintf(bkpinfo->media_device, "%s", "/dev/cdrom"); /* superfluous */ 971 971 bkpinfo->isodir[0] = iso_mnt[0] = iso_path[0] = '\0'; 972 972 if (mount_media()) { … … 2160 2160 run_program_and_log_output("mkdir -p tmp", FALSE); 2161 2161 2162 if ( strlen(bkpinfo->media_device) == 0) {2163 strcpy(bkpinfo->media_device, "/dev/st0");2164 log_msg(2, "media_device is blank; assuming %s" );2162 if (bkpinfo->media_device == NULL) { 2163 mr_asprintf(bkpinfo->media_device, "%s", "/dev/st0"); 2164 log_msg(2, "media_device is blank; assuming %s", bkpinfo->media_device); 2165 2165 } 2166 2166 mr_asprintf(tmp, "%s", bkpinfo->media_device); 2167 if (extract_cfg_file_and_mountlist_from_tape_dev 2168 (bkpinfo->media_device)) { 2169 strcpy(bkpinfo->media_device, "/dev/st0"); 2170 if (extract_cfg_file_and_mountlist_from_tape_dev 2171 (bkpinfo->media_device)) { 2172 strcpy(bkpinfo->media_device, "/dev/osst0"); 2173 if (extract_cfg_file_and_mountlist_from_tape_dev 2174 (bkpinfo->media_device)) { 2175 strcpy(bkpinfo->media_device, "/dev/ht0"); 2176 if (extract_cfg_file_and_mountlist_from_tape_dev 2177 (bkpinfo->media_device)) { 2178 log_msg(3, 2179 "I tried lots of devices but none worked."); 2180 strcpy(bkpinfo->media_device, tmp); 2167 if (extract_cfg_file_and_mountlist_from_tape_dev(bkpinfo->media_device)) { 2168 mr_free(bkpinfo->media_device); 2169 mr_asprintf(bkpinfo->media_device, "%s", "/dev/st0"); 2170 if (extract_cfg_file_and_mountlist_from_tape_dev(bkpinfo->media_device)) { 2171 mr_free(bkpinfo->media_device); 2172 mr_asprintf(bkpinfo->media_device, "%s", "/dev/osst0"); 2173 if (extract_cfg_file_and_mountlist_from_tape_dev(bkpinfo->media_device)) { 2174 mr_free(bkpinfo->media_device); 2175 mr_asprintf(bkpinfo->media_device, "%s", "/dev/ht0"); 2176 if (extract_cfg_file_and_mountlist_from_tape_dev(bkpinfo->media_device)) { 2177 log_msg(3, "I tried lots of devices but none worked."); 2178 mr_free(bkpinfo->media_device); 2181 2179 } 2182 2180 } 2183 2181 } 2184 2182 } 2185 mr_free(tmp); 2183 if (bkpinfo->media_device == NULL) { 2184 bkpinfo->media_device = tmp; 2185 } else { 2186 mr_free(tmp); 2187 } 2186 2188 2187 2189 if (!does_file_exist("tmp/mondorestore.cfg")) { -
branches/3.3/mondo/src/mondorestore/mondorestore.c
r3819 r3822 2474 2474 interactively_obtain_media_parameters_from_user(FALSE); 2475 2475 } 2476 log_msg(2, "bkpinfo->media_device = %s", bkpinfo->media_device); 2477 if (!bkpinfo->media_device[0]) { 2478 log_msg(2, "Warning - failed to find media dev"); 2476 if (bkpinfo->media_device == NULL) { 2477 log_msg(2, "Warning - failed to find media_device"); 2478 } else { 2479 log_msg(2, "bkpinfo->media_device = %s", bkpinfo->media_device); 2479 2480 } 2480 2481
Note:
See TracChangeset
for help on using the changeset viewer.