Ignore:
Timestamp:
Jan 21, 2010, 8:50:00 PM (14 years ago)
Author:
Bruno Cornec
Message:

svn merge -r 2523:2545 /mondorescue/branches/2.2.9

  • Adds the --rescue flag to ntfsclone (Andree Leidenfrost andree_at_debian.org)
  • Fix 2 typos in the HOWTO (reported by Bram Mertens bram-mertens_at_linux.be)
  • Patch from Rogério Brito rbrito_at_ime.usp.br which fixes errors in man pages format
  • Fix syntax issue in analyze-my-lvm
  • Better doc for pre and post
  • Finally the function ListLvmDrivesAndPartitions is used, as it creates info parsed by mindi !! So reverting back to filter excluded devices in it
  • Better exclusion of the LVs from the mountlist at restore time if excludedevs used
  • Exclude LVs whose VGs are excluded now in analyze-my-lvm
  • First attempt to support device exclusion at restore time through a new boot param excludedevs
  • Fix a bug preventing execution of the pre script in init
  • LVM exclusion based on devices was flawed as the function targeted was not really useful. That script shold be fully rewritten to have a data structure contaiing what is needed. Anyway the current patch should allow to have some improvements
  • Do not report Duplicate mount point when lvm is used
  • each device of the EXCLUDE_DEVS list is now used correctly and partitions found on this device are excluded
  • Fix the way the dsf is declared in the linked list to have it work
  • Fix #383 by using pvdisplay instead of relying on 8e as partition type
  • Try to fix #384 by always excluding the dfs per users wish
  • Also use the exclude dev feature in case of multipath and exclude resulting /dev/mapper/mpath type of files
  • Fix #381 by postfixing spaces at the end of the strings to be cheked in strstr
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.10/mondo/src/common/libmondo-devices.c

    r2508 r2546  
    15921592    ********/
    15931593    if (strncmp(dsf, "/dev/", 5)) {
    1594         log_msg (5, "%s does not start with /dev/ and (probably) is not a  device special file", dsf);
     1594        log_msg (4, "%s does not start with /dev/ and (probably) is not a  device special file", dsf);
    15951595        return (-1);
    15961596    }
    1597     log_msg(5, "  %s looks like a device special file", dsf);
     1597    log_msg(4, "  %s looks like a device special file", dsf);
    15981598    /* Verify that the dsf exists */
    15991599    mr_asprintf(command, "ls -al %s 2>/dev/null | wc -l", dsf);
     
    16101610        return (1);
    16111611    }
    1612     log_msg(5, "  %s device special file exists", dsf);
     1612    log_msg(4, "  %s device special file exists", dsf);
    16131613
    16141614    /* Get a list of the mounted file systems */
     
    16241624    ********/
    16251625    mr_asprintf(command, "parted2fdisk -l %s 2>/dev/null|grep -E \"^/dev/\"|awk '{printf(\"%%s \", $1)}END{print \"\"}'", dsf);
    1626     log_msg(4, "Executing: %s", command);
     1626    log_msg(5, "Executing: %s", command);
    16271627    partition_list = call_program_and_get_last_line_of_output(command);
    16281628    mr_free(command);
     
    16421642        lastpos = 0;
    16431643        while ((token = mr_strtok(partition_list, token_chars, &lastpos)) != NULL) {
    1644             log_msg (5, "Found partition: %s", token);
     1644            log_msg (4, "Found partition: %s", token);
    16451645            partitions[i++] = token;
    16461646        }
     
    16481648    }
    16491649    mr_free(partition_list);
    1650  
     1650
     1651    /* In any case we want to exclude the dsf itself from all MondRescue activities
     1652     * at restore time (LVM, fdisk, ...) so we want it in our exclude_dev list */
     1653    if ((DSFptr = (MOUNTED_FS_STRUCT *) calloc(1, sizeof(MOUNTED_FS_STRUCT))) == NULL) {
     1654        fatal_error ("Cannot allocate memory");
     1655    }
     1656    add_mounted_fs_struct(DSFptr);
     1657    strcpy(DSFptr->device, dsf);
     1658    DSFptr->check = 1;
     1659
    16511660    /*  For the rest ndsf is the new dsf to deal with */
    16521661    /********
     
    16831692        /* See if it's swap. If it is, ignore it. */
    16841693        mr_asprintf(command, "parted2fdisk -l %s 2>/dev/null | awk '{if(($1==\"%s\")&&(toupper($0) ~ \"SWAP\")){print $1;exit}}'", ndsf, partitions[i]);
    1685         log_msg(4, "  Running: %s", command);
     1694        log_msg(5, "  Running: %s", command);
    16861695        tmp = call_program_and_get_last_line_of_output(command);
    16871696        mr_free(command);
    16881697
    1689         log_msg(4, "  Return value: %s", tmp);
     1698        log_msg(5, "  Return value: %s", tmp);
    16901699        c = strlen(tmp);
    16911700        mr_free(tmp);
     
    17171726        log_msg(4, "  It's not mounted. Checking to see if it's LVM...");
    17181727
    1719         /* Get the partition ID; 8e for LVM */
    1720         mr_asprintf(command, "parted2fdisk -l %s |awk '{if($1 ~ \"^%s\"){print $5}}'", ndsf, partitions[i]);
    1721         log_msg(4, "  Running: %s", command);
     1728        /* Check for LVM */
     1729        mr_asprintf(command, "pvdisplay -c %s | grep '%s:' 2> /dev/null", partitions[i], partitions[i]);
     1730        log_msg(5, "  Running: %s", command);
    17221731        tmp = call_program_and_get_last_line_of_output(command);
    17231732        mr_free(command);
    17241733
    17251734        if (strlen(tmp)) {
    1726             log_msg(4, "  Partition ID: %s", tmp);
    1727             if (!strcasecmp(tmp, "8e")) {
    1728                 /* It's LVM: Find the VG it's in */
    1729                 log_msg(4, "  It's LVM: Find the VG it's in...");
    1730                 mr_asprintf(command, "pvdisplay -v %s 2>/dev/null|grep \"VG Name\"|awk '{print $NF}'", partitions[i]);
    1731                 log_msg(4, "  Running: %s", command);
    1732                 VG = call_program_and_get_last_line_of_output(command);
     1735            log_msg(4, "Found an LVM partition at %s. Find the VG it's in...", partitions[i]);
     1736            /* It's LVM: Find the VG it's in */
     1737            mr_asprintf(command, "pvdisplay -v %s 2>/dev/null|grep \"VG Name\"|awk '{print $NF}'", partitions[i]);
     1738            log_msg(5, "  Running: %s", command);
     1739            strcpy(VG, call_program_and_get_last_line_of_output(command));
     1740            mr_free(command);
     1741
     1742            log_msg(4, "  Volume Group: %s", VG);
     1743            if (strlen(VG)) {
     1744                /* Found the Volume Group. Now find all of the VG's mount points */
     1745                log_msg(4, "  Found the Volume Group. Now find all of the VG's mount points");
     1746                mr_asprintf(command, "mount 2>/dev/null|grep -E \"/dev/mapper/%s-|/dev/%s/\"|awk '{printf(\"%%s \",$3)}END{print \"\"}'", VG, VG);
     1747                log_msg(5, "  Running: %s", command);
     1748                mr_asprintf(mount_list, "%s", call_program_and_get_last_line_of_output(command));
    17331749                mr_free(command);
    17341750
    1735                 log_msg(4, "  Volume Group: %s", VG);
    1736                 if (strlen(VG)) {
    1737                     /* Found the Volume Group. Now find all of the VG's mount points */
    1738                     log_msg(4, "  Found the Volume Group. Now find all of the VG's mount points");
    1739                     mr_asprintf(command, "mount 2>/dev/null|grep -E \"/dev/mapper/%s-|/dev/%s/\"|awk '{printf(\"%%s \",$3)}END{print \"\"}'", VG, VG);
    1740                     log_msg(4, "  Running: %s", command);
    1741                     mount_list = call_program_and_get_last_line_of_output(command);
     1751                log_msg(4, "  VG %s mount_list: %s", VG, mount_list);
     1752                lastpos = 0;
     1753                while ((token = mr_strtok(mount_list, token_chars, &lastpos)) != NULL) {
     1754                    log_msg (5, "mount point token: %s", token);
     1755                    if ((DSFptr = find_mount_point_in_list(token)) == NULL) {
     1756                        log_msg (4, "Can't find mount point %s in mounted file systems list", token);
     1757                        mr_free(tmp);
     1758                        mr_free(token);
     1759                        return (1);
     1760                    }
     1761                    DSFptr->check = 1;
     1762                    mr_free(token);
     1763                }
     1764                /********
     1765                 * Now we want to see if there are any software raid devices using
     1766                 * any of the Logical Volumes on the Volume Group.
     1767                 *******/
     1768                mr_free(mount_list);
     1769
     1770                mr_asprintf(command, "%s", "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");
     1771                log_msg (5, "Running: %s", command);
     1772                mr_asprintf(mount_list, "%s", call_program_and_get_last_line_of_output(command));
     1773                mr_free(command);
     1774
     1775                log_msg(4, "  Software raid device list: %s", mount_list);
     1776                lastpos = 0;
     1777                while ((token = mr_strtok(mount_list, token_chars, &lastpos)) != NULL) {
     1778                    mr_asprintf(command, "mdadm --detail %s 2>/dev/null | grep -c %s", token, VG);
     1779                    log_msg (5, "Running: %s", command);
     1780                    mr_free(tmp);
     1781                    mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output(command));
    17421782                    mr_free(command);
    17431783
    1744                     log_msg(4, "  VG %s mount_list: %s", VG, mount_list);
    1745                     lastpos = 0;
    1746                     while ((token = mr_strtok(mount_list, token_chars, &lastpos)) != NULL) {
    1747                         log_msg (5, "mount point token: %s", token);
    1748                         if ((DSFptr = find_mount_point_in_list(token)) == NULL) {
    1749                             log_msg (4, "Can't find mount point %s in mounted file systems list", token);
     1784                    log_msg(4, "Number of Software raid device: %s", tmp);
     1785                    if (atoi(tmp)) {
     1786                        /* This device is on our disk */
     1787                        if ((DSFptr = find_device_in_list(token)) == NULL) {
     1788                            log_msg (4, "Can't find device %s in mounted file systems list", token);
    17501789                            mr_free(tmp);
    17511790                            mr_free(VG);
     
    17541793                        }
    17551794                        DSFptr->check = 1;
    1756                         mr_free(token);
    17571795                    }
    1758                     /********
    1759                      * Now we want to see if there are any software raid devices using
    1760                      * any of the Logical Volumes on the Volume Group.
    1761                      *******/
    1762                     mr_free(mount_list);
    1763 
    1764                     mr_asprintf(command, "%s", "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");
    1765                     log_msg (5, "Running: %s", command);
    1766                     mount_list = call_program_and_get_last_line_of_output(command);
    1767                     mr_free(command);
    1768 
    1769                     log_msg(4, "  Software raid device list: %s", mount_list);
    1770                     lastpos = 0;
    1771                     while ((token = mr_strtok(mount_list, token_chars, &lastpos)) != NULL) {
    1772                         mr_asprintf(command, "mdadm --detail %s 2>/dev/null | grep -c %s", token, VG);
    1773                         log_msg (5, "Running: %s", command);
    1774                         mr_free(tmp);
    1775 
    1776                         tmp = call_program_and_get_last_line_of_output(command);
    1777                         mr_free(command);
    1778 
    1779                         log_msg(4, "Number of Software raid device: %s", tmp);
    1780                         c = atoi(tmp);
    1781                         mr_free(tmp);
    1782 
    1783                         if (c) {
    1784                             /* This device is on our disk */
    1785                             if ((DSFptr = find_device_in_list(token)) == NULL) {
    1786                                 log_msg (4, "Can't find device %s in mounted file systems list", token);
    1787                                 mr_free(VG);
    1788                                 mr_free(token);
    1789                                 return (1);
    1790                             }
    1791                             DSFptr->check = 1;
    1792                         }
    1793                         mr_free(token);
    1794                     }
    1795                     mr_free(token);
    1796                     mr_free(mount_list);
    1797                 } else {
    1798                     log_msg (4, "Error finding Volume Group for partition %s", partitions[i]);
    1799                     mr_free(tmp);
    1800                     return (1);
    18011796                }
     1797                mr_free(token);
     1798                paranoid_free(mount_list);
     1799            } else {
     1800                log_msg (4, "Error finding Volume Group for partition %s", partitions[i]);
    18021801                mr_free(tmp);
    1803                 mr_free(VG);
    1804                 continue;
    1805             }
     1802                return (1);
     1803            }
     1804            mr_free(tmp);
     1805            continue;
    18061806        } else {
    18071807            log_msg (4, "Error finding partition type for the partition %s", partitions[i]);
     
    18801880    while (DSFptr != NULL) {
    18811881        if (DSFptr->check) {
    1882             log_msg (5, "%s is mounted on %s and is on disk %s\n", DSFptr->device, DSFptr->mount_point, ndsf);
     1882            log_msg (4, "%s is mounted on %s and is on disk %s\n", DSFptr->device, DSFptr->mount_point, ndsf);
    18831883            strcat(*included_dsf_list, DSFptr->mount_point);
    18841884            strcat(*included_dsf_list, " ");
     
    19071907char *not_mounted_on_dsf = NULL;
    19081908char token_chars[] =" \t\r\f\a\0\n";
     1909char *tmp = NULL;
     1910char *tmp1 = NULL;
    19091911
    19101912while ((token = mr_strtok(pathlist, token_chars, &lastpos)) != NULL) {
     
    19461948    /* A device special file was not passed in. Process it as a path. */
    19471949    case -1:
     1950        /* we need to add a space after token to be sure our strstr test works correctly */
     1951        mr_asprintf(tmp1,"%s ",token);
    19481952        if (mode == 'E') {
    19491953            /*  Add the token if not already in the list */
    1950             if (strstr(bkpinfo->exclude_paths,token) == NULL) {
    1951                 mr_strcat(bkpinfo->exclude_paths, " %s ", token);
     1954            mr_asprintf(&tmp,"%s ",bkpinfo->exclude_paths);
     1955            if (strstr(tmp,tmp1) == NULL) {
     1956                mr_strcat(bkpinfo->exclude_paths, " %s", tmp1);
    19521957            }
    19531958        } else {
    19541959            /*  Add the token if not already in the list */
    1955             if (strstr(bkpinfo->include_paths,token) == NULL) {
    1956                 mr_strcat(bkpinfo->include_paths, " %s ", token);
    1957             }
    1958         }
     1960            mr_asprintf(&tmp,"%s ",bkpinfo->include_paths);
     1961            if (strstr(tmp,tmp1) == NULL) {
     1962                mr_strcat(bkpinfo->include_paths, " %s", tmp1);
     1963            }
     1964        }
     1965        mr_free(tmp);
     1966        mr_free(tmp1);
    19591967        break;
    19601968    }
Note: See TracChangeset for help on using the changeset viewer.