Changeset 2384 in MondoRescue


Ignore:
Timestamp:
Sep 10, 2009, 1:02:56 PM (15 years ago)
Author:
Bruno Cornec
Message:
  • Remove separate function look_for_duplicate_mountpoints used only once and whose interface created problems with caller
Location:
branches/2.2.9/mondo/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mondo/src/common/libmondo-mountlist-EXT.h

    r2350 r2384  
    44extern int find_device_in_mountlist(struct mountlist_itself *mountlist,
    55                                    char *device);
    6 extern int look_for_duplicate_mountpoints(struct mountlist_itself
    7                                           *mountlist, char *flaws_str);
    86extern int make_list_of_drives_in_mountlist(struct mountlist_itself *,
    97                                            struct list_of_disks *);
  • branches/2.2.9/mondo/src/common/libmondo-mountlist.c

    r2380 r2384  
    511511    char *flaws_str = NULL;
    512512
     513    int currline = 0;
     514    int copies = 0;
     515    int last_copy = 0;
     516
     517    /*@ buffetr ********************************************************* */
     518    char *curr_mountpoint = NULL;
     519
    513520    /*@ int ************************************************************** */
    514521    int i = 0;
     
    548555        }
    549556    }
    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. */
    607559    for (currline = 0; currline < mountlist->entries; currline++) {
    608560        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++) {
    611562            if (!strcmp(mountlist->el[i].mountpoint, curr_mountpoint)
    612563                && strcmp(mountlist->el[i].mountpoint, "lvm")
     
    622573            log_it(tmp);
    623574            paranoid_free(tmp);
    624             res++;
     575            (*res)++;
    625576        }
    626577        paranoid_free(curr_mountpoint);
    627578    }
    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 */
     591int
     592find_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    }
    629609}
    630610
  • branches/2.2.9/mondo/src/common/libmondo-mountlist.h

    r2350 r2384  
    77int find_device_in_mountlist(struct mountlist_itself *mountlist,
    88                             char *device);
    9 int look_for_duplicate_mountpoints(struct mountlist_itself *mountlist,
    10                                    char *flaws_str);
    119int make_list_of_drives_in_mountlist(struct mountlist_itself *,
    1210                                     struct list_of_disks *);
  • branches/2.2.9/mondo/src/mondorestore/mondo-rstr-newt.h

    r2355 r2384  
    148148void log_file_end_to_screen(char *, char *);
    149149void log_to_screen(const char *fmt, ...);
    150 int look_for_duplicate_mountpoints(struct mountlist_itself *, char *);
    151150void make_list_of_unallocated_raid_partitions(struct mountlist_itself *,
    152151                                              struct mountlist_itself *,
Note: See TracChangeset for help on using the changeset viewer.