Changeset 688 in MondoRescue for trunk/mondo/mondo/mondorestore/mondo-rstr-newt.c
- Timestamp:
- Jul 17, 2006, 3:44:46 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/mondo/mondo/mondorestore/mondo-rstr-newt.c
r539 r688 1 1 /*************************************************************************** 2 2 * $Id$ 3 * /3 **/ 4 4 5 5 … … 11 11 #ifdef __FreeBSD__ 12 12 #define OSSWAP(linux,fbsd) fbsd 13 //#include <libgen.h>14 13 #else 15 14 #define OSSWAP(linux,fbsd) linux … … 17 16 18 17 #include "mondo-rstr-newt.h" 19 20 //static char cvsid[] = "$Id$";21 22 extern char err_log_lines[NOOF_ERR_LINES][MAX_STR_LEN];23 24 18 25 19 /** … … 57 51 { 58 52 /** buffers ***********************************************************/ 59 char *tmp ;53 char *tmp = NULL; 60 54 61 55 /** newt **************************************************************/ … … 82 76 83 77 newtPushHelpLine 84 (_(" Add one of the following unallocated RAID partitions to this RAID device.")); 78 (_ 79 (" Add one of the following unallocated RAID partitions to this RAID device.")); 85 80 asprintf(&tmp, "%-26s %s", _("Device"), _("Size")); 86 81 headerMsg = newtLabel(1, 1, tmp); … … 157 152 newtComponent formatComp; 158 153 159 /** buffers **********************************************************/ 160 char *drive_to_add; 161 char *mountpoint_str; 154 char *drive_to_add = NULL; 155 char *mountpoint_str = NULL; 162 156 char *size_str = NULL; 163 char *device_str; 164 char *format_str; 165 166 /** pointers *********************************************************/ 167 char *mountpoint_here; 168 char *size_here; 169 char *device_here; 170 char *format_here; 157 char *device_str = NULL; 158 char *format_str = NULL; 159 char *mountpoint_here = NULL; 160 char *size_here = NULL; 161 char *device_here = NULL; 162 char *format_here = NULL; 171 163 172 164 assert(mountlist != NULL); … … 198 190 bCancel = newtButton(17, 6, _("Cancel")); 199 191 newtPushHelpLine 200 (_("To add an entry to the mountlist, please fill in these fields and then hit 'OK'")); 192 (_ 193 ("To add an entry to the mountlist, please fill in these fields and then hit 'OK'")); 201 194 myForm = newtForm(NULL, NULL, 0); 202 195 newtFormAddComponents(myForm, deviceComp, mountpointComp, sizeComp, … … 229 222 if (size_of_specific_device_in_mountlist(mountlist, device_str) 230 223 >= 0) { 231 popup_and_OK(_("Can't add this - you've got one already!")); 224 popup_and_OK(_ 225 ("Can't add this - you've got one already!")); 232 226 b_res = NULL; 233 227 } … … 286 280 287 281 if (popup_and_get_string 288 ("Add variable", _("Enter the name of the variable to add"), sz_out, 289 MAX_STR_LEN)) { 290 strip_spaces(sz_out); 282 ("Add variable", _("Enter the name of the variable to add"), 283 sz_out)) { 291 284 items = raidrec->additional_vars.entries; 292 285 for (i = 0; … … 295 288 if (i < items) { 296 289 popup_and_OK 297 (_("No need to add that variable. It is already listed here.")); 290 (_ 291 ("No need to add that variable. It is already listed here.")); 298 292 } else { 299 293 strcpy(raidrec->additional_vars.el[items].label, sz_out); … … 302 296 } 303 297 } 298 paranoid_free(sz_out); 304 299 } 305 300 #endif … … 322 317 323 318 /** structures ********************************************************/ 324 struct vinum_volume *raidrec; 325 326 /** int ***************************************************************/ 319 struct vinum_volume *raidrec = NULL; 320 327 321 int i = 0, j = 0; 328 322 int noof_partitions = 0; 329 323 330 /** long **************************************************************/331 324 long total_size = 0; 332 325 long plex_size = 0; … … 335 328 long sp = 0; 336 329 337 /** buffers ***********************************************************/ 338 char *tmp; 339 char *devname; 340 341 342 330 char *tmp = NULL; 331 char *devname = NULL; 343 332 344 333 for (i = 0; … … 347 336 if (i == raidlist->entries) { 348 337 asprintf(&tmp, 349 "Cannot calc size of raid device %s - cannot find it in raidlist",350 raid_device);338 "Cannot calc size of raid device %s - cannot find it in raidlist", 339 raid_device); 351 340 log_it(tmp); 352 341 paranoid_free(tmp); … … 411 400 } 412 401 413 asprintf(&tmp, "I have calculated %s's real size to be %ld", raid_device,414 (long) smallest_plex);402 asprintf(&tmp, "I have calculated %s's real size to be %ld", 403 raid_device, (long) smallest_plex); 415 404 log_it(tmp); 416 405 paranoid_free(tmp); … … 420 409 421 410 /** structures ********************************************************/ 422 struct raid_device_record *raidrec ;411 struct raid_device_record *raidrec = NULL; 423 412 424 413 /** int ***************************************************************/ … … 432 421 433 422 /** buffers ***********************************************************/ 434 char *tmp ;423 char *tmp = NULL; 435 424 436 425 assert(mountlist != NULL); … … 443 432 if (i == raidlist->entries) { 444 433 asprintf(&tmp, 445 "Cannot calc size of raid device %s - cannot find it in raidlist",446 raid_device);434 "Cannot calc size of raid device %s - cannot find it in raidlist", 435 raid_device); 447 436 log_it(tmp); 448 437 paranoid_free(tmp); … … 469 458 total_size = smallest_partition * (noof_partitions - 1); 470 459 } 471 asprintf(&tmp, "I have calculated %s's real size to be %ld", raid_device,472 (long) total_size);460 asprintf(&tmp, "I have calculated %s's real size to be %ld", 461 raid_device, (long) total_size); 473 462 log_it(tmp); 474 463 paranoid_free(tmp); … … 478 467 479 468 480 481 469 /** 482 470 * Choose the RAID level for the RAID device record in @p raidrec. … … 495 483 496 484 /** buffers ***********************************************************/ 497 char *tmp ;498 char *prompt ;499 char *sz ;485 char *tmp = NULL; 486 char *prompt = NULL; 487 char *sz = NULL; 500 488 501 489 asprintf(&prompt, 502 _("Please enter the RAID level you want. (concat, striped, raid5)")); 490 _ 491 ("Please enter the RAID level you want. (concat, striped, raid5)")); 503 492 if (raidrec->raidlevel == -1) { 504 493 asprintf(&tmp, "concat"); … … 509 498 } 510 499 for (out = 999; out == 999;) { 511 res = popup_and_get_string("Specify RAID level", prompt, tmp , 10);500 res = popup_and_get_string("Specify RAID level", prompt, tmp); 512 501 if (!res) { 513 502 return; 514 503 } 515 strip_spaces(tmp);504 /* BERLIOS: Useless ??? 516 505 if (tmp[0] == '[' && tmp[strlen(tmp) - 1] == ']') { 517 506 asprintf(&sz, tmp); … … 520 509 paranoid_free(sz); 521 510 } 511 */ 522 512 if (!strcmp(tmp, "concat")) { 523 513 out = -1; … … 544 534 #else 545 535 /** buffers ***********************************************************/ 546 char *tmp ;547 char personalities[MAX_STR_LEN];548 char *prompt ;549 char *sz ;536 char *tmp = NULL; 537 char *personalities = NULL; 538 char *prompt = NULL; 539 char *sz = NULL; 550 540 int out = 0, res = 0; 551 541 … … 554 544 system 555 545 ("grep Pers /proc/mdstat > /tmp/raid-personalities.txt 2> /dev/null"); 556 strcpy(personalities, 557 last_line_of_file("/tmp/raid-personalities.txt")); 546 personalities = last_line_of_file("/tmp/raid-personalities.txt")); 558 547 asprintf(&prompt, _("Please enter the RAID level you want. %s"), 559 personalities); 548 personalities); 549 paranoid_free(personalities); 550 560 551 if (raidrec->raid_level == -1) { 561 552 asprintf(&tmp, "linear"); … … 566 557 out != -1 && out != 0 && out != 1 && out != 4 && out != 5 567 558 && out != 10;) { 568 res = popup_and_get_string(_("Specify RAID level"), prompt, tmp, 10); 559 res = 560 popup_and_get_string(_("Specify RAID level"), prompt, tmp); 569 561 if (!res) { 570 562 return; 571 563 } 572 strip_spaces(tmp);564 /* BERLIOS: Useless ??? 573 565 if (tmp[0] == '[' && tmp[strlen(tmp) - 1] == ']') { 574 566 asprintf(&sz, tmp); 575 strncpy(tmp, sz + 1, strlen(sz) - 2); 567 paranoid_free(tmp); 568 569 asprintf(&tmp, sz + 1); 576 570 tmp[strlen(sz) - 2] = '\0'; 577 571 paranoid_free(sz); 578 572 } 573 */ 579 574 if (!strcmp(tmp, "linear")) { 580 575 out = -1; … … 585 580 } 586 581 log_it(tmp); 587 paranoid_free(tmp);588 582 if (is_this_raid_personality_registered(out)) { 589 583 log_it … … 591 585 } else { 592 586 if (ask_me_yes_or_no 593 (_("You have chosen a RAID personality which is not registered with the kernel. Make another selection?"))) 587 (_ 588 ("You have chosen a RAID personality which is not registered with the kernel. Make another selection?"))) 594 589 { 595 590 out = 999; … … 597 592 } 598 593 } 594 paranoid_free(tmp); 599 595 paranoid_free(prompt); 600 596 raidrec->raid_level = out; … … 622 618 623 619 /** buffers ***********************************************************/ 624 char *tmp ;620 char *tmp = NULL; 625 621 626 622 assert(mountlist != NULL); … … 634 630 pos++); 635 631 if (pos < mountlist->entries) { 636 asprintf(&tmp, 637 "Deleting partition %s cos it was part of a now-defunct RAID", 638 mountlist->el[pos].device); 639 log_it(tmp); 640 paranoid_free(tmp); 632 log_it("Deleting partition %s cos it was part of a now-defunct RAID", 633 mountlist->el[pos].device); 641 634 memcpy((void *) &mountlist->el[pos], 642 635 (void *) &mountlist->el[mountlist->entries - 1], … … 665 658 666 659 /** buffers ***********************************************************/ 667 char *tmp ;660 char *tmp = NULL; 668 661 669 662 assert(disklist != NULL); … … 671 664 672 665 asprintf(&tmp, _("Delete %s from RAID device %s - are you sure?"), 673 disklist->el[currline].device, raid_device);666 disklist->el[currline].device, raid_device); 674 667 if (!ask_me_yes_or_no(tmp)) { 675 668 paranoid_free(tmp); … … 705 698 706 699 /** buffers ***********************************************************/ 707 char *tmp ;708 char *device ;700 char *tmp = NULL; 701 char *device = NULL; 709 702 710 703 assert(mountlist != NULL); … … 718 711 device); 719 712 if (pos >= 0) { 720 asprintf(&tmp, _("Cannot delete %s: it is in use by RAID device %s"), 721 mountlist->el[currline].device, 722 raidlist->el[pos].OSSWAP(raid_device, volname)); 713 asprintf(&tmp, 714 _("Cannot delete %s: it is in use by RAID device %s"), 715 mountlist->el[currline].device, 716 raidlist->el[pos].OSSWAP(raid_device, volname)); 723 717 popup_and_OK(tmp); 724 718 paranoid_free(tmp); … … 726 720 } 727 721 asprintf(&tmp, _("Delete %s - are you sure?"), 728 mountlist->el[currline].device);722 mountlist->el[currline].device); 729 723 if (!ask_me_yes_or_no(tmp)) { 730 724 paranoid_free(tmp); … … 740 734 && strcmp(mountlist->el[currline].device, device); 741 735 currline++); 742 if (currline == mountlist->entries) {743 log_it("Dev is gone. I can't delete it. Ho-hum");744 paranoid_free(device);745 return;746 }736 if (currline == mountlist->entries) { 737 log_it("Dev is gone. I can't delete it. Ho-hum"); 738 paranoid_free(device); 739 return; 740 } 747 741 paranoid_free(device); 748 742 } … … 775 769 776 770 /** buffers ***********************************************************/ 777 char *tmp ;771 char *tmp = NULL; 778 772 779 773 assert(mountlist != NULL); … … 785 779 return; 786 780 } 787 asprintf(&tmp, _("Do you want me to delete %s's partitions, too?", device)); 781 asprintf(&tmp, 782 _("Do you want me to delete %s's partitions, too?"), device); 788 783 delete_partitions_too = ask_me_yes_or_no(tmp); 789 784 if (delete_partitions_too) { … … 846 841 847 842 /** buffers ************************************************************/ 848 char *tmp ;843 char *tmp = NULL; 849 844 850 845 /** structures *********************************************************/ 851 struct additional_raid_variables *av ;846 struct additional_raid_variables *av = NULL; 852 847 853 848 assert(raidrec != NULL); 854 849 855 850 av = &raidrec->additional_vars; 856 asprintf(&tmp, _("Delete %s - are you sure?" , av->el[lino].label));851 asprintf(&tmp, _("Delete %s - are you sure?"), av->el[lino].label); 857 852 if (ask_me_yes_or_no(tmp)) { 858 853 if (!strcmp(av->el[lino].label, "persistent-superblock") … … 860 855 paranoid_free(tmp); 861 856 asprintf(&tmp, _("%s must not be deleted. It would be bad."), 862 av->el[lino].label);857 av->el[lino].label); 863 858 popup_and_OK(tmp); 864 859 } else { … … 891 886 892 887 /** structures *******************************************************/ 893 struct s_node *node ;888 struct s_node *node = NULL; 894 889 895 890 /** buffers **********************************************************/ 896 static char *current_filename ;897 char *tmp ;891 static char *current_filename = NULL; 892 char *tmp = NULL; 898 893 899 894 /** bool *************************************************************/ … … 905 900 assert(keylist != NULL); 906 901 assert(listbox != NULL); 907 908 902 909 903 if (depth == 0) { … … 927 921 warned_already = TRUE; 928 922 asprintf(&tmp, 929 _("Too many lines. Displaying first %d entries only. Close a directory to see more."), 930 ARBITRARY_MAXIMUM); 923 _ 924 ("Too many lines. Displaying first %d entries only. Close a directory to see more."), 925 ARBITRARY_MAXIMUM); 931 926 popup_and_OK(tmp); 932 927 paranoid_free(tmp); … … 964 959 newtListboxClear(listbox); 965 960 for (i = 0; i < lines_in_flist_window; i++) { 966 asprintf(&tmp, "%c%c %-80s", (g_is_path_selected[i] ? '*' : ' '), 967 (g_is_path_expanded[i] ? '+' : '-'), 968 strip_path(g_strings_of_flist_window[i])); 969 // BERLIOS: this is dangerous now 961 asprintf(&tmp, "%c%c %-80s", 962 (g_is_path_selected[i] ? '*' : ' '), 963 (g_is_path_expanded[i] ? '+' : '-'), 964 strip_path(g_strings_of_flist_window[i])); 965 // BERLIOS: this is dangerous now => Memory leak 970 966 if (strlen(tmp) > 71) { 971 967 tmp[70] = '\0'; … … 1011 1007 slashcount--; /* Keep one slash 'cos Hugh does... */ 1012 1008 1009 /* BERLIOS: tmpnopath and prev not defined !! How can this compile ?? */ 1013 1010 for (i = 0; i < slashcount; i++) { /* Replace each dir with a space char */ 1014 1011 tmpnopath[i] = ' '; … … 1062 1059 void *keylist[ARBITRARY_MAXIMUM]; 1063 1060 1064 /** buffers ***********************************************************/1065 char tmp[MAX_STR_LEN];1066 1067 1061 /** bool **************************************************************/ 1068 1062 bool dummybool; … … 1074 1068 log_to_screen(_("Editing filelist")); 1075 1069 newtPushHelpLine 1076 (_(" Please edit the filelist to your satisfaction, then click OK or Cancel.")); 1070 (_ 1071 (" Please edit the filelist to your satisfaction, then click OK or Cancel.")); 1077 1072 j = 4; 1078 1073 bLess = newtCompactButton(j, 17, _(" Less ")); … … 1111 1106 indexno = 0; 1112 1107 } 1113 sprintf(tmp,"You selected '%s'",1108 log_it("You selected '%s'", 1114 1109 g_strings_of_flist_window[indexno]); 1115 log_it(tmp);1116 1110 if (b_res == bMore) { 1117 1111 g_is_path_expanded[indexno] = TRUE; … … 1204 1198 newtComponent b_raid = NULL; 1205 1199 1206 /** buffers ***********************************************************/ 1207 char device_str[MAX_STR_LEN]; 1208 char mountpoint_str[MAX_STR_LEN]; 1209 char size_str[MAX_STR_LEN]; 1210 char format_str[MAX_STR_LEN]; 1211 char tmp[MAX_STR_LEN]; 1212 char device_used_to_be[MAX_STR_LEN]; 1213 char mountpt_used_to_be[MAX_STR_LEN]; 1214 1215 /** pointers **********************************************************/ 1216 char *device_here; 1217 char *mountpoint_here; 1218 char *size_here; 1219 char *format_here; 1220 1221 /** int ***************************************************************/ 1200 char *device_str = NULL; 1201 char *mountpoint_str = NULL; 1202 char *size_str = NULL; 1203 char *format_str = NULL; 1204 char *tmp = NULL; 1205 char *device_used_to_be = NULL; 1206 char *mountpt_used_to_be = NULL; 1207 char *device_here = NULL; 1208 char *mountpoint_here = NULL; 1209 char *size_here = NULL; 1210 char *format_here = NULL; 1211 1222 1212 int j = 0; 1223 1213 … … 1229 1219 memcpy((void *) &bkp_raidlist, (void *) raidlist, 1230 1220 sizeof(struct raidlist_itself)); 1231 strcpy(device_str, mountlist->el[currline].device); 1232 strcpy(device_used_to_be, mountlist->el[currline].device); 1233 strcpy(mountpoint_str, mountlist->el[currline].mountpoint); 1234 strcpy(mountpt_used_to_be, mountlist->el[currline].mountpoint); 1235 strcpy(format_str, mountlist->el[currline].format); 1236 sprintf(size_str, "%lld", mountlist->el[currline].size / 1024); 1221 asprintf(&device_str, mountlist->el[currline].device); 1222 asprintf(&device_used_to_be, mountlist->el[currline].device); 1223 asprintf(&mountpoint_str, mountlist->el[currline].mountpoint); 1224 asprintf(&mountpt_used_to_be, mountlist->el[currline].mountpoint); 1225 asprintf(&format_str, mountlist->el[currline].format); 1226 asprintf(&size_str, "%lld", mountlist->el[currline].size / 1024); 1227 1237 1228 newtOpenWindow(20, 5, 48, 10, "Edit entry"); 1238 1229 label0 = newtLabel(2, 1, _("Device:")); … … 1242 1233 deviceComp = 1243 1234 newtEntry(14, 1, device_str, 30, (void *) &device_here, 0); 1235 paranoid_free(device_str); 1236 1244 1237 mountpointComp = 1245 1238 newtEntry(14, 2, mountpoint_str, 30, (void *) &mountpoint_here, 0); 1239 paranoid_free(mountpoint_str); 1240 1246 1241 formatComp = 1247 1242 newtEntry(14, 4, format_str, 15, (void *) &format_here, 0); 1243 paranoid_free(format_str); 1244 1248 1245 if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB) 1249 1246 || !strcmp(mountlist->el[currline].mountpoint, "image")) { … … 1252 1249 sizeComp = newtEntry(14, 3, size_str, 10, (void *) &size_here, 0); 1253 1250 } 1251 paranoid_free(size_str); 1252 1254 1253 bOK = newtButton(2, 6, _(" OK ")); 1255 1254 bCancel = newtButton(14, 6, _("Cancel")); … … 1258 1257 } 1259 1258 newtPushHelpLine 1260 (_(" Edit this partition's mountpoint, size and format; then click 'OK'.")); 1259 (_ 1260 (" Edit this partition's mountpoint, size and format; then click 'OK'.")); 1261 1261 myForm = newtForm(NULL, NULL, 0); 1262 1262 newtFormAddComponents(myForm, deviceComp, mountpointComp, sizeComp, … … 1265 1265 for (b_res = NULL; b_res != bOK && b_res != bCancel;) { 1266 1266 b_res = newtRunForm(myForm); 1267 strcpy(device_str, device_here); 1267 1268 paranoid_free(device_str); 1269 asprintf(&device_str, device_here); 1268 1270 strip_spaces(device_str); 1269 strcpy(mountpoint_str, mountpoint_here); 1271 1272 paranoid_free(mountpoint_str); 1273 asprintf(&mountpoint_str, mountpoint_here); 1270 1274 strip_spaces(mountpoint_str); 1271 strcpy(format_str, format_here); 1275 1276 paranoid_free(format_str); 1277 asprintf(&format_str, format_here); 1278 paranoid_free(format_here); 1272 1279 strip_spaces(format_str); 1273 1280 if (b_res == bOK && strstr(device_str, RAID_DEVICE_STUB) … … 1279 1286 } else if (b_res == bOK && !strcmp(mountpoint_str, "image") 1280 1287 && strcmp(mountpt_used_to_be, "image")) { 1281 popup_and_OK(_("You can't change a regular device to an image.")); 1288 popup_and_OK(_ 1289 ("You can't change a regular device to an image.")); 1282 1290 b_res = NULL; 1283 1291 continue; 1284 1292 } 1293 paranoid_free(mountpt_used_to_be); 1294 1285 1295 if (!strstr(mountlist->el[currline].device, RAID_DEVICE_STUB) 1286 1296 && strcmp(mountlist->el[currline].mountpoint, "image")) { 1287 strcpy(size_str, size_here);1297 asprintf(&size_str, size_here); 1288 1298 strip_spaces(size_str); 1289 1299 } else { 1290 sprintf(size_str, "%ld",1300 asprintf(&size_str, "%ld", 1291 1301 calculate_raid_device_size(mountlist, raidlist, 1292 1302 mountlist->el[currline]. … … 1294 1304 newtLabelSetText(sizeComp, size_str); 1295 1305 } 1306 paranoid_free(size_here); 1307 1296 1308 /* do not let user click RAID button if user has changed device_str */ 1297 1309 if (b_res == b_raid) { … … 1302 1314 */ 1303 1315 popup_and_OK 1304 (_("You cannot edit the RAID settings until you have OK'd your change to the device node.")); 1316 (_ 1317 ("You cannot edit the RAID settings until you have OK'd your change to the device node.")); 1305 1318 } else { 1306 1319 j = find_raid_device_in_raidlist(raidlist, … … 1309 1322 if (j < 0) { 1310 1323 sprintf(tmp, 1311 _("/etc/raidtab does not have an entry for %s; please delete it and add it again"), 1324 _ 1325 ("/etc/raidtab does not have an entry for %s; please delete it and add it again"), 1312 1326 mountlist->el[currline].device); 1313 1327 popup_and_OK(tmp); … … 1320 1334 } 1321 1335 } 1336 paranoid_free(device_here); 1337 paranoid_free(mountpoint_here); 1338 1322 1339 newtFormDestroy(myForm); 1323 1340 newtPopHelpLine(); … … 1330 1347 strcpy(mountlist->el[currline].device, device_str); 1331 1348 strcpy(mountlist->el[currline].mountpoint, mountpoint_str); 1349 paranoid_free(mountpoint_str); 1350 1332 1351 strcpy(mountlist->el[currline].format, format_str); 1352 paranoid_free(format_str); 1353 1333 1354 if (strstr(mountlist->el[currline].device, RAID_DEVICE_STUB) 1334 1355 || !strcmp(mountlist->el[currline].mountpoint, "image")) { … … 1339 1360 mountlist->el[currline].size = atol(size_str) * 1024; 1340 1361 } 1362 paranoid_free(size_str); 1363 1341 1364 newtListboxSetEntry(listbox, (int) keylist[currline], 1342 1365 mountlist_entry_to_string(mountlist, currline)); … … 1363 1386 else if (strcmp(device_used_to_be, device_str)) { 1364 1387 popup_and_OK 1365 (_("You are renaming a RAID device as another RAID device. I don't like it but I'll allow it.")); 1388 (_ 1389 ("You are renaming a RAID device as another RAID device. I don't like it but I'll allow it.")); 1366 1390 } 1367 1391 #endif 1368 1392 redraw_mountlist(mountlist, keylist, listbox); 1393 paranoid_free(device_str); 1394 paranoid_free(device_used_to_be); 1369 1395 } 1370 1396 … … 1425 1451 } 1426 1452 1453 1427 1454 void 1428 1455 edit_raidlist_plex(struct mountlist_itself *mountlist, … … 1455 1482 1456 1483 /** buffers ***********************************************************/ 1457 char title_of_editraidForm_window[MAX_STR_LEN];1484 char *title_of_editraidForm_window; 1458 1485 1459 1486 /** newt **************************************************************/ … … 1472 1499 1473 1500 int currline2 = 0; 1501 char *pname = NULL; 1502 char *raidlevel = NULL; 1503 char *chunksize = NULL; 1504 char *entry = NULL; 1505 char *msg = NULL; 1506 int i = 0; 1507 char *headerstr = NULL; 1474 1508 1475 1509 log_it(_("Started edit_raidlist_entry")); 1476 1510 memcpy((void *) &bkp_raidrec, (void *) raidrec, 1477 1511 sizeof(struct vinum_volume)); 1478 sprintf(title_of_editraidForm_window, _("Plexes on %s"),1512 asprintf(&title_of_editraidForm_window, _("Plexes on %s"), 1479 1513 raidrec->volname); 1480 1514 newtPushHelpLine(_(" Please select a plex to edit")); 1481 1515 newtOpenWindow(13, 5, 54, 15, title_of_editraidForm_window); 1516 paranoid_free(title_of_editraidForm_window); 1517 1482 1518 for (;;) { 1483 int i; 1484 char headerstr[MAX_STR_LEN]; 1485 snprintf(headerstr, MAX_STR_LEN, "%-14s %-8s %11s %8s", 1486 _("Plex"), _("Level",) _("Stripe Size"), _("Subdisks")); 1519 asprintf(&headerstr, "%-14s %-8s %11s %8s", _("Plex"), _("Level",) _("Stripe Size"), _("Subdisks")); 1487 1520 1488 1521 bOK = newtCompactButton(2, 13, _(" OK ")); … … 1495 1528 newtListbox(2, 3, 9, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT); 1496 1529 plexesHeader = newtLabel(2, 2, headerstr); 1530 paranoid_free(headerstr); 1531 1497 1532 editraidForm = newtForm(NULL, NULL, 0); 1498 1533 … … 1501 1536 keylist[i] = (void *) i; 1502 1537 if (i < raidrec->plexes) { 1503 char pname[64], entry[MAX_STR_LEN], raidlevel[64],1504 chunksize[64];1505 1538 switch (raidrec->plex[i].raidlevel) { 1506 1539 case -1: 1507 strcpy(raidlevel, "concat");1540 asprintf(&raidlevel, "concat"); 1508 1541 break; 1509 1542 case 0: 1510 strcpy(raidlevel, "striped");1543 asprintf(&raidlevel, "striped"); 1511 1544 break; 1512 1545 case 5: 1513 strcpy(raidlevel, "raid5");1546 asprintf(&raidlevel, "raid5"); 1514 1547 break; 1515 1548 default: 1516 sprintf(raidlevel, "raid%i",1549 asprintf(&raidlevel, "raid%i", 1517 1550 raidrec->plex[i].raidlevel); 1518 1551 break; … … 1520 1553 1521 1554 if (raidrec->plex[i].raidlevel == -1) { 1522 strcpy(chunksize, "N/A");1555 asprintf(&chunksize, "N/A"); 1523 1556 } else { 1524 sprintf(chunksize, "%dk", raidrec->plex[i].stripesize);1557 asprintf(&chunksize, "%dk", raidrec->plex[i].stripesize); 1525 1558 } 1526 snprintf(pname, 64, "%s.p%i", raidrec->volname, i);1527 snprintf(entry, MAX_STR_LEN, "%-14s %-8s %11s %8d",1559 asprintf(&pname, "%s.p%i", raidrec->volname, i); 1560 asprintf(&entry, "%-14s %-8s %11s %8d", 1528 1561 pname, raidlevel, chunksize, 1529 1562 raidrec->plex[i].subdisks); 1563 paranoid_free(pname); 1564 paranoid_free(chunksize); 1565 paranoid_free(raidlevel); 1530 1566 newtListboxAppendEntry(plexesListbox, entry, keylist[i]); 1567 paranoid_free(entry); 1531 1568 } 1532 1569 } … … 1549 1586 1550 1587 if (b_res == bDelete) { 1551 char msg[MAX_STR_LEN]; 1552 sprintf(msg, _("Are you sure you want to delete %s.p%i?"), 1588 asprintf(&msg, _("Are you sure you want to delete %s.p%i?"), 1553 1589 raidrec->volname, currline2); 1554 1590 if (ask_me_yes_or_no(msg)) { … … 1559 1595 raidrec->plexes--; 1560 1596 } 1597 paranoid_free(msg); 1561 1598 continue; 1562 1599 } … … 1581 1618 #else 1582 1619 /** structures ********************************************************/ 1583 struct raid_device_record *bkp_raidrec ;1620 struct raid_device_record *bkp_raidrec = NULL; 1584 1621 1585 1622 1586 1623 /** buffers ***********************************************************/ 1587 char *title_of_editraidForm_window ;1588 char *sz_raid_level ;1589 char *sz_data_disks ;1590 char *sz_spare_disks ;1591 char *sz_parity_disks ;1592 char *sz_failed_disks ;1624 char *title_of_editraidForm_window = NULL; 1625 char *sz_raid_level = NULL; 1626 char *sz_data_disks = NULL; 1627 char *sz_spare_disks = NULL; 1628 char *sz_parity_disks = NULL; 1629 char *sz_failed_disks = NULL; 1593 1630 1594 1631 /** newt **************************************************************/ … … 1608 1645 assert(raidrec != NULL); 1609 1646 1610 malloc_string(title_of_editraidForm_window);1611 malloc_string(sz_raid_level);1612 malloc_string(sz_data_disks);1613 malloc_string(sz_spare_disks);1614 malloc_string(sz_parity_disks);1615 malloc_string(sz_failed_disks);1616 1647 if (!(bkp_raidrec = malloc(sizeof(struct raid_device_record)))) { 1617 1648 fatal_error("Cannot malloc space for raidrec"); … … 1622 1653 memcpy((void *) bkp_raidrec, (void *) raidrec, 1623 1654 sizeof(struct raid_device_record)); 1624 sprintf(title_of_editraidForm_window, "%s", raidrec->raid_device);1655 asprintf(&title_of_editraidForm_window, _("Edit %s"), raidrec->raid_device); 1625 1656 log_msg(2, "Opening newt window"); 1626 1657 newtOpenWindow(20, 5, 40, 14, title_of_editraidForm_window); 1658 paranoid_free(title_of_editraidForm_window); 1659 1627 1660 for (;;) { 1628 1661 log_msg(2, "Main loop"); 1629 sprintf(title_of_editraidForm_window, _("Edit %s"), 1630 raidrec->raid_device); 1631 strcpy(sz_raid_level, 1662 asprintf(&sz_raid_level, 1632 1663 turn_raid_level_number_to_string(raidrec->raid_level)); 1633 strcpy(sz_data_disks,1664 asprintf(&sz_data_disks, 1634 1665 number_of_disks_as_string(raidrec->data_disks.entries, 1635 1666 _("data"))); 1636 strcpy(sz_spare_disks,1667 asprintf(&sz_spare_disks, 1637 1668 number_of_disks_as_string(raidrec->spare_disks.entries, 1638 1669 _("spare"))); 1639 strcpy(sz_parity_disks,1670 asprintf(&sz_parity_disks, 1640 1671 number_of_disks_as_string(raidrec->parity_disks.entries, 1641 1672 _("parity"))); 1642 strcpy(sz_failed_disks,1673 asprintf(&sz_failed_disks, 1643 1674 number_of_disks_as_string(raidrec->failed_disks.entries, 1644 1675 _("failed"))); … … 1648 1679 bSelectFailed = newtButton(20, 5, sz_failed_disks); 1649 1680 bChangeRaid = newtButton(1, 9, sz_raid_level); 1681 paranoid_free(sz_raid_level); 1682 paranoid_free(sz_data_disks); 1683 paranoid_free(sz_spare_disks); 1684 paranoid_free(sz_parity_disks); 1685 paranoid_free(sz_failed_disks); 1686 1650 1687 bOK = newtButton(16 + (raidrec->raid_level == -1), 9, _(" OK ")); 1651 1688 bCancel = newtButton(28, 9, _("Cancel")); … … 1654 1691 _("Additional settings and information")); 1655 1692 newtPushHelpLine 1656 (_(" Edit the RAID device's settings to your heart's content, then hit OK/Cancel.")); 1693 (_ 1694 (" Edit the RAID device's settings to your heart's content, then hit OK/Cancel.")); 1657 1695 editraidForm = newtForm(NULL, NULL, 0); 1658 1696 newtFormAddComponents(editraidForm, bSelectData, bSelectParity, … … 1691 1729 calculate_raid_device_size(mountlist, raidlist, 1692 1730 raidrec->raid_device); 1693 paranoid_free(title_of_editraidForm_window);1694 paranoid_free(sz_raid_level);1695 paranoid_free(sz_data_disks);1696 paranoid_free(sz_spare_disks);1697 paranoid_free(sz_parity_disks);1698 paranoid_free(sz_failed_disks);1699 1731 paranoid_free(bkp_raidrec); 1700 1732 #endif 1701 1733 } 1702 1703 1734 #ifdef __FreeBSD__ 1735 1704 1736 1705 1737 /** … … 1724 1756 1725 1757 /** buffers ***********************************************************/ 1726 char title_of_editraidForm_window[MAX_STR_LEN]; 1758 char *title_of_editraidForm_window = NULL; 1759 char *tmp = NULL; 1760 char *entry = NULL; 1727 1761 1728 1762 /** newt **************************************************************/ … … 1742 1776 void *curr_choice_a, *curr_choice_u; 1743 1777 int currline_a, currline_u; 1744 1745 struct mountlist_itself *unallocparts; 1746 1778 int i; 1779 1780 struct mountlist_itself *unallocparts = NULL; 1781 1782 /* BERLIOS: Check return value */ 1747 1783 unallocparts = malloc(sizeof(struct mountlist_itself)); 1748 1784 … … 1750 1786 memcpy((void *) &bkp_raidrec, (void *) raidrec, 1751 1787 sizeof(struct vinum_plex)); 1752 sprintf(title_of_editraidForm_window, "%s.p%i",1788 asprintf(&title_of_editraidForm_window, "%s.p%i", 1753 1789 raidlist->el[currline].volname, currline2); 1754 1790 newtPushHelpLine 1755 (_(" Please select a subdisk to edit, or edit this plex's parameters")); 1791 (_ 1792 (" Please select a subdisk to edit, or edit this plex's parameters")); 1756 1793 newtOpenWindow(13, 3, 54, 18, title_of_editraidForm_window); 1794 paranoid_free(title_of_editraidForm_window); 1795 1757 1796 for (;;) { 1758 int i;1759 char headerstr[MAX_STR_LEN];1760 char tmp[64];1761 snprintf(headerstr, MAX_STR_LEN, "%-24s %s", _("Subdisk"), _("Device"));1762 1763 1764 1797 switch (raidrec->raidlevel) { 1765 1798 case -1: 1766 strcpy(tmp, "concat");1799 asprintf(&tmp, "concat"); 1767 1800 break; 1768 1801 case 0: 1769 strcpy(tmp, "striped");1802 asprintf(&tmp, "striped"); 1770 1803 break; 1771 1804 case 5: 1772 strcpy(tmp, "raid5");1805 asprintf(&tmp, "raid5"); 1773 1806 break; 1774 1807 default: 1775 sprintf(tmp, _("unknown (%i)"), raidrec->raidlevel);1808 asprintf(&tmp, _("unknown (%i)"), raidrec->raidlevel); 1776 1809 break; 1777 1810 } 1778 1811 bLevel = newtCompactButton(2, 2, _(" RAID level ")); 1779 1812 sLevel = newtLabel(19, 2, tmp); 1813 paranoid_free(tmp); 1780 1814 1781 1815 if (raidrec->raidlevel >= 0) { 1782 sprintf(tmp, "%ik", raidrec->stripesize);1816 asprintf(&tmp, "%ik", raidrec->stripesize); 1783 1817 bStripeSize = newtCompactButton(2, 4, _(" Stripe size ")); 1784 1818 } else { 1785 strcpy(tmp, "N/A");1819 asprintf(&tmp, "N/A"); 1786 1820 bStripeSize = newtLabel(2, 4, _("Stripe size:")); 1787 1821 } 1788 1822 sStripeSize = newtLabel(19, 4, tmp); 1823 paranoid_free(tmp); 1789 1824 1790 1825 bOK = newtCompactButton(2, 16, _(" OK ")); … … 1796 1831 1797 1832 // plexesListbox = newtListbox (2, 7, 9, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT); 1798 // plexesHeader = newtLabel (2, 6, headerstr);1799 1833 unallocListbox = 1800 1834 newtListbox(2, 7, 7, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT); … … 1812 1846 raidlist); 1813 1847 for (i = 0; i < ARBITRARY_MAXIMUM; ++i) { 1814 char entry[MAX_STR_LEN];1815 1848 keylist[i] = (void *) i; 1816 1849 if (i < raidrec->subdisks) { 1817 snprintf(entry, MAX_STR_LEN, "%-17s",1850 asprintf(&entry, "%-17s", 1818 1851 find_dev_entry_for_raid_device_name(raidlist, 1819 1852 raidrec-> … … 1821 1854 which_device)); 1822 1855 newtListboxAppendEntry(allocListbox, entry, keylist[i]); 1856 paranoid_free(entry); 1823 1857 } 1824 1858 if (i < unallocparts->entries) { 1825 snprintf(entry, MAX_STR_LEN, "%-17s", 1826 unallocparts->el[i].device); 1859 asprintf(&entry, "%-17s", unallocparts->el[i].device); 1827 1860 newtListboxAppendEntry(unallocListbox, entry, keylist[i]); 1861 paranoid_free(entry); 1828 1862 } 1829 1863 } … … 1875 1909 choose_raid_level(raidrec); 1876 1910 } else if (b_res == bStripeSize) { 1877 char tmp[64]; 1878 sprintf(tmp, "%i", raidrec->stripesize); 1911 asprintf(&tmp, "%i", raidrec->stripesize); 1879 1912 if (popup_and_get_string 1880 1913 (_("Stripe size"), 1881 _("Please enter the stripe size in kilobytes."), tmp , 20)) {1914 _("Please enter the stripe size in kilobytes."), tmp)) { 1882 1915 raidrec->stripesize = atoi(tmp); 1883 1916 } 1917 paranoid_free(tmp); 1884 1918 } else if ((b_res == bAlloc) || (b_res == unallocListbox)) { 1885 1919 if (currline_u <= unallocparts->entries) … … 1922 1956 1923 1957 /** buffers ***********************************************************/ 1924 char header[MAX_STR_LEN];1925 char comment[MAX_STR_LEN];1926 char sz_out[MAX_STR_LEN];1958 char *header = NULL; 1959 char *comment = NULL; 1960 char *sz_out = NULL; 1927 1961 1928 1962 assert(raidrec != 0); 1929 1963 assert(lino >= 0); 1930 1964 1931 strcpy(sz_out, raidrec->additional_vars.el[lino].value);1932 sprintf(header, _("Edit %s"), raidrec->additional_vars.el[lino].label);1933 sprintf(comment, _("Please set %s's value (currently '%s')"),1965 asprintf(&sz_out, raidrec->additional_vars.el[lino].value); 1966 asprintf(&header, _("Edit %s"), raidrec->additional_vars.el[lino].label); 1967 asprintf(&comment, _("Please set %s's value (currently '%s')"), 1934 1968 raidrec->additional_vars.el[lino].label, sz_out); 1935 if (popup_and_get_string(header, comment, sz_out, MAX_STR_LEN)) { 1936 strip_spaces(sz_out); 1969 if (popup_and_get_string(header, comment, sz_out)) { 1937 1970 strcpy(raidrec->additional_vars.el[lino].value, sz_out); 1938 1971 } 1939 } 1940 1941 1942 /* I'm not racist against white people. I just don't like people who think Liberia is near Spain. - Hugo, 09/01/2001 */ 1943 1972 paranoid_free(header); 1973 paranoid_free(comment); 1974 paranoid_free(sz_out); 1975 } 1944 1976 #endif 1977 1945 1978 1946 1979 /** … … 1972 2005 1973 2006 /** ???? *************************************************************/ 1974 void *curr_choice ;2007 void *curr_choice = NULL; 1975 2008 void *keylist[ARBITRARY_MAXIMUM]; 1976 2009 … … 1981 2014 1982 2015 /** buffers **********************************************************/ 1983 char tmp[MAX_STR_LEN];1984 char flaws_str_A[MAX_STR_LEN];1985 char flaws_str_B[MAX_STR_LEN];1986 char flaws_str_C[MAX_STR_LEN];2016 char *tmp = NULL; 2017 char *flaws_str_A = NULL; 2018 char *flaws_str_B = NULL; 2019 char *flaws_str_C = NULL; 1987 2020 1988 2021 assert(mountlist != NULL); 1989 2022 assert(raidlist != NULL); 1990 2023 1991 strcpy(flaws_str_A, "xxxxxxxxx");1992 strcpy(flaws_str_B, "xxxxxxxxx");1993 strcpy(flaws_str_C, "xxxxxxxxx");2024 asprintf(&flaws_str_A, "xxxxxxxxx"); 2025 asprintf(&flaws_str_B, "xxxxxxxxx"); 2026 asprintf(&flaws_str_C, "xxxxxxxxx"); 1994 2027 if (mountlist->entries > ARBITRARY_MAXIMUM) { 1995 2028 log_to_screen(_("Arbitrary limits suck, man!")); … … 1997 2030 } 1998 2031 newtPushHelpLine 1999 (_(" Please edit the mountlist to your satisfaction, then click OK or Cancel.")); 2032 (_ 2033 (" Please edit the mountlist to your satisfaction, then click OK or Cancel.")); 2000 2034 i = 4; 2001 2035 bAdd = newtCompactButton(i, 17, _(" Add ")); … … 2005 2039 bCancel = newtCompactButton(i += 12, 17, _("Cancel")); 2006 2040 bOK = newtCompactButton(i += 12, 17, _(" OK ")); 2007 sprintf(tmp, "%-24s %-24s %-8s %s", _("Device"), _("Mountpoint"), _("Format"),2008 _(" Size (MB)"));2041 asprintf(&tmp, "%-24s %-24s %-8s %s", _("Device"), _("Mountpoint"), 2042 _("Format"), _("Size (MB)")); 2009 2043 headerMsg = newtLabel(2, 1, tmp); 2010 2044 flawsLabelA = newtLabel(2, 13, flaws_str_A); … … 2026 2060 newtLabelSetText(flawsLabelC, flaws_str_C); 2027 2061 b_res = newtRunForm(myForm); 2062 /* BERLIOS: This needs to be re-written */ 2028 2063 if (b_res == bOK) { 2029 2064 if (!evaluate_mountlist … … 2035 2070 finished = 2036 2071 ask_me_yes_or_no 2037 (_("Are you sure you want to save your mountlist and continue? (No changes will be made to your partition table at this time.)")); 2072 (_ 2073 ("Are you sure you want to save your mountlist and continue? (No changes will be made to your partition table at this time.)")); 2038 2074 } 2039 2075 } else if (b_res == bCancel) { … … 2041 2077 } else if (b_res == bReload) { 2042 2078 if (ask_me_yes_or_no(_("Reload original mountlist?"))) { 2043 /*2044 This would be really dumb. RAIDTAB_FNAME is #define'd. --- Hugo, 2003/04/242045 if (!RAIDTAB_FNAME[0])2046 {2047 strcpy(RAIDTAB_FNAME, "/etc/raidtab");2048 log_it("Warning - raidtab_fname is blank. Assuming %s", g_raidtab_fname);2049 }2050 */2051 2079 load_mountlist(mountlist, mountlist_fname); 2052 2080 load_raidtab_into_raidlist(raidlist, RAIDTAB_FNAME); … … 2076 2104 } else { 2077 2105 popup_and_OK 2078 (_("Please add an entry. Then press ENTER to edit it.")); 2106 (_ 2107 ("Please add an entry. Then press ENTER to edit it.")); 2079 2108 } 2080 2109 } 2081 2110 } 2082 2111 } 2112 paranoid_free(flaws_str_A); 2113 paranoid_free(flaws_str_B); 2114 paranoid_free(flaws_str_C); 2083 2115 } 2084 2116 newtFormDestroy(myForm); … … 2095 2127 2096 2128 2097 2098 2129 /** 2099 2130 * Edit the mountlist. … … 2107 2138 { 2108 2139 int res = 0; 2109 // char tmp[MAX_STR_LEN];2110 2140 2111 2141 iamhere("entering eml"); … … 2121 2151 return (res); 2122 2152 } 2123 2124 2125 2153 2126 2154 … … 2149 2177 2150 2178 /** ?? ***************************************************************/ 2151 void *keylist[ARBITRARY_MAXIMUM], *curr_choice ;2179 void *keylist[ARBITRARY_MAXIMUM], *curr_choice = NULL; 2152 2180 2153 2181 /** buffers **********************************************************/ 2154 char title_of_window[MAX_STR_LEN];2182 char *title_of_window = NULL; 2155 2183 2156 2184 /** int **************************************************************/ … … 2163 2191 memcpy((void *) &bkp_raidrec, (void *) raidrec, 2164 2192 sizeof(struct raid_device_record)); 2165 sprintf(title_of_window, "Additional variables");2193 asprintf(&title_of_window, "Additional variables"); 2166 2194 newtPushHelpLine 2167 (_(" Edit the additional fields to your heart's content, then click OK or Cancel.")); 2168 headerMsg = newtLabel(1, 1, _("Label Value")); 2195 (_ 2196 (" Edit the additional fields to your heart's content, then click OK or Cancel.")); 2197 headerMsg = 2198 newtLabel(1, 1, _("Label Value")); 2169 2199 varsListbox = 2170 2200 newtListbox(1, 2, 6, NEWT_FLAG_SCROLL | NEWT_FLAG_RETURNEXIT); … … 2176 2206 bCancel = newtCompactButton(i += 9, 9, _("Cancel")); 2177 2207 newtOpenWindow(17, 7, 46, 10, title_of_window); 2208 paranoid_free(title_of_window); 2209 2178 2210 myForm = newtForm(NULL, NULL, 0); 2179 2211 newtFormAddComponents(myForm, headerMsg, varsListbox, bAdd, bEdit, … … 2247 2279 2248 2280 2249 2250 2281 /** 2251 2282 * Locate @p device in @p raidlist. … … 2259 2290 char *device) 2260 2291 { 2261 2262 2292 /** int ***************************************************************/ 2263 2293 int i = 0; 2264 2294 #ifdef __FreeBSD__ 2265 char vdev[64]; 2266 #else 2267 // Linux 2295 char *vdev = NULL; 2268 2296 #endif 2269 2297 … … 2273 2301 #ifdef __FreeBSD__ 2274 2302 for (i = 0; i < raidlist->entries; i++) { 2275 sprintf(vdev, "/dev/vinum/%s", raidlist->el[i].volname); 2276 if (!strcmp(device, vdev)) 2303 asprintf(&vdev, "/dev/vinum/%s", raidlist->el[i].volname); 2304 if (!strcmp(device, vdev)) { 2305 paranoid_free(vdev); 2277 2306 break; 2307 } 2308 paranoid_free(vdev); 2278 2309 } 2279 2310 #else … … 2305 2336 /** initialize ********************************************************/ 2306 2337 2307 assert(isodir_device != NULL); 2308 assert(isodir_format != NULL); 2309 assert(isodir_path != NULL); 2310 2311 log_it("%d - AAA - isodir_path = %s", isodir_path); 2312 isodir_format[0] = '\0'; 2313 if (isodir_device[0] == '\0') { 2314 strcpy(isodir_device, "/dev/"); 2315 } 2316 if (isodir_path[0] == '\0') { 2317 strcpy(isodir_path, "/"); 2338 // %d no var ??? 2339 // log_it("%d - AAA - isodir_path = %s", isodir_path); 2340 if (isodir_device == NULL) { 2341 asprintf(&isodir_device, "/dev/"); 2342 } 2343 if (isodir_path == NULL) { 2344 asprintf(&isodir_path, "/"); 2318 2345 } 2319 2346 if (does_file_exist("/tmp/NFS-SERVER-PATH")) { 2320 strcpy(isodir_device, last_line_of_file("/tmp/NFS-SERVER-MOUNT")); 2321 strcpy(isodir_format, "nfs"); 2322 strcpy(isodir_path, last_line_of_file("/tmp/NFS-SERVER-PATH")); 2347 paranoid_free(isodir_device); 2348 isodir_device = last_line_of_file("/tmp/NFS-SERVER-MOUNT"); 2349 asprintf(&isodir_format, "nfs"); 2350 paranoid_free(isodir_path); 2351 isodir_path = last_line_of_file("/tmp/NFS-SERVER-PATH"); 2323 2352 } 2324 2353 if (nuke_me_please) { … … 2327 2356 2328 2357 if (popup_and_get_string 2329 (_("ISO Mode - device"), _("On what device do the ISO files live?"),2330 isodir_device, MAX_STR_LEN / 4)) {2358 (_("ISO Mode - device"), 2359 _("On what device do the ISO files live?"), isodir_device)) { 2331 2360 if (popup_and_get_string 2332 2361 (_("ISO Mode - format"), 2333 _("What is the disk format of the device? (Hit ENTER if you don't know.)"), 2334 isodir_format, 16)) { 2362 _ 2363 ("What is the disk format of the device? (Hit ENTER if you don't know.)"), 2364 isodir_format)) { 2335 2365 if (popup_and_get_string 2336 2366 (_("ISO Mode - path"), 2337 _("At what path on this device can the ISO files be found?"), 2338 isodir_path, MAX_STR_LEN / 4)) { 2339 strip_spaces(isodir_device); 2340 strip_spaces(isodir_format); 2341 strip_spaces(isodir_path); 2342 log_it("%d - BBB - isodir_path = %s", isodir_path); 2367 _ 2368 ("At what path on this device can the ISO files be found?"), 2369 isodir_path)) { 2370 // Same pb: 2371 // log_it("%d - BBB - isodir_path = %s", isodir_path); 2343 2372 return (TRUE); 2344 2373 } … … 2362 2391 int currline, char *device) 2363 2392 { 2364 2365 2393 /** structure *********************************************************/ 2366 2394 struct OSSWAP (raid_device_record, vinum_volume) * raidrec; … … 2415 2443 raidrec->additional_vars.entries = items; 2416 2444 } 2417 2418 2445 #endif 2446 2419 2447 2420 2448 /** … … 2433 2461 2434 2462 newtPushHelpLine 2435 (_("This is where I nuke your hard drives. Mhahahahaha. No-one can stop Mojo Jojo!")); 2463 (_ 2464 ("This is where I nuke your hard drives. Mhahahahaha. No-one can stop Mojo Jojo!")); 2436 2465 newtOpenWindow(24, 3, 32, 13, _("Nuking")); 2437 2466 b1 = newtButton(7, 1, _("Slowly")); … … 2447 2476 2448 2477 2449 2450 2478 /** 2451 2479 * Redraw the disklist. … … 2512 2540 2513 2541 2514 2515 2516 2542 /** 2517 2543 * Redraw the list of unallocated RAID partitions. … … 2531 2557 2532 2558 /** buffers **********************************************************/ 2533 char tmp[MAX_STR_LEN];2559 char *tmp = NULL; 2534 2560 2535 2561 assert(unallocated_raid_partitions != NULL); … … 2542 2568 } 2543 2569 for (i = 0; i < unallocated_raid_partitions->entries; i++) { 2544 sprintf(tmp, "%-22s %8lld",2570 asprintf(&tmp, "%-22s %8lld", 2545 2571 unallocated_raid_partitions->el[i].device, 2546 2572 unallocated_raid_partitions->el[i].size / 1024); 2547 2573 newtListboxAppendEntry(listbox, tmp, keylist[i]); 2548 } 2549 } 2574 paranoid_free(tmp); 2575 } 2576 } 2577 2550 2578 2551 2579 #ifndef __FreeBSD__ … … 2565 2593 2566 2594 /** buffers *********************************************************/ 2567 char tmp[MAX_STR_LEN];2595 char *tmp; 2568 2596 2569 2597 assert(additional_vars != NULL); … … 2577 2605 } 2578 2606 for (i = 0; i < additional_vars->entries; i++) { 2579 sprintf(tmp, "%-32s %-8s", additional_vars->el[i].label,2607 asprintf(&tmp, "%-32s %-8s", additional_vars->el[i].label, 2580 2608 additional_vars->el[i].value); 2581 2609 newtListboxAppendEntry(listbox, tmp, keylist[i]); 2610 paranoid_free(tmp); 2582 2611 } 2583 2612 } … … 2622 2651 #endif 2623 2652 2653 2624 2654 /** 2625 2655 * Change all RAID devices to use @p new_dev instead of @p old_dev. … … 2635 2665 { 2636 2666 /** buffers ********************************************************/ 2637 char tmp[MAX_STR_LEN];2667 char *tmp; 2638 2668 2639 2669 /** int ************************************************************/ … … 2647 2677 pos = which_raid_device_is_using_this_partition(raidlist, old_dev); 2648 2678 if (pos < 0) { 2649 sprintf(tmp, "No need to rejig %s in raidlist: it's not listed.",2679 asprintf(&tmp, "No need to rejig %s in raidlist: it's not listed.", 2650 2680 old_dev); 2651 2681 log_it(tmp); 2682 paranoid_free(tmp); 2652 2683 } else { 2653 2684 if ((j = … … 2681 2712 #endif 2682 2713 else { 2683 sprintf(tmp,2714 asprintf(&tmp, 2684 2715 "%s is supposed to be listed in this raid dev but it's not...", 2685 2716 old_dev); 2686 2717 log_it(tmp); 2718 paranoid_free(tmp); 2687 2719 } 2688 2720 } … … 2717 2749 res = read_variableINT_and_remove_from_raidvars(raidrec, "block-size"); 2718 2750 } 2751 2719 2752 2720 2753 /** … … 2734 2767 struct list_of_disks *disklist) 2735 2768 { 2736 void *curr_choice; 2737 2738 /** ??? ***************************************************************/ 2769 void *curr_choice = NULL; 2739 2770 2740 2771 /** structures ********************************************************/ 2741 struct raidlist_itself *bkp_raidlist ;2742 struct raid_device_record *bkp_raidrec ;2743 struct list_of_disks *bkp_disklist ;2744 struct mountlist_itself *unallocated_raid_partitions ;2772 struct raidlist_itself *bkp_raidlist = NULL; 2773 struct raid_device_record *bkp_raidrec = NULL; 2774 struct list_of_disks *bkp_disklist = NULL; 2775 struct mountlist_itself *unallocated_raid_partitions = NULL; 2745 2776 2746 2777 /** newt **************************************************************/ … … 2756 2787 /** buffers **********************************************************/ 2757 2788 void *keylist[ARBITRARY_MAXIMUM]; 2758 char *tmp ;2759 char *help_text ;2760 char *title_of_window ;2761 char *sz_res ;2762 char *header_text ;2789 char *tmp = NULL; 2790 char *help_text = NULL; 2791 char *title_of_window = NULL; 2792 char *sz_res = NULL; 2793 char *header_text = NULL; 2763 2794 2764 2795 /** int **************************************************************/ … … 2773 2804 2774 2805 iamhere("malloc'ing"); 2775 malloc_string(tmp);2776 malloc_string(help_text);2777 malloc_string(title_of_window);2778 malloc_string(sz_res);2779 malloc_string(header_text);2780 2806 if (!(bkp_raidrec = malloc(sizeof(struct raid_device_record)))) { 2781 2807 fatal_error("Cannot malloc space for raidrec"); … … 2801 2827 2802 2828 iamhere("Post-malloc"); 2803 strcpy(help_text, 2804 _(" Edit this RAID device's list of partitions. Choose OK or Cancel when done.")); 2805 sprintf(header_text, "%-24s %s", _("Device"), _("Index")); 2806 sprintf(title_of_window, _("%s contains..."), raidrec->raid_device); 2829 asprintf(&help_text, 2830 _ 2831 (" Edit this RAID device's list of partitions. Choose OK or Cancel when done.")); 2832 asprintf(&header_text, "%-24s %s", _("Device"), _("Index")); 2833 asprintf(&title_of_window, _("%s contains..."), raidrec->raid_device); 2807 2834 newtPushHelpLine(help_text); 2835 paranoid_free(help_text); 2808 2836 for (b_res = (newtComponent) 12345; b_res != bOK && b_res != bCancel;) { 2809 2837 headerMsg = newtLabel(1, 1, header_text); … … 2844 2872 if (unallocated_raid_partitions->entries <= 0) { 2845 2873 popup_and_OK 2846 (_("There are no unallocated partitions marked for RAID.")); 2874 (_ 2875 ("There are no unallocated partitions marked for RAID.")); 2847 2876 } else { 2848 2877 log_it 2849 (_("Done. The user may add one or more of the above to RAID device")); 2878 (_ 2879 ("Done. The user may add one or more of the above to RAID device")); 2850 2880 add_disklist_entry(disklist, raidrec->raid_device, 2851 2881 unallocated_raid_partitions); 2852 log_it(_("I have finished adding a disklist entry.")); 2882 log_it(_ 2883 ("I have finished adding a disklist entry.")); 2853 2884 redraw_disklist(disklist, keylist, 2854 2885 partitionsListbox); … … 2859 2890 redraw_disklist(disklist, keylist, partitionsListbox); 2860 2891 } else { 2861 sprintf(tmp, _("%s's index is %d. What should it be?"),2892 asprintf(&tmp, _("%s's index is %d. What should it be?"), 2862 2893 raidrec->raid_device, 2863 2894 disklist->el[currline].index); 2864 sprintf(sz_res, "%d", disklist->el[currline].index); 2865 if (popup_and_get_string(_("Set index"), tmp, sz_res, 10)) { 2895 asprintf(&sz_res, "%d", disklist->el[currline].index); 2896 if (popup_and_get_string 2897 (_("Set index"), tmp, sz_res)) { 2866 2898 disklist->el[currline].index = atoi(sz_res); 2867 2899 } 2900 paranoid_free(tmp); 2901 paranoid_free(sz_res); 2868 2902 redraw_disklist(disklist, keylist, partitionsListbox); 2869 2903 } … … 2873 2907 newtPopWindow(); 2874 2908 } 2909 paranoid_free(title_of_window); 2910 paranoid_free(header_text); 2911 2875 2912 newtPopHelpLine(); 2876 2913 if (b_res == bCancel) { … … 2882 2919 sizeof(struct list_of_disks)); 2883 2920 } 2884 paranoid_free(tmp);2885 paranoid_free(help_text);2886 paranoid_free(title_of_window);2887 paranoid_free(sz_res);2888 paranoid_free(header_text);2889 2921 paranoid_free(bkp_raidrec); 2890 2922 paranoid_free(bkp_disklist); … … 2895 2927 2896 2928 2897 2898 2929 /** 2899 2930 * Ask the user which restore mode (nuke, interactive, or compare) we should use. … … 2906 2937 /** char *************************************************************/ 2907 2938 char output = '\0'; 2908 char tmp[MAX_STR_LEN]; 2939 char *tmp = NULL; 2940 size_t n = 0; 2909 2941 2910 2942 /** newt *************************************************************/ … … 2920 2952 for (output = 'z'; !strchr("AICE", output); output = tmp[0]) { 2921 2953 printf 2922 (_("Which mode - (A)utomatic, (I)nteractive, \n(C)ompare only, or (E)xit to shell?\n--> ")); 2923 fgets(tmp, MAX_STR_LEN - 1, stdin); 2924 } 2954 (_ 2955 ("Which mode - (A)utomatic, (I)nteractive, \n(C)ompare only, or (E)xit to shell?\n--> ")); 2956 getline(&tmp, &n, stdin); 2957 } 2958 paranoid_free(tmp); 2925 2959 return (output); 2926 2960 } 2927 2961 2928 2962 newtPushHelpLine 2929 (_(" Do you want to 'nuke' your system, restore interactively, or just compare?")); 2963 (_ 2964 (" Do you want to 'nuke' your system, restore interactively, or just compare?")); 2930 2965 newtOpenWindow(24, 3, 32, 17, _("How should I restore?")); 2931 2966 b1 = newtButton(7, 1, _("Automatically"));
Note:
See TracChangeset
for help on using the changeset viewer.