Changeset 2334 in MondoRescue for branches/2.2.10/mondo/src/mondorestore/mondo-rstr-newt.c
- Timestamp:
- Aug 18, 2009, 5:28:18 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note:
See TracChangeset
for help on using the changeset viewer.