Changeset 2516 in MondoRescue
- Timestamp:
- Jan 4, 2010, 7:36:12 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mondo/src/common/libmondo-mountlist.c
r2394 r2516 58 58 59 59 /*@ buffers ******************************************************** */ 60 char tmp [MAX_STR_LEN];60 char tmp = NULL; 61 61 char device[MAX_STR_LEN]; 62 62 char mountpoint[MAX_STR_LEN]; … … 73 73 /*@ initialize ***************************************************** */ 74 74 prev_part_no = 0; 75 tmp[0] = '\0';76 75 mr_asprintf(&flaws_str, "%s", ""); 77 76 … … 80 79 81 80 if (physical_drive_size < 0) { 82 sprintf(tmp, " %s does not exist.", drive);81 mr_asprintf(&tmp, " %s does not exist.", drive); 83 82 mr_strcat(flaws_str, "%s", tmp); 84 83 } else { 85 sprintf(tmp, "%s is %ld MB", drive, physical_drive_size);84 mr_asprintf(&tmp, "%s is %ld MB", drive, physical_drive_size); 86 85 } 87 86 log_it(tmp); 87 mr_free(tmp); 88 88 89 89 … … 104 104 /* is it too big? */ 105 105 if (curr_part_no > 'h') { 106 sprintf(tmp, " Can only have up to 'h' in disklabel.");106 mr_asprintf(&tmp, " Can only have up to 'h' in disklabel."); 107 107 log_it(tmp); 108 108 mr_strcat(flaws_str, tmp); 109 mr_free(tmp); 109 110 res++; 110 111 } … … 117 118 } 118 119 if (device_copies > 1) { 119 sprintf(tmp, " %s %s's.", number_to_text(device_copies), 120 device); 120 mr_asprintf(&tmp, " %s %s's.", number_to_text(device_copies), device); 121 121 if (!strstr(flaws_str, tmp)) { 122 122 log_it(tmp); … … 124 124 res++; 125 125 } 126 mr_free(tmp); 126 127 } 127 128 /* silly partition size? */ 128 129 if (mountlist->el[pos].size < 8192 129 130 && strcmp(mountlist->el[pos].mountpoint, "lvm")) { 130 sprintf(tmp, " %s is tiny!", device);131 mr_asprintf(&tmp, " %s is tiny!", device); 131 132 log_it(tmp); 132 133 mr_strcat(flaws_str, tmp); 134 mr_free(tmp); 133 135 res++; 134 136 } … … 140 142 && strcmp(mountlist->el[pos].mountpoint, "none") 141 143 && mountlist->el[pos].mountpoint[0] != '/') { 142 sprintf(tmp, " %s has a weird mountpoint.", device);144 mr_asprintf(&tmp, " %s has a weird mountpoint.", device); 143 145 log_it(tmp); 144 146 mr_strcat(flaws_str, tmp); 147 mr_free(tmp); 145 148 res++; 146 149 } 147 150 /* is format sensible? */ 148 151 if (!is_this_a_valid_disk_format(mountlist->el[pos].format)) { 149 sprintf(tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);152 mr_asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format); 150 153 log_it(tmp); 151 154 mr_strcat(flaws_str, tmp); 155 mr_free(tmp); 152 156 res++; 153 157 } … … 178 182 if (curr_part_no - prev_part_no > 1) { 179 183 if (prev_part_no == 0) { 180 sprintf(tmp, " Gap prior to %s.", device);184 mr_asprintf(&tmp, " Gap prior to %s.", device); 181 185 log_it(tmp); 182 186 mr_strcat(flaws_str, "%s", tmp); 187 mr_free(tmp); 183 188 res++; 184 189 } else if (curr_part_no > 5 185 190 || (curr_part_no <= 4 && prev_part_no > 0)) { 186 sprintf(tmp, " Gap between %ss%d and %d.", drive, 187 prev_part_no, curr_part_no); 191 mr_asprintf(&tmp, " Gap between %ss%d and %d.", drive, prev_part_no, curr_part_no); 188 192 log_it(tmp); 189 193 mr_strcat(flaws_str, "%s", tmp); 194 mr_free(tmp); 190 195 res++; 191 196 } … … 196 201 if ((curr_part_no >= 5 && prev_part_no == 4) 197 202 && (strcmp(part_table_fmt, "MBR") == 0)) { 198 sprintf(tmp, " Partition %ss4 is occupied.", drive);203 mr_asprintf(&tmp, " Partition %ss4 is occupied.", drive); 199 204 log_it(tmp); 200 205 mr_strcat(flaws_str, "%s", tmp); 206 mr_free(tmp); 201 207 res++; 202 208 } … … 209 215 } 210 216 if (device_copies > 1) { 211 sprintf(tmp, " %s %s's.", number_to_text(device_copies), 212 device); 217 mr_asprintf(&tmp, " %s %s's.", number_to_text(device_copies), device); 213 218 if (!strstr(flaws_str, "%s", tmp)) { 214 219 log_it(tmp); … … 216 221 res++; 217 222 } 223 mr_free(tmp); 218 224 } 219 225 /* silly partition size? */ 220 226 if (mountlist->el[pos].size < 8192 221 227 && strcmp(mountlist->el[pos].mountpoint, "lvm")) { 222 sprintf(tmp, " %s is tiny!", device);228 mr_asprintf(&tmp, " %s is tiny!", device); 223 229 log_it(tmp); 224 230 mr_strcat(flaws_str, "%s", tmp); 231 mr_free(tmp); 225 232 res++; 226 233 } … … 232 239 && strcmp(mountlist->el[pos].mountpoint, "none") 233 240 && mountlist->el[pos].mountpoint[0] != '/') { 234 sprintf(tmp, " %s has a weird mountpoint.", device);241 mr_asprintf(&tmp, " %s has a weird mountpoint.", device); 235 242 log_it(tmp); 236 243 mr_strcat(flaws_str, "%s", tmp); 244 mr_free(tmp); 237 245 res++; 238 246 } 239 247 /* is format sensible? */ 240 248 if (!is_this_a_valid_disk_format(mountlist->el[pos].format)) { 241 sprintf(tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);249 mr_asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format); 242 250 log_it(tmp); 243 251 mr_strcat(flaws_str, "%s", tmp); 252 mr_free(tmp); 244 253 res++; 245 254 } … … 255 264 /* is it too big? */ 256 265 if (curr_part_no > 'h') { 257 sprintf(tmp, " Can only have up to 'h' in disklabel.");266 mr_asprintf(&tmp, " Can only have up to 'h' in disklabel."); 258 267 log_it(tmp); 259 268 mr_strcat(flaws_str, "%s", tmp); 269 mr_free(tmp); 260 270 res++; 261 271 } … … 268 278 } 269 279 if (device_copies > 1) { 270 sprintf(tmp, " %s %s's.", 271 number_to_text(device_copies), device); 280 mr_asprintf(&tmp, " %s %s's.", number_to_text(device_copies), device); 272 281 if (!strstr(flaws_str, tmp)) { 273 282 log_it(tmp); … … 275 284 res++; 276 285 } 286 mr_free(tmp); 277 287 } 278 288 /* silly partition size? */ 279 289 if (mountlist->el[pos].size < 8192 280 290 && strcmp(mountlist->el[pos].mountpoint, "lvm")) { 281 sprintf(tmp, " %s is tiny!", device);291 mr_asprintf(&tmp, " %s is tiny!", device); 282 292 log_it(tmp); 283 293 mr_strcat(flaws_str, "%s", tmp); 294 mr_free(tmp); 284 295 res++; 285 296 } … … 291 302 && strcmp(mountlist->el[pos].mountpoint, "none") 292 303 && mountlist->el[pos].mountpoint[0] != '/') { 293 sprintf(tmp, " %s has a weird mountpoint.", device);304 mr_asprintf(&tmp, " %s has a weird mountpoint.", device); 294 305 log_it(tmp); 295 306 mr_strcat(flaws_str, "%s", tmp); 307 mr_free(tmp); 296 308 res++; 297 309 } … … 299 311 if (!is_this_a_valid_disk_format 300 312 (mountlist->el[pos].format)) { 301 sprintf(tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);313 mr_asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format); 302 314 log_it(tmp); 303 315 mr_strcat(flaws_str, "%s", tmp); 316 mr_free(tmp); 304 317 res++; 305 318 } … … 317 330 if (amount_allocated > physical_drive_size) // Used to be +1, but what if you're 1 MB too high? 318 331 { 319 sprintf(tmp, " %ld MB over-allocated on %s.",332 mr_asprintf(&tmp, " %ld MB over-allocated on %s.", 320 333 amount_allocated - physical_drive_size, drive); 321 334 log_it(tmp); 322 335 mr_strcat(flaws_str, "%s", tmp); 336 mr_free(tmp); 323 337 res++; 324 338 } else if (amount_allocated < physical_drive_size - 1) { /* NOT AN ERROR, JUST A WARNING :-) */ 325 sprintf(tmp, " %ld MB unallocated on %s.",339 mr_asprintf(&tmp, " %ld MB unallocated on %s.", 326 340 physical_drive_size - amount_allocated, drive); 327 341 log_it(tmp); 328 342 mr_strcat(flaws_str, "%s", tmp); 343 mr_free(tmp); 329 344 } 330 345 if (res) { … … 349 364 350 365 /*@ buffers ******************************************************** */ 351 char *tmp ;352 char *device ;366 char *tmp = NULL; 367 char *device = NULL; 353 368 char *flaws_str = NULL; 354 369 … … 365 380 mr_asprintf(&flaws_str, "%s", ""); 366 381 367 malloc_string(tmp);368 382 malloc_string(device); 369 383 prev_part_no = 0; 370 tmp[0] = '\0';371 372 384 373 385 physical_drive_size = get_phys_size_of_drive(drive); 374 386 375 387 if (physical_drive_size < 0) { 376 sprintf(tmp, " %s does not exist.", drive);388 mr_asprintf(&tmp, " %s does not exist.", drive); 377 389 log_it(tmp); 378 390 mr_strcat(flaws_str, "%s", tmp); 379 391 res++; 392 mr_free(tmp); 380 393 goto endoffunc; 381 394 } else { 382 sprintf(tmp, "%s is %ld MB", drive, physical_drive_size);395 mr_asprintf(&tmp, "%s is %ld MB", drive, physical_drive_size); 383 396 log_it(tmp); 397 mr_free(tmp); 384 398 } 385 399 … … 394 408 if (curr_part_no - prev_part_no > 1) { 395 409 if (prev_part_no == 0) { 396 sprintf(tmp, " Gap prior to %s.", device);410 mr_asprintf(&tmp, " Gap prior to %s.", device); 397 411 log_it(tmp); 398 412 mr_strcat(flaws_str, "%s", tmp); 413 mr_free(tmp); 399 414 res++; 400 415 } else if (curr_part_no > 5 401 416 || (curr_part_no <= 4 && prev_part_no > 0)) { 402 sprintf(tmp, " Gap on %s between %d and %d.", drive,417 mr_asprintf(&tmp, " Gap on %s between %d and %d.", drive, 403 418 prev_part_no, curr_part_no); 404 419 log_it(tmp); 405 420 mr_strcat(flaws_str, "%s", tmp); 421 mr_free(tmp); 406 422 res++; 407 423 } … … 412 428 if ((curr_part_no >= 5 && prev_part_no == 4) 413 429 && (strcmp(part_table_fmt, "MBR") == 0)) { 414 sprintf(tmp, " Partition 4 of %s is occupied.", drive);430 mr_asprintf(&tmp, " Partition 4 of %s is occupied.", drive); 415 431 log_it(tmp); 416 432 mr_strcat(flaws_str, "%s", tmp); 433 mr_free(tmp); 417 434 res++; 418 435 } … … 425 442 } 426 443 if (device_copies > 1) { 427 sprintf(tmp, " %s %s's.", number_to_text(device_copies),444 mr_asprintf(&tmp, " %s %s's.", number_to_text(device_copies), 428 445 device); 429 446 if (!strstr(flaws_str, tmp)) { … … 432 449 res++; 433 450 } 451 mr_free(tmp); 434 452 } 435 453 /* silly partition size? */ 436 454 if (mountlist->el[pos].size < 8192 437 455 && strcmp(mountlist->el[pos].mountpoint, "lvm")) { 438 sprintf(tmp, " %s is tiny!", device);456 mr_asprintf(&tmp, " %s is tiny!", device); 439 457 log_it(tmp); 440 458 mr_strcat(flaws_str, "%s", tmp); 459 mr_free(tmp); 441 460 res++; 442 461 } … … 447 466 && strcmp(mountlist->el[pos].mountpoint, "image") 448 467 && mountlist->el[pos].mountpoint[0] != '/') { 449 sprintf(tmp, " %s has a weird mountpoint.", device);468 mr_asprintf(&tmp, " %s has a weird mountpoint.", device); 450 469 log_it(tmp); 451 470 mr_strcat(flaws_str, "%s", tmp); 471 mr_free(tmp); 452 472 res++; 453 473 } 454 474 /* is format sensible? */ 455 475 if (!is_this_a_valid_disk_format(mountlist->el[pos].format)) { 456 sprintf(tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format);476 mr_asprintf(&tmp, " %s has unsupported format %s.", device, mountlist->el[pos].format); 457 477 log_it(tmp); 458 478 mr_strcat(flaws_str, "%s", tmp); 479 mr_free(tmp); 459 480 res++; 460 481 } … … 466 487 /* Over-allocated the disk? Unallocated space on disk? */ 467 488 if (amount_allocated > physical_drive_size + 1) { 468 sprintf(tmp, " %ld MB over-allocated on %s.",489 mr_asprintf(&tmp, " %ld MB over-allocated on %s.", 469 490 amount_allocated - physical_drive_size, drive); 470 491 log_it(tmp); 471 492 mr_strcat(flaws_str, "%s", tmp); 493 mr_free(tmp); 472 494 res++; 473 495 } else if (amount_allocated < physical_drive_size - 1) { /* NOT AN ERROR, JUST A WARNING :-) */ 474 sprintf(tmp, " %ld MB unallocated on %s.",496 mr_asprintf(&tmp, " %ld MB unallocated on %s.", 475 497 physical_drive_size - amount_allocated, drive); 476 498 log_it(tmp); 477 499 mr_strcat(flaws_str, "%s", tmp); 500 mr_free(tmp); 478 501 } 479 502 480 503 endoffunc: 481 paranoid_free(tmp);482 504 paranoid_free(device); 483 505
Note:
See TracChangeset
for help on using the changeset viewer.