Changeset 2334 in MondoRescue for branches/2.2.10/mondo/src/mondorestore
- Timestamp:
- Aug 18, 2009, 5:28:18 PM (16 years ago)
- Location:
- branches/2.2.10/mondo/src/mondorestore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/mondorestore/mondo-prep.c
r2331 r2334 192 192 char *incoming; 193 193 char *command; 194 char *lvscan_sz; 195 char *lvremove_sz; 196 char *pvscan_sz; 197 char *vgscan_sz; 198 char *vgcreate_sz; 199 char *vgchange_sz; 200 char *vgremove_sz; 201 // char *do_this_last; 194 char *lvscan_sz = NULL; 195 char *lvremove_sz = NULL; 196 char *pvscan_sz = NULL; 197 char *vgscan_sz = NULL; 198 char *vgchange_sz = NULL; 199 char *vgremove_sz = NULL; 202 200 203 201 /** char **************************************************/ … … 229 227 malloc_string(tmp); 230 228 malloc_string(incoming); 231 malloc_string(lvscan_sz); 232 malloc_string(lvremove_sz); 233 malloc_string(vgscan_sz); 234 malloc_string(pvscan_sz); 235 malloc_string(vgcreate_sz); 236 malloc_string(vgchange_sz); 237 malloc_string(vgremove_sz); 238 command = malloc(512); 229 command = malloc(1024); 239 230 240 231 log_it("STARTING"); … … 243 234 if (tmp1) // found it :) cool 244 235 { 245 strcpy(lvscan_sz, "lvm lvscan"); 246 strcpy(lvremove_sz, "lvm lvremove"); 247 strcpy(vgscan_sz, "lvm vgscan"); 248 strcpy(pvscan_sz, "lvm pvscan"); 249 strcpy(vgcreate_sz, "lvm vgcreate"); 250 strcpy(vgchange_sz, "lvm vgchange"); 251 strcpy(vgremove_sz, "lvm vgremove -f"); 236 mr_asprintf(lvscan_sz, "lvm lvscan"); 237 mr_asprintf(lvremove_sz, "lvm lvremove"); 238 mr_asprintf(vgscan_sz, "lvm vgscan"); 239 mr_asprintf(pvscan_sz, "lvm pvscan"); 240 mr_asprintf(vgchange_sz, "lvm vgchange"); 241 mr_asprintf(vgremove_sz, "lvm vgremove -f"); 252 242 } else { 253 strcpy(lvscan_sz, "lvscan"); 254 strcpy(lvremove_sz, "lvremove"); 255 strcpy(vgscan_sz, "vgscan"); 256 strcpy(pvscan_sz, "pvscan"); 257 strcpy(vgcreate_sz, "vgcreate"); 258 strcpy(vgchange_sz, "vgchange"); 259 strcpy(vgremove_sz, "vgremove"); 243 mr_asprintf(lvscan_sz, "lvscan"); 244 mr_asprintf(lvremove_sz, "lvremove"); 245 mr_asprintf(vgscan_sz, "vgscan"); 246 mr_asprintf(pvscan_sz, "pvscan"); 247 mr_asprintf(vgchange_sz, "vgchange"); 248 mr_asprintf(vgremove_sz, "vgremove"); 260 249 } 261 250 mr_free(tmp1); 262 251 263 252 mr_asprintf(tmp1, "for i in `%s | cut -d\"'\" -f2 | sort -r` ; do echo \"Shutting down lv $i\" >> %s ; %s -f $i; done", lvscan_sz, MONDO_LOGFILE, lvremove_sz); 253 mr_free(lvscan_sz); 254 mr_free(lvremove_sz); 255 264 256 run_program_and_log_output(tmp1, 5); 265 257 mr_free(tmp1); 266 258 267 259 sleep(1); 268 sprintf(command, 269 "for i in `%s | grep -i lvm | cut -d'\"' -f2` ; do %s -a n $i ; %s $i; echo \"Shutting down vg $i\" >> %s ; done", vgscan_sz, vgchange_sz, vgremove_sz, MONDO_LOGFILE); 260 sprintf(command, "for i in `%s | grep -i lvm | cut -d'\"' -f2` ; do %s -a n $i ; %s $i; echo \"Shutting down vg $i\" >> %s ; done", vgscan_sz, vgchange_sz, vgremove_sz, MONDO_LOGFILE); 261 mr_free(vgchange_sz); 262 mr_free(vgremove_sz); 263 270 264 run_program_and_log_output(command, 5); 271 265 if (just_erase_existing_volumes) { … … 401 395 sleep(1); 402 396 } 397 mr_free(vgscan_sz); 398 mr_free(pvscan_sz); 399 403 400 paranoid_fclose(fin); 404 401 log_msg(1, "Closed i-want-my-lvm. Finished doing funky stuff."); … … 407 404 paranoid_free(incoming); 408 405 paranoid_free(command); 409 paranoid_free(lvscan_sz);410 paranoid_free(lvremove_sz);411 paranoid_free(vgscan_sz);412 paranoid_free(pvscan_sz);413 paranoid_free(vgcreate_sz);414 paranoid_free(vgchange_sz);415 paranoid_free(vgremove_sz);416 406 system("sync"); 417 407 system("sync"); … … 829 819 830 820 if (res && strstr(program, "kludge")) { 831 mr_asprintf( &tmp, "Kludge failed; using regular mkfs.%s to format %s", format, device);821 mr_asprintf(tmp, "Kludge failed; using regular mkfs.%s to format %s", format, device); 832 822 mr_free(program); 833 823 #ifdef __FreeBSD__ … … 895 885 896 886 assert(mountlist != NULL); 897 mr_asprintf(tmp, "format_everything (mountlist, interactively = %s", (interactively) ? "true" : "false"); 898 log_it(tmp); 899 mr_free(tmp); 887 log_it("format_everything (mountlist, interactively = %s", (interactively) ? "true" : "false"); 900 888 901 889 mvaddstr_and_log_it(g_currentY, 0, "Formatting partitions "); … … 1423 1411 /** buffers *********************************************************/ 1424 1412 char *device_str = NULL; 1425 char *format ;1413 char *format = NULL; 1426 1414 char *tmp = NULL; 1427 1415 … … 1430 1418 assert(mountlist != NULL); 1431 1419 assert_string_is_neither_NULL_nor_zerolength(drivename); 1432 1433 malloc_string(format);1434 1420 1435 1421 log_it("Partitioning drive %s", drivename); … … 1445 1431 if (!pout_to_fdisk) { 1446 1432 log_to_screen("Cannot call parted2fdisk to configure %s", drivename); 1447 paranoid_free(format);1448 1433 return (1); 1449 1434 } … … 1480 1465 mr_free(command); 1481 1466 mr_free(device_str); 1482 paranoid_free(format);1483 1467 return r; 1484 1468 } … … 1495 1479 int i, line; 1496 1480 1497 strcpy(format, "ufs");1481 mr_asprintf(format, "ufs"); 1498 1482 partsize = 0; 1499 1483 for (i = 'a'; i < 'z'; ++i) { … … 1552 1536 #ifdef __FreeBSD__ 1553 1537 if (!fbsd_part) { 1554 #endif 1555 1556 strcpy(format, mountlist->el[lino].format); 1538 mr_free(format); 1539 #endif 1540 1541 mr_asprintf(format, "%s", mountlist->el[lino].format); 1557 1542 partsize = mountlist->el[lino].size; 1558 1543 … … 1566 1551 ("You must leave at least one partition spare as the Extended partition."); 1567 1552 mr_free(device_str); 1568 paranoid_free(format);1553 mr_free(format); 1569 1554 return (1); 1570 1555 } 1571 1556 #endif 1572 1557 1573 retval += 1574 partition_device(pout_to_fdisk, drivename, current_devno, 1575 previous_devno, format, partsize); 1558 retval += partition_device(pout_to_fdisk, drivename, current_devno, previous_devno, format, partsize); 1559 mr_free(format); 1576 1560 1577 1561 #ifdef __FreeBSD__ … … 1626 1610 } 1627 1611 } 1628 paranoid_free(format);1629 1612 return (retval); 1630 1613 } … … 1978 1961 mr_asprintf(partcode, ""); 1979 1962 } else if (strlen(format) >= 1 && strlen(format) <= 2) { 1980 mr_asprintf(partcode, format);1963 mr_asprintf(partcode, "%s", format); 1981 1964 } else { 1982 1965 /* probably an image */ … … 1985 1968 mr_free(tmp); 1986 1969 #ifdef __FreeBSD__ 1987 mr_asprintf(partcode, format); // was a51970 mr_asprintf(partcode, "%s", format); // was a5 1988 1971 #else 1989 mr_asprintf(partcode, format); // was 831972 mr_asprintf(partcode, "%s", format); // was 83 1990 1973 #endif 1991 1974 } … … 2260 2243 2261 2244 /** buffers *********************************************************/ 2262 char *tmp = NULL;2263 2245 char *program = NULL; 2264 2246 … … 2311 2293 mr_asprintf(program, "mkfs -t %s -c", format); // -c checks for bad blocks 2312 2294 #endif 2313 mr_asprintf(tmp, "Unknown format (%s) - assuming '%s' will do", format, program); 2314 log_it(tmp); 2315 mr_free(tmp); 2295 log_it("Unknown format (%s) - assuming '%s' will do", format, program); 2316 2296 res = 0; 2317 2297 } -
branches/2.2.10/mondo/src/mondorestore/mondo-rstr-compare.c
r2332 r2334 43 43 44 44 /** needs malloc *******/ 45 char *checksum_ptr ;46 char *original_cksum_ptr ;47 char *bigfile_fname_ptr ;45 char *checksum_ptr = NULL; 46 char *original_cksum_ptr = NULL; 47 char *bigfile_fname_ptr = NULL; 48 48 char *tmp_ptr = NULL; 49 49 char *command_ptr = NULL; 50 50 51 char *checksum, * original_cksum, *bigfile_fname, *tmp, *command;51 char *checksum, *bigfile_fname, *tmp, *command; 52 52 53 53 char *p; … … 58 58 59 59 malloc_string(checksum); 60 malloc_string(original_cksum);61 60 malloc_string(bigfile_fname); 62 61 malloc_string(tmp); 63 62 malloc_string(command); 64 malloc_string(checksum_ptr);65 malloc_string(original_cksum_ptr);66 malloc_string(bigfile_fname_ptr);67 63 68 64 /********************************************************************* … … 70 66 *********************************************************************/ 71 67 assert(bkpinfo != NULL); 72 memset(checksum_ptr, '\0', sizeof(checksum));73 memset(original_cksum_ptr, '\0', sizeof(original_cksum));74 memset(bigfile_fname_ptr, '\0', sizeof(bigfile_fname));75 68 /** end **/ 76 69 … … 84 77 } 85 78 if (!(fin = fopen(slice_fname(bigfileno, 0, ARCHIVES_PATH, ""), "r"))) { 86 log_to_screen("Cannot open bigfile %ld ( %s)'s info file", bigfileno + 1, bigfile_fname_ptr);79 log_to_screen("Cannot open bigfile %ld (NULL)'s info file", bigfileno + 1); 87 80 return (1); 88 81 } … … 90 83 paranoid_fclose(fin); 91 84 92 strcpy(checksum_ptr, biggiestruct.checksum);93 strcpy(bigfile_fname_ptr, biggiestruct.filename);85 mr_asprintf(checksum_ptr, "%s", biggiestruct.checksum); 86 mr_asprintf(bigfile_fname_ptr, "%s", biggiestruct.filename); 94 87 95 88 log_msg(2, "biggiestruct.filename = %s", biggiestruct.filename); … … 106 99 } 107 100 if (!strncmp(bigfile_fname_ptr, "/dev/", 5)) { 108 strcpy(original_cksum_ptr, "IGNORE");109 101 log_msg(2, "IGNORING %s as begining with /dev", bigfile_fname_ptr); 102 mr_free(bigfile_fname_ptr); 110 103 return (1); 111 104 } … … 122 115 if (i) { 123 116 log_OS_error("Warning - command failed"); 124 original_cksum[0] = '\0';125 117 return (1); 126 118 } else { … … 128 120 log_msg(2, 129 121 "Unable to open /tmp/md5sum.txt; can't get live checksum"); 130 original_cksum[0] = '\0';122 mr_free(bigfile_fname_ptr); 131 123 return (1); 132 124 } else { 133 fgets(original_cksum_ptr, MAX_STR_LEN - 1, fin);125 mr_getline(original_cksum_ptr, fin); 134 126 paranoid_fclose(fin); 135 for (i = strlen(original_cksum_ptr); 136 i > 0 && original_cksum[i - 1] < 32; i--); 137 original_cksum[i] = '\0'; 138 p = (char *) strchr(original_cksum_ptr, ' '); 127 p = strchr(original_cksum_ptr, ' '); 139 128 if (p) { 140 129 *p = '\0'; … … 143 132 } 144 133 mr_asprintf(tmp_ptr, "bigfile #%ld ('%s') ", bigfileno + 1, bigfile_fname_ptr); 145 if ( !strcmp(checksum_ptr, original_cksum_ptr) != 0) {134 if ((original_cksum_ptr != NULL) && (strcmp(checksum_ptr, original_cksum_ptr) == 0)) { 146 135 mr_strcat(tmp_ptr, " ... OK"); 147 136 } else { … … 149 138 retval++; 150 139 } 140 mr_free(checksum_ptr); 141 mr_free(original_cksum_ptr); 142 151 143 log_msg(1, tmp_ptr); 152 144 paranoid_free(tmp_ptr); … … 159 151 paranoid_fclose(fout); 160 152 } 161 162 paranoid_free(original_cksum_ptr); 163 paranoid_free(original_cksum); 164 paranoid_free(bigfile_fname_ptr); 153 mr_free(bigfile_fname_ptr); 154 165 155 paranoid_free(bigfile_fname); 166 paranoid_free(checksum_ptr);167 156 paranoid_free(checksum); 168 157 paranoid_free(command); … … 365 354 /** needs malloc **********/ 366 355 367 char *tarball_fname, *progress_str; 356 char *tarball_fname = NULL; 357 char *progress_str = NULL; 368 358 char *tmp = NULL; 369 359 char *mds = NULL; … … 443 433 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 444 434 } 445 paranoid_free(tarball_fname);446 paranoid_free(progress_str);447 435 return (retval); 448 436 } -
branches/2.2.10/mondo/src/mondorestore/mondo-rstr-newt.c
r2332 r2334 78 78 newtPushHelpLine 79 79 (" Add one of the following unallocated RAID partitions to this RAID device."); 80 mr_asprintf( &tmp, "%-26s %s", "Device", "Size");80 mr_asprintf(tmp, "%-26s %s", "Device", "Size"); 81 81 headerMsg = newtLabel(1, 1, tmp); 82 82 partitionsListbox = … … 104 104 105 105 items = disklist->entries; 106 strcpy(disklist->el[items].device, 107 unallocated_raid_partitions->el[currline].device); 106 strcpy(disklist->el[items].device, unallocated_raid_partitions->el[currline].device); 108 107 disklist->el[items].index = index; 109 108 disklist->entries = ++items; … … 154 153 155 154 /** buffers **********************************************************/ 156 char drive_to_add[MAX_STR_LEN];157 char mountpoint_str[MAX_STR_LEN];158 char size_str[MAX_STR_LEN];159 char device_str[MAX_STR_LEN];160 char format_str[MAX_STR_LEN];155 char *drive_to_add = NULL; 156 char *mountpoint_str = NULL; 157 char *size_str = NULL; 158 char *device_str = NULL; 159 char *format_str = NULL; 161 160 162 161 /** pointers *********************************************************/ … … 171 170 assert(keylist != NULL); 172 171 173 strcpy(device_str, "/dev/"); 174 strcpy(mountpoint_str, "/"); 172 mr_asprintf(device_str, "/dev/"); 173 mr_asprintf(mountpoint_str, "/"); 174 mr_asprintf(size_str, ""); 175 175 #ifdef __FreeBSD__ 176 strcpy(format_str, "ufs");176 mr_asprintf(format_str, "ufs"); 177 177 #else 178 strcpy(format_str, "ext3");178 mr_asprintf(format_str, "ext3"); 179 179 #endif 180 size_str[0] = '\0';181 180 newtOpenWindow(20, 5, 48, 10, "Add entry"); 182 181 label0 = newtLabel(2, 1, "Device: "); … … 184 183 label2 = newtLabel(2, 3, "Size (MB): "); 185 184 label3 = newtLabel(2, 4, "Format: "); 186 deviceComp = 187 newtEntry(14, 1, device_str, 30, (void *) &device_here, 0); 188 mountpointComp = 189 newtEntry(14, 2, mountpoint_str, 30, (void *) &mountpoint_here, 0); 190 formatComp = 191 newtEntry(14, 4, format_str, 15, (void *) &format_here, 0); 185 deviceComp = newtEntry(14, 1, device_str, 30, (void *) &device_here, 0); 186 mountpointComp = newtEntry(14, 2, mountpoint_str, 30, (void *) &mountpoint_here, 0); 187 formatComp = newtEntry(14, 4, format_str, 15, (void *) &format_here, 0); 192 188 sizeComp = newtEntry(14, 3, size_str, 10, (void *) &size_here, 0); 193 189 bOK = newtButton(5, 6, " OK "); … … 201 197 for (b_res = NULL; b_res != bOK && b_res != bCancel;) { 202 198 b_res = newtRunForm(myForm); 203 strcpy(device_str, device_here); 204 strcpy(mountpoint_str, mountpoint_here); 205 strcpy(format_str, format_here); 206 strcpy(size_str, size_here); 207 // log_it ("Originals = %s,%s,%s,%s", device_str, mountpoint_str, format_str, size_str); 199 mr_free(device_str); 200 mr_asprintf(device_str, "%s", device_here); 201 202 mr_free(mountpoint_str); 203 mr_asprintf(mountpoint_str, "%s", mountpoint_here); 204 mr_strip_spaces(mountpoint_str); 205 206 mr_free(format_str); 207 mr_asprintf(format_str, "%s", format_here); 208 mr_strip_spaces(format_str); 209 210 mr_free(size_str); 211 mr_asprintf(size_str, "%s", size_here); 212 mr_strip_spaces(size_str); 213 208 214 strip_spaces(device_str); 209 strip_spaces(mountpoint_str);210 strip_spaces(format_str);211 strip_spaces(size_str);212 // log_it ("Modified = %s,%s,%s,%s", device_str, mountpoint_str, format_str, size_str);213 215 if (b_res == bOK) { 214 216 if (device_str[strlen(device_str) - 1] == '/') { … … 216 218 b_res = NULL; 217 219 } 218 if (size_of_specific_device_in_mountlist(mountlist, device_str) 219 >= 0) { 220 if (size_of_specific_device_in_mountlist(mountlist, device_str) >= 0) { 220 221 popup_and_OK("Can't add this - you've got one already!"); 221 222 b_res = NULL; … … 229 230 return; 230 231 } 231 strcpy(drive_to_add, device_str);232 mr_asprintf(drive_to_add, "%s", device_str); 232 233 for (i = strlen(drive_to_add); isdigit(drive_to_add[i - 1]); i--); 233 234 num_to_add = atoi(drive_to_add + i); 234 drive_to_add[i] = '\0'; 235 mr_free(drive_to_add); 236 235 237 currline = mountlist->entries; 236 238 strcpy(mountlist->el[currline].device, device_str); 237 239 strcpy(mountlist->el[currline].mountpoint, mountpoint_str); 240 mr_free(mountpoint_str); 241 238 242 strcpy(mountlist->el[currline].format, format_str); 243 mr_free(format_str); 244 239 245 mountlist->el[currline].size = atol(size_str) * 1024L; 246 mr_free(size_str); 247 240 248 mountlist->entries++; 241 249 if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)) { 242 initiate_new_raidlist_entry(raidlist, mountlist, currline, 243 device_str); 244 } 250 initiate_new_raidlist_entry(raidlist, mountlist, currline, device_str); 251 } 252 mr_free(device_str); 253 245 254 redraw_mountlist(mountlist, keylist, listbox); 246 255 } … … 316 325 /** buffers ***********************************************************/ 317 326 char tmp = NULL; 318 319 320 327 char *devname = NULL; 321 328 322 329 for (i = 0; … … 324 331 && strcmp(raidlist->el[i].volname, basename(raid_device)); i++); 325 332 if (i == raidlist->entries) { 326 mr_asprintf(&tmp, "Cannot calc size of raid device %s - cannot find it in raidlist", raid_device); 327 log_it(tmp); 328 mr_free(tmp); 333 log_it("Cannot calc size of raid device %s - cannot find it in raidlist", raid_device); 329 334 return (0); // Isn't this more sensible than 999999999? If the raid dev !exists, 330 335 // then it has no size, right? … … 338 343 int k = 0, l = 0; 339 344 for (k = 0; k < raidrec->plex[j].subdisks; ++k) { 340 char devname[64]; 341 strcpy(devname, raidrec->plex[j].sd[k].which_device); 345 mr_asprintf(devname, "%s", raidrec->plex[j].sd[k].which_device); 342 346 for (l = 0; l < raidlist->disks.entries; ++l) { 343 347 if (!strcmp(devname, raidlist->disks.el[l].name)) { … … 367 371 } 368 372 } 373 mr_free(devname); 369 374 } 370 375 … … 387 392 } 388 393 389 mr_asprintf(&tmp, "I have calculated %s's real size to be %ld", raid_device, (long) smallest_plex); 390 log_it(tmp); 391 mr_free(tmp); 394 log_it("I have calculated %s's real size to be %ld", raid_device, (long) smallest_plex); 392 395 return (smallest_plex); 393 396 #else … … 406 409 long sp = 0; 407 410 408 /** buffers ***********************************************************/409 char tmp = NULL;410 411 411 assert(mountlist != NULL); 412 412 assert(raidlist != NULL); … … 417 417 && strcmp(raidlist->el[i].raid_device, raid_device); i++); 418 418 if (i == raidlist->entries) { 419 mr_asprintf(&tmp, "Cannot calc size of raid device %s - cannot find it in raidlist", raid_device); 420 log_it(tmp); 421 mr_free(tmp); 419 log_it("Cannot calc size of raid device %s - cannot find it in raidlist", raid_device); 422 420 return (999999999); 423 421 } … … 442 440 total_size = smallest_partition * (noof_partitions - 1); 443 441 } 444 mr_asprintf(&tmp, "I have calculated %s's real size to be %ld", raid_device, (long) total_size); 445 log_it(tmp); 446 mr_free(tmp); 442 log_it("I have calculated %s's real size to be %ld", raid_device, (long) total_size); 447 443 return (total_size); 448 444 #endif … … 499 495 } 500 496 p[i] = '\0'; 501 mr_free(sz);502 497 } 503 498 if (!strcmp(p, "concat")) { … … 568 563 } 569 564 p[i] = '\0'; 570 mr_free(sz);571 565 } 572 566 if (!strcmp(p, "linear")) { … … 613 607 614 608 /** buffers ***********************************************************/ 615 char *tmp = NULL;616 617 609 assert(mountlist != NULL); 618 610 assert(raidlist != NULL); … … 625 617 pos++); 626 618 if (pos < mountlist->entries) { 627 mr_asprintf(&tmp, "Deleting partition %s cos it was part of a now-defunct RAID", mountlist->el[pos].device); 628 log_it(tmp); 629 mr_free(tmp); 619 log_it("Deleting partition %s cos it was part of a now-defunct RAID", mountlist->el[pos].device); 630 620 631 621 memcpy((void *) &mountlist->el[pos], … … 662 652 assert_string_is_neither_NULL_nor_zerolength(raid_device); 663 653 664 mr_asprintf( &tmp, "Delete %s from RAID device %s - are you sure?", disklist->el[currline].device, raid_device);654 mr_asprintf(tmp, "Delete %s from RAID device %s - are you sure?", disklist->el[currline].device, raid_device); 665 655 res = ask_me_yes_or_no(tmp); 666 656 mr_free(tmp); … … 699 689 /** buffers ***********************************************************/ 700 690 char *tmp = NULL; 701 char device[MAX_STR_LEN];691 char *device = NULL; 702 692 703 693 … … 707 697 assert(keylist != NULL); 708 698 709 /* BERLIOS: Why isn't device initialized here ? what is expected */ 710 pos = 711 which_raid_device_is_using_this_partition(raidlist, 712 mountlist->el[currline]. 713 device); 699 pos = which_raid_device_is_using_this_partition(raidlist, mountlist->el[currline].device); 714 700 if (pos >= 0) { 715 mr_asprintf( &tmp, "Cannot delete %s: it is in use by RAID device %s", mountlist->el[currline].device, raidlist->el[pos].OSSWAP(raid_device, volname));701 mr_asprintf(tmp, "Cannot delete %s: it is in use by RAID device %s", mountlist->el[currline].device, raidlist->el[pos].OSSWAP(raid_device, volname)); 716 702 popup_and_OK(tmp); 717 703 mr_free(tmp); 718 704 return; 719 705 } 720 mr_asprintf( &tmp, "Delete %s - are you sure?", mountlist->el[currline].device);706 mr_asprintf(tmp, "Delete %s - are you sure?", mountlist->el[currline].device); 721 707 res = ask_me_yes_or_no(tmp); 722 708 mr_free(tmp); … … 726 712 } 727 713 if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)) { 728 strcpy(device, mountlist->el[currline].device);714 mr_asprintf(device, "%s", mountlist->el[currline].device); 729 715 delete_raidlist_entry(mountlist, raidlist, device); 730 716 for (currline = 0; … … 732 718 && strcmp(mountlist->el[currline].device, device); 733 719 currline++); 720 mr_free(device); 721 734 722 if (currline == mountlist->entries) { 735 723 log_it("Dev is gone. I can't delete it. Ho-hum"); … … 775 763 return; 776 764 } 777 mr_asprintf( &tmp, "Do you want me to delete %s's partitions, too?", device);765 mr_asprintf(tmp, "Do you want me to delete %s's partitions, too?", device); 778 766 delete_partitions_too = ask_me_yes_or_no(tmp); 779 767 if (delete_partitions_too) { … … 788 776 if (!strcmp(raidlist->el[i].plex[x].sd[y].which_device, 789 777 raidlist->disks.el[z].name)) { 790 strcpy(d.el[d.entries].name, 791 raidlist->disks.el[z].name); 792 strcpy(d.el[d.entries++].device, 793 raidlist->disks.el[z].device); 778 strcpy(d.el[d.entries].name, raidlist->disks.el[z].name); 779 strcpy(d.el[d.entries++].device, raidlist->disks.el[z].device); 794 780 } 795 781 } … … 844 830 845 831 av = &raidrec->additional_vars; 846 mr_asprintf( &tmp, "Delete %s - are you sure?", av->el[lino].label);832 mr_asprintf(tmp, "Delete %s - are you sure?", av->el[lino].label); 847 833 res = ask_me_yes_or_no(tmp); 848 834 mr_free(tmp); … … 851 837 if (!strcmp(av->el[lino].label, "persistent-superblock") 852 838 || !strcmp(av->el[lino].label, "chunk-size")) { 853 mr_asprintf( &tmp, "%s must not be deleted. It would be bad.", av->el[lino].label);839 mr_asprintf(tmp, "%s must not be deleted. It would be bad.", av->el[lino].label); 854 840 popup_and_OK(tmp); 855 841 mr_free(tmp); … … 920 906 if (!warned_already) { 921 907 warned_already = TRUE; 922 mr_asprintf( &tmp1, "Too many lines. Displaying first %d entries only. Close a directory to see more.", ARBITRARY_MAXIMUM);908 mr_asprintf(tmp1, "Too many lines. Displaying first %d entries only. Close a directory to see more.", ARBITRARY_MAXIMUM); 923 909 popup_and_OK(tmp1); 924 910 mr_free(tmp1); 925 911 } 926 912 } else { 927 strcpy(g_strings_of_flist_window[lines_in_flist_window], 928 current_filename); 913 strcpy(g_strings_of_flist_window[lines_in_flist_window], current_filename); 929 914 g_is_path_selected[lines_in_flist_window] = node->selected; 930 915 lines_in_flist_window++; … … 941 926 (g_strings_of_flist_window[i], 942 927 g_strings_of_flist_window[i - 1]) < 0) { 943 mr_asprintf(&tmp1, g_strings_of_flist_window[i]); 944 strcpy(g_strings_of_flist_window[i], 945 g_strings_of_flist_window[i - 1]); 928 mr_asprintf(tmp1, "%s", g_strings_of_flist_window[i]); 929 strcpy(g_strings_of_flist_window[i], g_strings_of_flist_window[i - 1]); 946 930 strcpy(g_strings_of_flist_window[i - 1], tmp1); 947 931 mr_free(tmp1); … … 1048 1032 void *curr_choice; 1049 1033 void *keylist[ARBITRARY_MAXIMUM]; 1050 1051 /** buffers ***********************************************************/1052 char *tmp = NULL;1053 1034 1054 1035 /** bool **************************************************************/ … … 1098 1079 indexno = 0; 1099 1080 } 1100 mr_asprintf(&tmp, "You selected '%s'", g_strings_of_flist_window[indexno]); 1101 log_it(tmp); 1102 mr_free(tmp); 1081 log_it("You selected '%s'", g_strings_of_flist_window[indexno]); 1103 1082 1104 1083 if (b_res == bMore) { … … 1193 1172 1194 1173 /** buffers ***********************************************************/ 1195 char device_str[MAX_STR_LEN];1196 char mountpoint_str[MAX_STR_LEN];1197 char size_str[MAX_STR_LEN];1198 char format_str[MAX_STR_LEN];1174 char *device_str = NULL; 1175 char *mountpoint_str = NULL; 1176 char *size_str = NULL; 1177 char *format_str = NULL; 1199 1178 char *tmp = NULL; 1200 char device_used_to_be[MAX_STR_LEN];1201 char mountpt_used_to_be[MAX_STR_LEN];1179 char *device_used_to_be = NULL; 1180 char *mountpt_used_to_be = NULL; 1202 1181 1203 1182 /** pointers **********************************************************/ … … 1217 1196 memcpy((void *) &bkp_raidlist, (void *) raidlist, 1218 1197 sizeof(struct raidlist_itself)); 1219 strcpy(device_str, mountlist->el[currline].device);1220 strcpy(device_used_to_be, mountlist->el[currline].device);1221 strcpy(mountpoint_str, mountlist->el[currline].mountpoint);1222 strcpy(mountpt_used_to_be, mountlist->el[currline].mountpoint);1223 strcpy(format_str, mountlist->el[currline].format);1224 sprintf(size_str, "%lld", mountlist->el[currline].size / 1024L);1198 mr_asprintf(device_str, "%s", mountlist->el[currline].device); 1199 mr_asprintf(device_used_to_be, "%s", mountlist->el[currline].device); 1200 mr_asprintf(mountpoint_str, "%s", mountlist->el[currline].mountpoint); 1201 mr_asprintf(mountpt_used_to_be, "%s", mountlist->el[currline].mountpoint); 1202 mr_asprintf(format_str, "%s", mountlist->el[currline].format); 1203 mr_asprintf(size_str, "%lld", mountlist->el[currline].size / 1024L); 1225 1204 newtOpenWindow(20, 5, 48, 10, "Edit entry"); 1226 1205 label0 = newtLabel(2, 1, "Device:"); … … 1228 1207 label2 = newtLabel(2, 3, "Size (MB): "); 1229 1208 label3 = newtLabel(2, 4, "Format: "); 1230 deviceComp = 1231 newtEntry(14, 1, device_str, 30, (void *) &device_here, 0); 1232 mountpointComp = 1233 newtEntry(14, 2, mountpoint_str, 30, (void *) &mountpoint_here, 0); 1234 formatComp = 1235 newtEntry(14, 4, format_str, 15, (void *) &format_here, 0); 1209 deviceComp = newtEntry(14, 1, device_str, 30, (void *) &device_here, 0); 1210 mountpointComp = newtEntry(14, 2, mountpoint_str, 30, (void *) &mountpoint_here, 0); 1211 formatComp = newtEntry(14, 4, format_str, 15, (void *) &format_here, 0); 1236 1212 if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB) 1237 1213 || !strcmp(mountlist->el[currline].mountpoint, "image")) { … … 1253 1229 for (b_res = NULL; b_res != bOK && b_res != bCancel;) { 1254 1230 b_res = newtRunForm(myForm); 1255 strcpy(device_str, device_here); 1256 strip_spaces(device_str); 1257 strcpy(mountpoint_str, mountpoint_here); 1258 strip_spaces(mountpoint_str); 1259 strcpy(format_str, format_here); 1260 strip_spaces(format_str); 1231 mr_free(device_str); 1232 mr_asprintf(device_str, "%s", device_here); 1233 mr_strip_spaces(device_str); 1234 1235 mr_free(mountpoint_str); 1236 mr_asprintf(mountpoint_str, "%s", mountpoint_here); 1237 mr_strip_spaces(mountpoint_str); 1238 1239 mr_free(format_str); 1240 mr_asprintf(format_str, "%s", format_here); 1241 mr_strip_spaces(format_str); 1242 1261 1243 if (b_res == bOK && strstr(device_str, RAID_DEVICE_STUB) 1262 1244 && strstr(device_used_to_be, RAID_DEVICE_STUB) … … 1273 1255 if (!strstr(mountlist->el[currline].device, RAID_DEVICE_STUB) 1274 1256 && strcmp(mountlist->el[currline].mountpoint, "image")) { 1275 strcpy(size_str, size_here); 1276 strip_spaces(size_str); 1257 mr_free(size_str); 1258 mr_asprintf(size_str, "%s", size_here); 1259 mr_strip_spaces(size_str); 1277 1260 } else { 1278 sprintf(size_str, "%ld", 1279 calculate_raid_device_size(mountlist, raidlist, 1280 mountlist->el[currline]. 1281 device) / 1024); 1261 mr_asprintf(size_str, "%ld", calculate_raid_device_size(mountlist, raidlist, mountlist->el[currline].device) / 1024); 1282 1262 newtLabelSetText(sizeComp, size_str); 1283 1263 } … … 1296 1276 device); 1297 1277 if (j < 0) { 1298 mr_asprintf( &tmp, "/etc/raidtab does not have an entry for %s; please delete it and add it again", mountlist->el[currline].device);1278 mr_asprintf(tmp, "/etc/raidtab does not have an entry for %s; please delete it and add it again", mountlist->el[currline].device); 1299 1279 popup_and_OK(tmp); 1300 1280 mr_free(tmp); … … 1310 1290 newtPopHelpLine(); 1311 1291 newtPopWindow(); 1292 mr_free(mountpt_used_to_be); 1293 1312 1294 if (b_res == bCancel) { 1313 1295 memcpy((void *) raidlist, (void *) &bkp_raidlist, 1314 1296 sizeof(struct raidlist_itself)); 1297 mr_free(device_str); 1298 mr_free(device_used_to_be); 1299 mr_free(format_str); 1300 mr_free(size_str); 1315 1301 return; 1316 1302 } 1317 1303 strcpy(mountlist->el[currline].device, device_str); 1318 1304 strcpy(mountlist->el[currline].mountpoint, mountpoint_str); 1305 mr_free(mountpoint_str); 1306 1319 1307 strcpy(mountlist->el[currline].format, format_str); 1308 mr_free(format_str); 1309 1320 1310 if (strcmp(mountlist->el[currline].mountpoint, "image")) { 1321 1311 if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB)) { … … 1327 1317 } 1328 1318 } 1319 mr_free(size_str); 1329 1320 newtListboxSetEntry(listbox, (long) keylist[currline], 1330 1321 mountlist_entry_to_string(mountlist, currline)); … … 1332 1323 if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB) 1333 1324 && !strstr(device_used_to_be, RAID_DEVICE_STUB)) { 1334 initiate_new_raidlist_entry(raidlist, mountlist, currline, 1335 device_str); 1325 initiate_new_raidlist_entry(raidlist, mountlist, currline, device_str); 1336 1326 } 1337 1327 /* if moving from RAID to non-RAID then do funky stuff */ … … 1350 1340 #ifndef __FreeBSD__ /* It works fine under FBSD. */ 1351 1341 else if (strcmp(device_used_to_be, device_str)) { 1352 popup_and_OK 1353 ("You are renaming a RAID device as another RAID device. I don't like it but I'll allow it."); 1342 popup_and_OK("You are renaming a RAID device as another RAID device. I don't like it but I'll allow it."); 1354 1343 } 1355 1344 #endif 1345 mr_free(device_str); 1346 mr_free(device_used_to_be); 1347 1356 1348 redraw_mountlist(mountlist, keylist, listbox); 1357 1349 } … … 1376 1368 for (i = 0; i < raidlist->disks.entries; ++i) { 1377 1369 if (!strcmp(raidlist->disks.el[i].device, temp)) { 1378 strcpy(raidrec->sd[raidrec->subdisks].which_device, 1379 raidlist->disks.el[i].name); 1370 strcpy(raidrec->sd[raidrec->subdisks].which_device, raidlist->disks.el[i].name); 1380 1371 found = TRUE; 1381 1372 } … … 1494 1485 switch (raidrec->plex[i].raidlevel) { 1495 1486 case -1: 1496 mr_asprintf( &raidlevel, "concat");1487 mr_asprintf(raidlevel, "concat"); 1497 1488 break; 1498 1489 case 0: 1499 mr_asprintf( &raidlevel, "striped");1490 mr_asprintf(raidlevel, "striped"); 1500 1491 break; 1501 1492 case 5: 1502 mr_asprintf( &raidlevel, "raid5");1493 mr_asprintf(raidlevel, "raid5"); 1503 1494 break; 1504 1495 default: 1505 mr_asprintf( &raidlevel, "raid%i", raidrec->plex[i].raidlevel);1496 mr_asprintf(raidlevel, "raid%i", raidrec->plex[i].raidlevel); 1506 1497 break; 1507 1498 } 1508 1499 1509 1500 if (raidrec->plex[i].raidlevel == -1) { 1510 mr_asprintf( &chunksize, "N/A");1501 mr_asprintf(chunksize, "N/A"); 1511 1502 } else { 1512 mr_asprintf( &chunksize, "%dk", raidrec->plex[i].stripesize);1503 mr_asprintf(chunksize, "%dk", raidrec->plex[i].stripesize); 1513 1504 } 1514 1505 snprintf(pname, 64, "%s.p%i", raidrec->volname, i); … … 1540 1531 1541 1532 if (b_res == bDelete) { 1542 mr_asprintf( &msg, "Are you sure you want to delete %s.p%i?", raidrec->volname, currline2);1533 mr_asprintf(msg, "Are you sure you want to delete %s.p%i?", raidrec->volname, currline2); 1543 1534 res = ask_me_yes_or_no(msg); 1544 1535 mr_free(msg); … … 1578 1569 /** buffers ***********************************************************/ 1579 1570 char *title_of_editraidForm_window; 1580 char *sz_raid_level ;1571 char *sz_raid_level = NULL; 1581 1572 char *sz_data_disks = NULL; 1582 1573 char *sz_spare_disks = NULL; … … 1600 1591 assert(raidrec != NULL); 1601 1592 1602 malloc_string(title_of_editraidForm_window);1603 malloc_string(sz_raid_level);1604 1605 1593 bkp_raidrec = mr_malloc(sizeof(struct raid_device_record)); 1606 1594 log_it("Started edit_raidlist_entry"); 1607 1595 1608 1596 memcpy((void *) bkp_raidrec, (void *) raidrec, sizeof(struct raid_device_record)); 1609 sprintf(title_of_editraidForm_window, "%s", raidrec->raid_device);1597 mr_asprintf(title_of_editraidForm_window, "%s", raidrec->raid_device); 1610 1598 log_msg(2, "Opening newt window"); 1611 1599 newtOpenWindow(20, 5, 40, 14, title_of_editraidForm_window); 1612 1600 for (;;) { 1613 1601 log_msg(2, "Main loop"); 1614 sprintf(title_of_editraidForm_window, "Edit %s", 1615 raidrec->raid_device); 1616 strcpy(sz_raid_level, 1617 turn_raid_level_number_to_string(raidrec->raid_level)); 1602 mr_free(title_of_editraidForm_window); 1603 mr_asprintf(title_of_editraidForm_window, "Edit %s", raidrec->raid_device); 1604 mr_asprintf(sz_raid_level, "%s", turn_raid_level_number_to_string(raidrec->raid_level)); 1618 1605 /* Those 4 strings are allocated by the function */ 1619 1606 sz_data_disks = number_of_disks_as_string(raidrec->data_disks.entries, "data"); … … 1666 1653 newtPopWindow(); 1667 1654 mountlist->el[currline].size = calculate_raid_device_size(mountlist, raidlist, raidrec->raid_device); 1668 paranoid_free(title_of_editraidForm_window);1669 paranoid_free(sz_raid_level);1655 mr_free(title_of_editraidForm_window); 1656 mr_free(sz_raid_level); 1670 1657 paranoid_free(bkp_raidrec); 1671 1658 #endif … … 1715 1702 1716 1703 char *p = NULL; 1704 char *tmp = NULL; 1705 char *entry = NULL; 1717 1706 1718 1707 struct mountlist_itself *unallocparts; … … 1730 1719 for (;;) { 1731 1720 int i; 1732 char headerstr[MAX_STR_LEN];1733 char tmp[64];1734 snprintf(headerstr, MAX_STR_LEN, "%-24s %s", "Subdisk", "Device");1735 1736 1721 1737 1722 switch (raidrec->raidlevel) { 1738 1723 case -1: 1739 strcpy(tmp, "concat");1724 mr_asprintf(tmp, "concat"); 1740 1725 break; 1741 1726 case 0: 1742 strcpy(tmp, "striped");1727 mr_asprintf(tmp, "striped"); 1743 1728 break; 1744 1729 case 5: 1745 strcpy(tmp, "raid5");1730 mr_asprintf(tmp, "raid5"); 1746 1731 break; 1747 1732 default: 1748 sprintf(tmp, "unknown (%i)", raidrec->raidlevel);1733 mr_asprintf(tmp, "unknown (%i)", raidrec->raidlevel); 1749 1734 break; 1750 1735 } 1751 1736 bLevel = newtCompactButton(2, 2, " RAID level "); 1752 1737 sLevel = newtLabel(19, 2, tmp); 1738 mr_free(tmp); 1753 1739 1754 1740 if (raidrec->raidlevel >= 0) { 1755 sprintf(tmp, "%ik", raidrec->stripesize);1741 mr_asprintf(tmp, "%ik", raidrec->stripesize); 1756 1742 bStripeSize = newtCompactButton(2, 4, " Stripe size "); 1757 1743 } else { 1758 strcpy(tmp, "N/A");1744 mr_asprintf(tmp, "N/A"); 1759 1745 bStripeSize = newtLabel(2, 4, "Stripe size:"); 1760 1746 } 1761 1747 sStripeSize = newtLabel(19, 4, tmp); 1748 mr_free(tmp); 1762 1749 1763 1750 bOK = newtCompactButton(2, 16, " OK "); … … 1768 1755 1769 1756 1770 // plexesListbox = newtListbox (2, 7, 9, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT);1771 // plexesHeader = newtLabel (2, 6, headerstr);1772 1757 unallocListbox = 1773 1758 newtListbox(2, 7, 7, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT); … … 1785 1770 raidlist); 1786 1771 for (i = 0; i < ARBITRARY_MAXIMUM; ++i) { 1787 char entry[MAX_STR_LEN];1788 1772 keylist[i] = (void *) i; 1789 1773 if (i < raidrec->subdisks) { 1790 snprintf(entry, MAX_STR_LEN, "%-17s", 1791 find_dev_entry_for_raid_device_name(raidlist, 1792 raidrec-> 1793 sd[i]. 1794 which_device)); 1774 mr_asprintf(entry, "%-17s", find_dev_entry_for_raid_device_name(raidlist, raidrec->sd[i].which_device)); 1795 1775 newtListboxAppendEntry(allocListbox, entry, keylist[i]); 1776 mr_free(entry); 1796 1777 } 1797 1778 if (i < unallocparts->entries) { 1798 snprintf(entry, MAX_STR_LEN, "%-17s", 1799 unallocparts->el[i].device); 1779 mr_asprintf(entry, "%-17s", unallocparts->el[i].device); 1800 1780 newtListboxAppendEntry(unallocListbox, entry, keylist[i]); 1781 mr_free(entry); 1801 1782 } 1802 1783 } … … 1848 1829 choose_raid_level(raidrec); 1849 1830 } else if (b_res == bStripeSize) { 1850 char *tmp = NULL;1851 1852 1831 mr_asprintf(tmp, "%i", raidrec->stripesize); 1853 1832 p = popup_and_get_string("Stripe size", "Please enter the stripe size in kilobytes.", tmp); … … 1973 1952 bCancel = newtCompactButton(i += 12, 17, "Cancel"); 1974 1953 bOK = newtCompactButton(i += 12, 17, " OK "); 1975 mr_asprintf( &tmp, "%-24s %-24s %-8s %s", "Device", "Mountpoint", "Format", "Size (MB)");1954 mr_asprintf(tmp, "%-24s %-24s %-8s %s", "Device", "Mountpoint", "Format", "Size (MB)"); 1976 1955 headerMsg = newtLabel(2, 1, tmp); 1977 1956 flawsLabelA = newtLabel(2, 13, flaws_str_A); … … 2238 2217 #ifdef __FreeBSD__ 2239 2218 for (i = 0; i < raidlist->entries; i++) { 2240 mr_asprintf( &vdev, "/dev/vinum/%s", raidlist->el[i].volname);2219 mr_asprintf(vdev, "/dev/vinum/%s", raidlist->el[i].volname); 2241 2220 res = strcmp(device, vdev); 2242 2221 mr_free(vdev); … … 2365 2344 raidrec = &raidlist->el[pos_in_raidlist]; 2366 2345 initialize_raidrec(raidrec); 2367 strcpy(raidrec->OSSWAP(raid_device, volname), 2368 OSSWAP(device, basename(device))); 2346 strcpy(raidrec->OSSWAP(raid_device, volname), OSSWAP(device, basename(device))); 2369 2347 #ifndef __FreeBSD__ 2370 2348 choose_raid_level(raidrec); … … 2618 2596 char *new_dev) 2619 2597 { 2620 /** buffers ********************************************************/2621 char *tmp = NULL;2622 2623 2598 /** int ************************************************************/ 2624 2599 int pos = 0; … … 2631 2606 pos = which_raid_device_is_using_this_partition(raidlist, old_dev); 2632 2607 if (pos < 0) { 2633 mr_asprintf(&tmp, "No need to rejig %s in raidlist: it's not listed.", old_dev); 2634 log_it(tmp); 2635 mr_free(tmp); 2608 log_it("No need to rejig %s in raidlist: it's not listed.", old_dev); 2636 2609 } else { 2637 2610 if ((j = … … 2639 2612 OSSWAP(el[pos].data_disks, disks), 2640 2613 old_dev)) >= 0) { 2641 strcpy(raidlist->OSSWAP(el[pos].data_disks, disks).el[j]. 2642 device, new_dev); 2614 strcpy(raidlist->OSSWAP(el[pos].data_disks, disks).el[j].device, new_dev); 2643 2615 } else 2644 2616 if ((j = … … 2647 2619 spares), 2648 2620 old_dev)) >= 0) { 2649 strcpy(raidlist->OSSWAP(el[pos].spare_disks, spares).el[j]. 2650 device, new_dev); 2621 strcpy(raidlist->OSSWAP(el[pos].spare_disks, spares).el[j].device, new_dev); 2651 2622 } 2652 2623 #ifndef __FreeBSD__ … … 2665 2636 #endif 2666 2637 else { 2667 mr_asprintf(&tmp, "%s is supposed to be listed in this raid dev but it's not...", old_dev); 2668 log_it(tmp); 2669 mr_free(tmp); 2638 log_it("%s is supposed to be listed in this raid dev but it's not...", old_dev); 2670 2639 } 2671 2640 } -
branches/2.2.10/mondo/src/mondorestore/mondo-rstr-tools.c
r2332 r2334 206 206 { 207 207 208 /** needs malloc **/209 208 char *command = NULL; 210 char *file ;211 char *tmp ;209 char *file = NULL; 210 char *tmp = NULL; 212 211 int res; 213 212 214 malloc_string(file);215 malloc_string(tmp);216 213 assert_string_is_neither_NULL_nor_zerolength(f); 217 214 assert_string_is_neither_NULL_nor_zerolength(list_fname); … … 219 216 220 217 if (strncmp(preamble, f, strlen(preamble)) == 0) { 221 strcpy(file, f + strlen(preamble));218 mr_asprintf(file, "%s", f + strlen(preamble)); 222 219 } else { 223 strcpy(file, f);220 mr_asprintf(file, "%s", f); 224 221 } 225 222 if (file[0] == '/' && file[1] == '/') { 226 strcpy(tmp, file); 227 strcpy(file, tmp + 1); 223 mr_asprintf(tmp, "%s", file); 224 mr_free(file); 225 226 mr_asprintf(file, "%s", tmp + 1); 227 mr_free(tmp); 228 228 } 229 229 log_msg(2, "Checking to see if f=%s, file=%s, is in the list of biggiefiles", f, file); 230 230 mr_asprintf(command, "grep -E '^%s$' %s", file, list_fname); 231 mr_free(file); 232 231 233 res = run_program_and_log_output(command, FALSE); 232 234 mr_free(command); 233 paranoid_free(file);234 mr_free(tmp);235 235 if (res) { 236 236 return (FALSE); … … 429 429 } 430 430 if (res) { 431 log_msg(1, "Unable to mount device %s (type %s) at %s", device, 432 format, mountdir); 431 log_msg(1, "Unable to mount device %s (type %s) at %s", device, format, mountdir); 433 432 log_msg(1, "command was '%s'", command); 434 433 if (!strcmp(mountpoint, "swap")) { … … 479 478 char *tmp = NULL; 480 479 char *these_failed = NULL; 481 char *format;482 480 struct mountlist_itself *mountlist = NULL; 483 484 malloc_string(format);485 481 486 482 assert(p_external_copy_of_mountlist != NULL); … … 511 507 update_progress_form(tmp); 512 508 mr_free(tmp); 513 strcpy(format, mountlist->el[lino].format); 514 res = mount_device(mountlist->el[lino].device, 515 mountlist->el[lino].mountpoint, 516 format, writeable); 509 res = mount_device(mountlist->el[lino].device, mountlist->el[lino].mountpoint, mountlist->el[lino].format, writeable); 510 517 511 retval += res; 518 512 if (res) { … … 556 550 run_program_and_log_output("df -m", 3); 557 551 paranoid_free(mountlist); 558 paranoid_free(format);559 552 return (retval); 560 553 } … … 728 721 char *iso_path = NULL; 729 722 char *old_isodir = NULL; 730 char cfg_file[100];723 char *cfg_file = NULL; 731 724 t_bkptype media_specified_by_user; 732 725 … … 736 729 737 730 if (!cfgf) { 738 strcpy(cfg_file, g_mondo_cfg_file);731 cfg_file = g_mondo_cfg_file; 739 732 } else { 740 strcpy(cfg_file, cfgf);733 cfg_file = cfgf; 741 734 } 742 735 … … 1495 1488 char *conffile; 1496 1489 char *tmp = NULL; 1497 char *editor ;1490 char *editor = NULL; 1498 1491 char *p = NULL; 1499 1492 … … 1501 1494 bool done; 1502 1495 1503 malloc_string(editor);1504 1496 malloc_string(rootdev); 1505 1497 malloc_string(rootdrive); 1506 1498 malloc_string(conffile); 1507 1499 assert_string_is_neither_NULL_nor_zerolength(bd); 1508 strcpy(editor, find_my_editor());1509 1500 mr_asprintf(boot_device, "%s", bd); 1510 1501 … … 1544 1535 newtSuspend(); 1545 1536 } 1537 mr_asprintf(editor, "%s", find_my_editor()); 1538 1546 1539 mr_asprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor); 1547 1540 paranoid_system(tmp); … … 1559 1552 paranoid_system(tmp); 1560 1553 mr_free(tmp); 1554 mr_free(editor); 1561 1555 1562 1556 if (!g_text_mode) { … … 1611 1605 paranoid_free(rootdrive); 1612 1606 paranoid_free(conffile); 1613 paranoid_free(editor);1614 1607 1615 1608 return (res); … … 1631 1624 char *command = NULL; 1632 1625 char *tmp = NULL; 1633 char *editor ;1626 char *editor = NULL; 1634 1627 1635 1628 int res; 1636 1629 int done; 1637 1630 1638 malloc_string(editor);1639 strcpy(editor, find_my_editor());1640 1631 if (offer_to_run_stabelilo 1641 1632 && ask_me_yes_or_no("Did you change the mountlist or cloned the system ?")) … … 1657 1648 newtSuspend(); 1658 1649 } 1650 mr_asprintf(editor, "%s", find_my_editor()); 1651 1659 1652 mr_asprintf(tmp, "chroot %s %s /etc/fstab", MNT_RESTORING, editor); 1660 1653 paranoid_system(tmp); … … 1664 1657 paranoid_system(tmp); 1665 1658 mr_free(tmp); 1659 1660 mr_free(editor); 1666 1661 1667 1662 if (!g_text_mode) { … … 1682 1677 res = TRUE; 1683 1678 } 1684 paranoid_free(editor);1685 1679 return (res); 1686 1680 } … … 1701 1695 char *command = NULL; 1702 1696 char *tmp = NULL; 1703 char *editor ;1697 char *editor = NULL; 1704 1698 1705 1699 int res; 1706 1700 int done; 1707 1701 bool run_lilo_M = FALSE; 1708 malloc_string(editor);1709 1702 1710 1703 if (!run_program_and_log_output … … 1713 1706 } 1714 1707 1715 strcpy(editor, find_my_editor());1716 1708 if (offer_to_run_stablilo 1717 1709 && ask_me_yes_or_no("Did you change the mountlist or cloned the system ?")) … … 1733 1725 newtSuspend(); 1734 1726 } 1727 mr_asprintf(editor, "%s", find_my_editor()); 1728 1735 1729 mr_asprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1736 1730 paranoid_system(tmp); … … 1740 1734 paranoid_system(tmp); 1741 1735 mr_free(tmp); 1736 1737 mr_free(editor); 1742 1738 1743 1739 if (!g_text_mode) { … … 1795 1791 " lilo -M /dev/sda", 3); 1796 1792 } 1797 paranoid_free(editor);1798 1793 return (res); 1799 1794 } … … 1821 1816 int done; 1822 1817 1823 malloc_string(editor);1824 1818 assert_string_is_neither_NULL_nor_zerolength(bd); 1825 1819 1826 strcpy(editor, find_my_editor());1827 1820 mr_asprintf(boot_device, "%s", bd); 1828 1821 … … 1838 1831 newtSuspend(); 1839 1832 } 1833 mr_asprintf(editor, "%s", find_my_editor()); 1840 1834 mr_asprintf(tmp, "%s " MNT_RESTORING "/etc/fstab", editor); 1835 mr_free(editor); 1836 1841 1837 paranoid_system(tmp); 1842 1838 mr_free(tmp); … … 1884 1880 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 1885 1881 } 1886 paranoid_free(editor);1887 1882 return (res); 1888 1883 } -
branches/2.2.10/mondo/src/mondorestore/mondorestore.c
r2331 r2334 443 443 char *p = NULL; 444 444 char *tmp1 = NULL; 445 char *fstab_fname ;445 char *fstab_fname = NULL; 446 446 char *old_restpath = NULL; 447 447 … … 453 453 454 454 malloc_string(tmp); 455 malloc_string(fstab_fname);456 455 assert(bkpinfo != NULL); 457 456 assert(mountlist != NULL); … … 640 639 "Using tune2fs to identify your ext2,3,4 partitions"); 641 640 if (does_file_exist("/tmp/fstab.new")) { 642 strcpy(fstab_fname, "/tmp/fstab.new");641 mr_asprintf(fstab_fname, "/tmp/fstab.new"); 643 642 } else { 644 strcpy(fstab_fname, "/tmp/fstab");643 mr_asprintf(fstab_fname, "/tmp/fstab"); 645 644 } 646 645 mr_asprintf(tmp1, "label-partitions-as-necessary %s < %s >> %s 2>> %s", g_mountlist_fname, fstab_fname, MONDO_LOGFILE, MONDO_LOGFILE); 646 mr_free(fstab_fname); 647 647 648 res = system(tmp1); 648 649 mr_free(tmp1); … … 665 666 end_of_func: 666 667 paranoid_free(tmp); 667 paranoid_free(fstab_fname);668 668 log_it("Leaving interactive_mode()"); 669 669 return (retval); … … 1018 1018 1019 1019 /** malloc ***/ 1020 char *checksum ;1020 char *checksum = NULL; 1021 1021 char *outfile_fname = NULL; 1022 1022 char *tmp = NULL; 1023 1023 char *bzip2_command = NULL; 1024 char *ntfsprog_command, *suffix; 1024 char *ntfsprog_command; 1025 char *suffix = NULL; 1025 1026 char *sz_devfile = NULL; 1026 1027 char *bigblk; 1027 char *p;1028 1028 char *mds = NULL; 1029 1029 int retval = 0; … … 1031 1031 long sliceno; 1032 1032 long siz; 1033 char ntfsprog_fifo[MAX_STR_LEN];1033 char *ntfsprog_fifo = NULL; 1034 1034 char *file_to_openout = NULL; 1035 1035 struct s_filename_and_lstat_info biggiestruct; … … 1045 1045 assert(bkpinfo != NULL); 1046 1046 1047 malloc_string(checksum);1048 1047 malloc_string(ntfsprog_command); 1049 malloc_string(suffix);1050 1048 1051 1049 pathname_of_last_file_restored[0] = '\0'; … … 1067 1065 paranoid_fclose(fin); 1068 1066 1069 strcpy(checksum, biggiestruct.checksum); 1070 1067 mr_asprintf(checksum, "%s", biggiestruct.checksum); 1071 1068 if (!checksum[0]) { 1072 1069 log_msg(3, "Warning - bigfile %ld does not have a checksum", bigfileno + 1); 1073 p = checksum;1074 }1070 } 1071 mr_free(checksum); 1075 1072 1076 1073 if (!strncmp(biggiestruct.filename, "/dev/", 5)) // Whether NTFS or not :) … … 1085 1082 node = find_string_at_node(filelist, biggiestruct.filename); 1086 1083 if (!node) { 1087 log_msg(0, "Skipping %s (name isn't in filelist)", 1088 biggiestruct.filename); 1084 log_msg(0, "Skipping %s (name isn't in filelist)", biggiestruct.filename); 1089 1085 pathname_of_last_file_restored[0] = '\0'; 1090 1086 return (0); 1091 1087 } else if (!(node->selected)) { 1092 log_msg(1, "Skipping %s (name isn't in biggielist subset)", 1093 biggiestruct.filename); 1088 log_msg(1, "Skipping %s (name isn't in biggielist subset)", biggiestruct.filename); 1094 1089 pathname_of_last_file_restored[0] = '\0'; 1095 1090 return (0); 1096 1091 } 1097 1092 } 1093 1098 1094 /* otherwise, continue */ 1099 1100 1095 log_msg(1, "DEFINITELY restoring %s", biggiestruct.filename); 1101 1096 if (biggiestruct.use_ntfsprog) { 1102 1097 if (strncmp(biggiestruct.filename, "/dev/", 5)) { 1103 log_msg(1, 1104 "I was in error when I set biggiestruct.use_ntfsprog to TRUE."); 1098 log_msg(1, "I was in error when I set biggiestruct.use_ntfsprog to TRUE."); 1105 1099 log_msg(1, "%s isn't even in /dev", biggiestruct.filename); 1106 1100 biggiestruct.use_ntfsprog = FALSE; … … 1109 1103 1110 1104 if (biggiestruct.use_ntfsprog) // if it's an NTFS device 1111 // if (!strncmp ( biggiestruct.filename, "/dev/", 5))1112 1105 { 1113 1106 g_loglevel = 4; … … 1116 1109 mr_asprintf(sz_devfile, "/tmp/%d.%d.000", (int) (random() % 32768), (int) (random() % 32768)); 1117 1110 mkfifo(sz_devfile, 0x770); 1118 strcpy(ntfsprog_fifo, sz_devfile);1111 mr_asprintf(ntfsprog_fifo, "%s", sz_devfile); 1119 1112 mr_free(sz_devfile); 1120 1113 file_to_openout = ntfsprog_fifo; … … 1123 1116 fatal_error("Fork failure"); 1124 1117 case 0: 1125 log_msg(3, 1126 "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)", 1127 biggiestruct.filename, ntfsprog_fifo); 1128 res = 1129 feed_outfrom_ntfsprog(biggiestruct.filename, 1130 ntfsprog_fifo); 1131 // log_msg(3, "CHILD - fip - exiting"); 1118 log_msg(3, "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)", biggiestruct.filename, ntfsprog_fifo); 1119 res = feed_outfrom_ntfsprog(biggiestruct.filename, ntfsprog_fifo); 1120 mr_free(ntfsprog_fifo); 1132 1121 exit(res); 1133 1122 break; 1134 1123 default: 1135 log_msg(3, 1136 "feed_into_ntfsprog() called in background --- pid=%ld", 1137 (long int) (pid)); 1138 } 1124 log_msg(3, "feed_into_ntfsprog() called in background --- pid=%ld", (long int) (pid)); 1125 } 1126 mr_free(ntfsprog_fifo); 1139 1127 } else { 1140 1128 use_ntfsprog_hack = FALSE; 1141 ntfsprog_fifo[0] = '\0';1142 1129 file_to_openout = outfile_fname; 1143 1130 if (!does_file_exist(outfile_fname)) // yes, it looks weird with the '!' but it's correct that way … … 1155 1142 */ 1156 1143 1157 strncpy(pathname_of_last_file_restored, biggiestruct.filename, 1158 MAX_STR_LEN - 1); 1144 strncpy(pathname_of_last_file_restored, biggiestruct.filename, MAX_STR_LEN - 1); 1159 1145 pathname_of_last_file_restored[MAX_STR_LEN - 1] = '\0'; 1160 1146 … … 1167 1153 1168 1154 for (sliceno = 1, finished = FALSE; !finished;) { 1169 if (!does_file_exist 1170 (slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "")) 1171 && 1172 !does_file_exist(slice_fname 1173 (bigfileno, sliceno, ARCHIVES_PATH, "lzo")) 1174 && 1175 !does_file_exist(slice_fname 1176 (bigfileno, sliceno, ARCHIVES_PATH, "gz")) 1177 && 1178 !does_file_exist(slice_fname 1179 (bigfileno, sliceno, ARCHIVES_PATH, "bz2"))) { 1180 log_msg(3, 1181 "Cannot find a data slice or terminator slice on CD %d", 1182 g_current_media_number); 1155 if (!does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "")) && 1156 !does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "lzo")) && 1157 !does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "gz")) && 1158 !does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "bz2"))) { 1159 log_msg(3, "Cannot find a data slice or terminator slice on CD %d", g_current_media_number); 1183 1160 g_current_media_number++; 1184 1161 mds = media_descriptor_string(bkpinfo->backup_media_type); … … 1193 1170 mr_asprintf(tmp, "%s", slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "")); 1194 1171 if (does_file_exist(tmp) && length_of_file(tmp) == 0) { 1195 log_msg(2, 1196 "End of bigfile # %ld (slice %ld is the terminator)", 1197 bigfileno + 1, sliceno); 1172 log_msg(2, "End of bigfile # %ld (slice %ld is the terminator)", bigfileno + 1, sliceno); 1198 1173 finished = TRUE; 1199 1174 mr_free(tmp); 1200 1175 continue; 1201 1176 } else { 1202 if (does_file_exist 1203 (slice_fname 1204 (bigfileno, sliceno, ARCHIVES_PATH, "lzo"))) { 1177 if (does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "lzo"))) { 1205 1178 mr_asprintf(bzip2_command, "lzop"); 1206 strcpy(suffix, "lzo");1179 mr_asprintf(suffix, "lzo"); 1207 1180 } else 1208 if (does_file_exist 1209 (slice_fname 1210 (bigfileno, sliceno, ARCHIVES_PATH, "gz"))) { 1181 if (does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "gz"))) { 1211 1182 mr_asprintf(bzip2_command, "gzip"); 1212 strcpy(suffix, "gz");1183 mr_asprintf(suffix, "gz"); 1213 1184 } else 1214 if (does_file_exist 1215 (slice_fname 1216 (bigfileno, sliceno, ARCHIVES_PATH, "bz2"))) { 1185 if (does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, "bz2"))) { 1217 1186 mr_asprintf(bzip2_command, "bzip2"); 1218 strcpy(suffix, "bz2");1187 mr_asprintf(suffix, "bz2"); 1219 1188 } else 1220 if (does_file_exist 1221 (slice_fname 1222 (bigfileno, sliceno, ARCHIVES_PATH, ""))) { 1189 if (does_file_exist(slice_fname(bigfileno, sliceno, ARCHIVES_PATH, ""))) { 1223 1190 mr_asprintf(bzip2_command, ""); 1224 strcpy(suffix, "");1191 mr_asprintf(suffix, ""); 1225 1192 } else { 1226 1193 log_to_screen("OK, that's pretty fsck0red..."); … … 1235 1202 mr_asprintf(bzip2_command, "cat %s 2>> %s", slice_fname(bigfileno, sliceno, ARCHIVES_PATH, suffix), MONDO_LOGFILE); 1236 1203 } 1204 mr_free(suffix); 1205 1237 1206 mds = media_descriptor_string(bkpinfo->backup_media_type); 1238 1207 mr_asprintf(tmp, "Working on %s #%d, file #%ld, slice #%ld ", mds, g_current_media_number, bigfileno + 1, sliceno); … … 1288 1257 mr_free(outfile_fname); 1289 1258 paranoid_free(bigblk); 1290 paranoid_free(checksum);1291 1259 paranoid_free(ntfsprog_command); 1292 paranoid_free(suffix);1293 1260 1294 1261 return (retval); … … 1331 1298 char *ntfsprog_command; 1332 1299 char *sz_devfile = NULL; 1333 char *ntfsprog_fifo ;1300 char *ntfsprog_fifo = NULL; 1334 1301 char *file_to_openout = NULL; 1335 1302 … … 1350 1317 1351 1318 malloc_string(tmp); 1352 malloc_string(ntfsprog_fifo);1353 1319 malloc_string(ntfsprog_command); 1354 1320 old_loglevel = g_loglevel; … … 1407 1373 mr_asprintf(sz_devfile, "%s/%d.%d.000", bkpinfo->tmpdir, (int) (random() % 32768), (int) (random() % 32768)); 1408 1374 mkfifo(sz_devfile, 0x770); 1409 strcpy(ntfsprog_fifo, sz_devfile);1375 mr_asprintf(ntfsprog_fifo, "%s", sz_devfile); 1410 1376 mr_free(sz_devfile); 1411 1377 … … 1417 1383 log_msg(3, "CHILD - fip - calling feed_outfrom_ntfsprog(%s, %s)", outfile_fname, ntfsprog_fifo); 1418 1384 res = feed_outfrom_ntfsprog(outfile_fname, ntfsprog_fifo); 1385 mr_free(ntfsprog_fifo); 1419 1386 exit(res); 1420 1387 break; … … 1422 1389 log_msg(3, "feed_into_ntfsprog() called in background --- pid=%ld", (long int) (pid)); 1423 1390 } 1391 mr_free(ntfsprog_fifo); 1424 1392 } else { 1425 1393 if (!strncmp(orig_bf_fname, "/dev/", 5)) { … … 1431 1399 } 1432 1400 use_ntfsprog_hack = FALSE; 1433 ntfsprog_fifo[0] = '\0';1434 1401 file_to_openout = outfile_fname; 1435 1402 if (!does_file_exist(outfile_fname)) // yes, it looks weird with the '!' but it's correct that way … … 1539 1506 paranoid_free(tmp); 1540 1507 paranoid_free(ntfsprog_command); 1541 paranoid_free(ntfsprog_fifo);1542 1508 g_loglevel = old_loglevel; 1543 1509 return (retval); … … 2099 2065 char *tarball_fname = NULL; 2100 2066 char *progress_str = NULL; 2101 char *comment;2102 2103 malloc_string(comment);2104 2067 2105 2068 assert(bkpinfo != NULL); … … 2182 2145 mr_strcat(tmp1, " (%d attempts) - review logs", attempts); 2183 2146 } 2184 strcpy(comment, tmp1); 2147 if (attempts > 1) { 2148 log_to_screen(tmp1); 2149 } 2185 2150 mr_free(tmp1); 2186 if (attempts > 1) {2187 log_to_screen(comment);2188 }2189 2151 2190 2152 retval += res; … … 2203 2165 mvaddstr_and_log_it(g_currentY++, 74, "Done."); 2204 2166 } 2205 paranoid_free(comment);2206 2167 2207 2168 return (retval); … … 2633 2594 struct raidlist_itself *raidlist; 2634 2595 struct s_node *filelist; 2635 char *a, *b; 2596 char *tmp1 = NULL; 2597 char *tmp2 = NULL; 2636 2598 bool run_postnuke = FALSE; 2637 2599 … … 2663 2625 run_program_and_log_output("mkdir -p " MNT_CDROM, FALSE); 2664 2626 2665 malloc_string(a);2666 malloc_string(b);2667 2627 setup_MR_global_filenames(); // malloc() and set globals, using bkpinfo->tmpdir etc. 2668 2628 bkpinfo->backup_media_type = none; // in case boot disk was made for one backup type but user wants to restore from another backup type … … 2753 2713 toggle_path_selection(filelist, "/usr/share", TRUE); 2754 2714 save_filelist(filelist, "/tmp/out.txt"); 2755 strcpy(a, argv[3]); 2756 strcpy(b, argv[4]); 2757 2758 res = save_filelist_entries_in_common(a, filelist, b, FALSE); 2715 mr_asprintf(tmp1, "%s", argv[3]); 2716 mr_asprintf(tmp2, "%s", argv[4]); 2717 2718 res = save_filelist_entries_in_common(tmp1, filelist, tmp2, FALSE); 2719 mr_free(tmp1); 2720 mr_free(tmp2); 2721 2759 2722 free_filelist(filelist); 2760 2723 printf("res = %d", res); … … 3029 2992 paranoid_MR_finish(retval); // frees global stuff plus bkpinfo 3030 2993 free_libmondo_global_strings(); // it's fine to have this here :) really :) 3031 paranoid_free(a);3032 paranoid_free(b);3033 2994 3034 2995 unlink("/tmp/filelist.full");
Note:
See TracChangeset
for help on using the changeset viewer.