Changeset 2384 in MondoRescue for branches/2.2.9/mondo/src/common
- Timestamp:
- Sep 10, 2009, 1:02:56 PM (16 years ago)
- Location:
- branches/2.2.9/mondo/src/common
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mondo/src/common/libmondo-mountlist-EXT.h
r2350 r2384 4 4 extern int find_device_in_mountlist(struct mountlist_itself *mountlist, 5 5 char *device); 6 extern int look_for_duplicate_mountpoints(struct mountlist_itself7 *mountlist, char *flaws_str);8 6 extern int make_list_of_drives_in_mountlist(struct mountlist_itself *, 9 7 struct list_of_disks *); -
branches/2.2.9/mondo/src/common/libmondo-mountlist.c
r2380 r2384 511 511 char *flaws_str = NULL; 512 512 513 int currline = 0; 514 int copies = 0; 515 int last_copy = 0; 516 517 /*@ buffetr ********************************************************* */ 518 char *curr_mountpoint = NULL; 519 513 520 /*@ int ************************************************************** */ 514 521 int i = 0; … … 548 555 } 549 556 } 550 *res += look_for_duplicate_mountpoints(mountlist, flaws_str); 551 return(flaws_str); 552 } 553 554 555 /** 556 * Find the index number of @p device in the mountlist. 557 * The device given must match @p mountlist->el[N].device exactly, case-sensitive. 558 * @param mountlist The mountlist to search in. 559 * @param device The device to search for. 560 * @return The zero-based index of the device, or -1 if it could not be found. 561 */ 562 int 563 find_device_in_mountlist(struct mountlist_itself *mountlist, char *device) 564 { 565 566 /*@ int ************************************************************** */ 567 int i = 0; 568 569 assert(mountlist != NULL); 570 assert_string_is_neither_NULL_nor_zerolength(device); 571 for (i = 0; 572 i < mountlist->entries 573 && strcmp(mountlist->el[i].device, device) != 0; i++); 574 575 if (i == mountlist->entries) { 576 return (-1); 577 } else { 578 return (i); 579 } 580 } 581 582 583 /** 584 * Look for duplicate mountpoints in @p mountlist. 585 * @param mountlist The mountlist to check. 586 * @param flaws_str The flaws string to append the results to. 587 * @return The number of mountpoints that have duplicates, or 0 for success. 588 */ 589 int 590 look_for_duplicate_mountpoints(struct mountlist_itself *mountlist, char *flaws_str) 591 { 592 593 /*@ int ************************************************************* */ 594 int res = 0; 595 int currline = 0; 596 int i = 0; 597 int copies = 0; 598 int last_copy = 0; 599 600 /*@ buffetr ********************************************************* */ 601 char *curr_mountpoint = NULL; 602 char *tmp = NULL; 603 604 assert(mountlist != NULL); 605 assert(flaws_str != NULL); 606 557 558 /* Look for duplicate mountpoints in mountlist. */ 607 559 for (currline = 0; currline < mountlist->entries; currline++) { 608 560 mr_asprintf(&curr_mountpoint, "%s", mountlist->el[currline].mountpoint); 609 for (i = 0, copies = 0, last_copy = -1; i < mountlist->entries; 610 i++) { 561 for (i = 0, copies = 0, last_copy = -1; i < mountlist->entries; i++) { 611 562 if (!strcmp(mountlist->el[i].mountpoint, curr_mountpoint) 612 563 && strcmp(mountlist->el[i].mountpoint, "lvm") … … 622 573 log_it(tmp); 623 574 paranoid_free(tmp); 624 res++;575 (*res)++; 625 576 } 626 577 paranoid_free(curr_mountpoint); 627 578 } 628 return (res); 579 580 return(flaws_str); 581 } 582 583 584 /** 585 * Find the index number of @p device in the mountlist. 586 * The device given must match @p mountlist->el[N].device exactly, case-sensitive. 587 * @param mountlist The mountlist to search in. 588 * @param device The device to search for. 589 * @return The zero-based index of the device, or -1 if it could not be found. 590 */ 591 int 592 find_device_in_mountlist(struct mountlist_itself *mountlist, char *device) 593 { 594 595 /*@ int ************************************************************** */ 596 int i = 0; 597 598 assert(mountlist != NULL); 599 assert_string_is_neither_NULL_nor_zerolength(device); 600 for (i = 0; 601 i < mountlist->entries 602 && strcmp(mountlist->el[i].device, device) != 0; i++); 603 604 if (i == mountlist->entries) { 605 return (-1); 606 } else { 607 return (i); 608 } 629 609 } 630 610 -
branches/2.2.9/mondo/src/common/libmondo-mountlist.h
r2350 r2384 7 7 int find_device_in_mountlist(struct mountlist_itself *mountlist, 8 8 char *device); 9 int look_for_duplicate_mountpoints(struct mountlist_itself *mountlist,10 char *flaws_str);11 9 int make_list_of_drives_in_mountlist(struct mountlist_itself *, 12 10 struct list_of_disks *);
Note:
See TracChangeset
for help on using the changeset viewer.