Changeset 2527 in MondoRescue
- Timestamp:
- Jan 7, 2010, 7:28:10 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mondo/src/common/libmondo-devices.c
r2525 r2527 1657 1657 ********/ 1658 1658 if (strncmp(dsf, "/dev/", 5)) { 1659 log_msg ( 5, "%s does not start with /dev/ and (probably) is not a device special file", dsf);1659 log_msg (4, "%s does not start with /dev/ and (probably) is not a device special file", dsf); 1660 1660 return (-1); 1661 1661 } 1662 log_msg( 5, " %s looks like a device special file", dsf);1662 log_msg(4, " %s looks like a device special file", dsf); 1663 1663 /* Verify that the dsf exists */ 1664 1664 mr_asprintf(&command, "ls -al %s 2>/dev/null | wc -l", dsf); … … 1675 1675 return (1); 1676 1676 } 1677 log_msg( 5, " %s device special file exists", dsf);1677 log_msg(4, " %s device special file exists", dsf); 1678 1678 1679 1679 /* Get a list of the mounted file systems */ … … 1689 1689 ********/ 1690 1690 mr_asprintf(&command, "parted2fdisk -l %s 2>/dev/null|grep -E \"^/dev/\"|awk '{printf(\"%%s \", $1)}END{print \"\"}'", dsf); 1691 log_msg( 4, "Executing: %s", command);1691 log_msg(5, "Executing: %s", command); 1692 1692 mr_asprintf(&partition_list, "%s", call_program_and_get_last_line_of_output(command)); 1693 1693 paranoid_free(command); … … 1704 1704 lastpos = 0; 1705 1705 while ((token = mr_strtok(partition_list, token_chars, &lastpos)) != NULL) { 1706 log_msg ( 5, "Found partition: %s", token);1706 log_msg (4, "Found partition: %s", token); 1707 1707 strcpy(partitions[i++], token); 1708 1708 mr_free(token); … … 1711 1711 } 1712 1712 mr_free(partition_list); 1713 1713 1714 /* In any case we want to exclude the dsf itself from all MondRescue activities 1715 * at restore time (LVM, fdisk, ...) so we want it in our exclude_dev list */ 1716 if ((DSFptr = find_device_in_list(dsf)) == NULL) { 1717 log_msg (4, "Can't find device %s in mounted file systems list", dsf); 1718 paranoid_free(tmp); 1719 mr_free(token); 1720 return (1); 1721 } 1722 DSFptr->check = 1; 1723 1714 1724 /* For the rest ndsf is the new dsf to deal with */ 1715 1725 /******** … … 1747 1757 mr_asprintf(&command, "parted2fdisk -l %s 2>/dev/null | awk '{if(($1==\"%s\")&&(toupper($0) ~ \"SWAP\")){print $1;exit}}'", 1748 1758 ndsf, partitions[i]); 1749 log_msg( 4, " Running: %s", command);1759 log_msg(5, " Running: %s", command); 1750 1760 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 1751 1761 paranoid_free(command); 1752 log_msg( 4, " Return value: %s", tmp);1762 log_msg(5, " Return value: %s", tmp); 1753 1763 c = strlen(tmp); 1754 1764 paranoid_free(tmp); … … 1775 1785 /* It's not swap and it's not mounted. See if it's LVM */ 1776 1786 log_msg(4, " It's not mounted. Checking to see if it's LVM..."); 1777 /* Get the partition ID; 8efor LVM */1778 mr_asprintf(&command, "p arted2fdisk -l %s |awk '{if($1 ~ \"^%s\"){print $5}}'", ndsf, partitions[i]);1779 log_msg( 4, " Running: %s", command);1787 /* Check for LVM */ 1788 mr_asprintf(&command, "pvdisplay -c %s | grep '%s:' 2> /dev/null", partitions[i], partitions[i]); 1789 log_msg(5, " Running: %s", command); 1780 1790 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 1781 1791 paranoid_free(command); 1782 1792 if (strlen(tmp)) { 1783 log_msg(4, " Partition ID: %s", tmp); 1784 if (!strcasecmp(tmp, "8e")) { 1785 /* It's LVM: Find the VG it's in */ 1786 log_msg(4, " It's LVM: Find the VG it's in..."); 1787 mr_asprintf(&command, "pvdisplay -v %s 2>/dev/null|grep \"VG Name\"|awk '{print $NF}'", partitions[i]); 1788 log_msg(4, " Running: %s", command); 1789 strcpy(VG, call_program_and_get_last_line_of_output(command)); 1793 log_msg(4, "Found an LVM partition at %s. Find the VG it's in...", partitions[i]); 1794 /* It's LVM: Find the VG it's in */ 1795 mr_asprintf(&command, "pvdisplay -v %s 2>/dev/null|grep \"VG Name\"|awk '{print $NF}'", partitions[i]); 1796 log_msg(5, " Running: %s", command); 1797 strcpy(VG, call_program_and_get_last_line_of_output(command)); 1798 paranoid_free(command); 1799 log_msg(4, " Volume Group: %s", VG); 1800 if (strlen(VG)) { 1801 /* Found the Volume Group. Now find all of the VG's mount points */ 1802 log_msg(4, " Found the Volume Group. Now find all of the VG's mount points"); 1803 mr_asprintf(&command, "mount 2>/dev/null|grep -E \"/dev/mapper/%s-|/dev/%s/\"|awk '{printf(\"%%s \",$3)}END{print \"\"}'", VG, VG); 1804 log_msg(5, " Running: %s", command); 1805 mr_asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command)); 1790 1806 paranoid_free(command); 1791 log_msg(4, " Volume Group: %s", VG); 1792 if (strlen(VG)) { 1793 /* Found the Volume Group. Now find all of the VG's mount points */ 1794 log_msg(4, " Found the Volume Group. Now find all of the VG's mount points"); 1795 mr_asprintf(&command, "mount 2>/dev/null|grep -E \"/dev/mapper/%s-|/dev/%s/\"|awk '{printf(\"%%s \",$3)}END{print \"\"}'", VG, VG); 1796 log_msg(4, " Running: %s", command); 1797 mr_asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command)); 1807 log_msg(4, " VG %s mount_list: %s", VG, mount_list); 1808 lastpos = 0; 1809 while ((token = mr_strtok(mount_list, token_chars, &lastpos)) != NULL) { 1810 log_msg (5, "mount point token: %s", token); 1811 if ((DSFptr = find_mount_point_in_list(token)) == NULL) { 1812 log_msg (4, "Can't find mount point %s in mounted file systems list", token); 1813 paranoid_free(tmp); 1814 mr_free(token); 1815 return (1); 1816 } 1817 DSFptr->check = 1; 1818 mr_free(token); 1819 } 1820 /******** 1821 * Now we want to see if there are any software raid devices using 1822 * any of the Logical Volumes on the Volume Group. 1823 *******/ 1824 paranoid_free(mount_list); 1825 1826 mr_asprintf(&command, "%s", "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'"); 1827 log_msg (5, "Running: %s", command); 1828 mr_asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command)); 1829 paranoid_free(command); 1830 log_msg(4, " Software raid device list: %s", mount_list); 1831 lastpos = 0; 1832 while ((token = mr_strtok(mount_list, token_chars, &lastpos)) != NULL) { 1833 mr_asprintf(&command, "mdadm --detail %s 2>/dev/null | grep -c %s", token, VG); 1834 log_msg (5, "Running: %s", command); 1835 paranoid_free(tmp); 1836 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command)); 1798 1837 paranoid_free(command); 1799 log_msg(4, " VG %s mount_list: %s", VG, mount_list); 1800 lastpos = 0; 1801 while ((token = mr_strtok(mount_list, token_chars, &lastpos)) != NULL) { 1802 log_msg (5, "mount point token: %s", token); 1803 if ((DSFptr = find_mount_point_in_list(token)) == NULL) { 1804 log_msg (4, "Can't find mount point %s in mounted file systems list", token); 1838 log_msg(4, "Number of Software raid device: %s", tmp); 1839 if (atoi(tmp)) { 1840 /* This device is on our disk */ 1841 if ((DSFptr = find_device_in_list(token)) == NULL) { 1842 log_msg (4, "Can't find device %s in mounted file systems list", token); 1805 1843 paranoid_free(tmp); 1806 1844 mr_free(token); … … 1808 1846 } 1809 1847 DSFptr->check = 1; 1810 mr_free(token);1811 1848 } 1812 /********1813 * Now we want to see if there are any software raid devices using1814 * any of the Logical Volumes on the Volume Group.1815 *******/1816 paranoid_free(mount_list);1817 1818 mr_asprintf(&command, "%s", "cat /proc/mdstat|grep -iv Personal|awk '{if($0~\"^.*[ ]+:\"){printf(\"/dev/%s \", $1)}}END{print \"\"}'");1819 log_msg (5, "Running: %s", command);1820 mr_asprintf(&mount_list, "%s", call_program_and_get_last_line_of_output(command));1821 paranoid_free(command);1822 log_msg(4, " Software raid device list: %s", mount_list);1823 lastpos = 0;1824 while ((token = mr_strtok(mount_list, token_chars, &lastpos)) != NULL) {1825 mr_asprintf(&command, "mdadm --detail %s 2>/dev/null | grep -c %s", token, VG);1826 log_msg (5, "Running: %s", command);1827 paranoid_free(tmp);1828 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));1829 paranoid_free(command);1830 log_msg(4, "Number of Software raid device: %s", tmp);1831 if (atoi(tmp)) {1832 /* This device is on our disk */1833 if ((DSFptr = find_device_in_list(token)) == NULL) {1834 log_msg (4, "Can't find device %s in mounted file systems list", token);1835 paranoid_free(tmp);1836 mr_free(token);1837 return (1);1838 }1839 DSFptr->check = 1;1840 }1841 }1842 mr_free(token);1843 paranoid_free(mount_list);1844 } else {1845 log_msg (4, "Error finding Volume Group for partition %s", partitions[i]);1846 paranoid_free(tmp);1847 return (1);1848 1849 } 1850 mr_free(token); 1851 paranoid_free(mount_list); 1852 } else { 1853 log_msg (4, "Error finding Volume Group for partition %s", partitions[i]); 1849 1854 paranoid_free(tmp); 1850 continue; 1851 } 1855 return (1); 1856 } 1857 paranoid_free(tmp); 1858 continue; 1852 1859 } else { 1853 1860 log_msg (4, "Error finding partition type for the partition %s", partitions[i]); … … 1917 1924 while (DSFptr != NULL) { 1918 1925 if (DSFptr->check) { 1919 log_msg ( 5, "%s is mounted on %s and is on disk %s\n", DSFptr->device, DSFptr->mount_point, ndsf);1926 log_msg (4, "%s is mounted on %s and is on disk %s\n", DSFptr->device, DSFptr->mount_point, ndsf); 1920 1927 strcat(*included_dsf_list, DSFptr->mount_point); 1921 1928 strcat(*included_dsf_list, " ");
Note:
See TracChangeset
for help on using the changeset viewer.