Changeset 2546 in MondoRescue for branches/2.2.10/mondo/src/common/libmondo-devices.c
- Timestamp:
- Jan 21, 2010, 8:50:00 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-devices.c
r2508 r2546 1592 1592 ********/ 1593 1593 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); 1595 1595 return (-1); 1596 1596 } 1597 log_msg( 5, " %s looks like a device special file", dsf);1597 log_msg(4, " %s looks like a device special file", dsf); 1598 1598 /* Verify that the dsf exists */ 1599 1599 mr_asprintf(command, "ls -al %s 2>/dev/null | wc -l", dsf); … … 1610 1610 return (1); 1611 1611 } 1612 log_msg( 5, " %s device special file exists", dsf);1612 log_msg(4, " %s device special file exists", dsf); 1613 1613 1614 1614 /* Get a list of the mounted file systems */ … … 1624 1624 ********/ 1625 1625 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); 1627 1627 partition_list = call_program_and_get_last_line_of_output(command); 1628 1628 mr_free(command); … … 1642 1642 lastpos = 0; 1643 1643 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); 1645 1645 partitions[i++] = token; 1646 1646 } … … 1648 1648 } 1649 1649 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 1651 1660 /* For the rest ndsf is the new dsf to deal with */ 1652 1661 /******** … … 1683 1692 /* See if it's swap. If it is, ignore it. */ 1684 1693 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); 1686 1695 tmp = call_program_and_get_last_line_of_output(command); 1687 1696 mr_free(command); 1688 1697 1689 log_msg( 4, " Return value: %s", tmp);1698 log_msg(5, " Return value: %s", tmp); 1690 1699 c = strlen(tmp); 1691 1700 mr_free(tmp); … … 1717 1726 log_msg(4, " It's not mounted. Checking to see if it's LVM..."); 1718 1727 1719 /* Get the partition ID; 8efor LVM */1720 mr_asprintf(command, "p arted2fdisk -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); 1722 1731 tmp = call_program_and_get_last_line_of_output(command); 1723 1732 mr_free(command); 1724 1733 1725 1734 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)); 1733 1749 mr_free(command); 1734 1750 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)); 1742 1782 mr_free(command); 1743 1783 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); 1750 1789 mr_free(tmp); 1751 1790 mr_free(VG); … … 1754 1793 } 1755 1794 DSFptr->check = 1; 1756 mr_free(token);1757 1795 } 1758 /********1759 * Now we want to see if there are any software raid devices using1760 * 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);1801 1796 } 1797 mr_free(token); 1798 paranoid_free(mount_list); 1799 } else { 1800 log_msg (4, "Error finding Volume Group for partition %s", partitions[i]); 1802 1801 mr_free(tmp); 1803 mr_free(VG); 1804 continue; 1805 } 1802 return (1); 1803 } 1804 mr_free(tmp); 1805 continue; 1806 1806 } else { 1807 1807 log_msg (4, "Error finding partition type for the partition %s", partitions[i]); … … 1880 1880 while (DSFptr != NULL) { 1881 1881 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); 1883 1883 strcat(*included_dsf_list, DSFptr->mount_point); 1884 1884 strcat(*included_dsf_list, " "); … … 1907 1907 char *not_mounted_on_dsf = NULL; 1908 1908 char token_chars[] =" \t\r\f\a\0\n"; 1909 char *tmp = NULL; 1910 char *tmp1 = NULL; 1909 1911 1910 1912 while ((token = mr_strtok(pathlist, token_chars, &lastpos)) != NULL) { … … 1946 1948 /* A device special file was not passed in. Process it as a path. */ 1947 1949 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); 1948 1952 if (mode == 'E') { 1949 1953 /* 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); 1952 1957 } 1953 1958 } else { 1954 1959 /* 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); 1959 1967 break; 1960 1968 }
Note:
See TracChangeset
for help on using the changeset viewer.