Changeset 2382 in MondoRescue for branches/2.2.10/mondo/src/common/libmondo-devices.c
- Timestamp:
- Sep 10, 2009, 2:07:16 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.10/mondo/src/common/libmondo-devices.c
r2376 r2382 54 54 */ 55 55 bool g_restoring_live_from_cd = FALSE; 56 bool g_restoring_live_from_n fs = FALSE;56 bool g_restoring_live_from_netfs = FALSE; 57 57 58 58 extern t_bkptype g_backup_media_type; // set by main() … … 164 164 mr_asprintf(output, "cdstream"); 165 165 break; 166 case n fs:167 mr_asprintf(output, "n fs");166 case netfs: 167 mr_asprintf(output, "netfs"); 168 168 break; 169 169 case tape: … … 1298 1298 mr_free(tmp); 1299 1299 1300 if (g_ISO_restore_mode || bkpinfo->backup_media_type == iso || bkpinfo->backup_media_type == n fs) {1300 if (g_ISO_restore_mode || bkpinfo->backup_media_type == iso || bkpinfo->backup_media_type == netfs) { 1301 1301 // BERLIOS --- I'm tempted to do something about this... 1302 1302 // Why unmount and remount again and again? … … 1310 1310 mr_free(tmp); 1311 1311 1312 if (((bkpinfo->isodir == NULL) && (bkpinfo->n fs_remote_dir == NULL)) || (bkpinfo->prefix == NULL)) {1312 if (((bkpinfo->isodir == NULL) && (bkpinfo->netfs_remote_dir == NULL)) || (bkpinfo->prefix == NULL)) { 1313 1313 fatal_error("Unable to prepare ISO file name. Please report to dev team"); 1314 1314 } 1315 if (bkpinfo->n fs_remote_dir) {1316 // N FS1317 mr_asprintf(tmp, "%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->n fs_remote_dir, bkpinfo->prefix, cd_number_i_want);1315 if (bkpinfo->netfs_remote_dir) { 1316 // NETFS 1317 mr_asprintf(tmp, "%s/%s/%s-%d.iso", bkpinfo->isodir, bkpinfo->netfs_remote_dir, bkpinfo->prefix, cd_number_i_want); 1318 1318 } else { 1319 1319 // ISO … … 1322 1322 if (!does_file_exist(tmp)) { 1323 1323 mr_free(tmp); 1324 if (bkpinfo->n fs_remote_dir) {1325 // N FS1326 mr_asprintf(tmp, "%s/isodir/%s/%s-%d.iso", bkpinfo->tmpdir, bkpinfo->n fs_remote_dir, bkpinfo->prefix, cd_number_i_want);1324 if (bkpinfo->netfs_remote_dir) { 1325 // NETFS 1326 mr_asprintf(tmp, "%s/isodir/%s/%s-%d.iso", bkpinfo->tmpdir, bkpinfo->netfs_remote_dir, bkpinfo->prefix, cd_number_i_want); 1327 1327 } else { 1328 1328 // ISO … … 1413 1413 bkpinfo->nonbootable_backup = FALSE; 1414 1414 1415 // Tape, CD, N FS, ...?1415 // Tape, CD, NETFS, ...? 1416 1416 srandom(getpid()); 1417 1417 bkpinfo->backup_media_type = … … 1647 1647 1648 1648 1649 case n fs:1650 /* Never try to eject a N FS device */1649 case netfs: 1650 /* Never try to eject a NETFS device */ 1651 1651 bkpinfo->please_dont_eject = TRUE; 1652 1652 1653 /* Initiate bkpinfo n fs_mount path from running environment if not already done */1654 if (bkpinfo->n fs_mount == NULL) {1655 mr_asprintf(bkpinfo->n fs_mount, "%s", call_program_and_get_last_line_of_output("mount | grep \":\" | cut -d' ' -f1 | head -n1"));1653 /* Initiate bkpinfo netfs_mount path from running environment if not already done */ 1654 if (bkpinfo->netfs_mount == NULL) { 1655 mr_asprintf(bkpinfo->netfs_mount, "%s", call_program_and_get_last_line_of_output("mount | grep \":\" | cut -d' ' -f1 | head -n1")); 1656 1656 } 1657 1657 #ifdef __FreeBSD__ … … 1661 1661 #endif 1662 1662 { 1663 p = popup_and_get_string("N FS dir.", "Please enter path and directory where archives are stored remotely. (Mondo has taken a guess at the correct value. If it is incorrect, delete it and type the correct one.)", bkpinfo->nfs_mount);1663 p = popup_and_get_string("Network shared dir.", "Please enter path and directory where archives are stored remotely. (Mondo has taken a guess at the correct value. If it is incorrect, delete it and type the correct one.)", bkpinfo->netfs_mount); 1664 1664 if (p == NULL) { 1665 1665 log_to_screen("User has chosen not to backup the PC"); 1666 1666 finish(1); 1667 1667 } 1668 mr_free(bkpinfo->n fs_mount);1669 bkpinfo->n fs_mount = p;1668 mr_free(bkpinfo->netfs_mount); 1669 bkpinfo->netfs_mount = p; 1670 1670 if (!bkpinfo->restore_data) { 1671 1671 if ((bkpinfo->compression_level = … … 1677 1677 // check whether already mounted - we better remove 1678 1678 // surrounding spaces and trailing '/' for this 1679 mr_strip_spaces(bkpinfo->n fs_mount);1680 if (bkpinfo->n fs_mount[strlen(bkpinfo->nfs_mount) - 1] == '/')1681 bkpinfo->n fs_mount[strlen(bkpinfo->nfs_mount) - 1] = '\0';1682 mr_asprintf(command, "mount | grep \"%s \" | cut -d' ' -f3", bkpinfo->n fs_mount);1679 mr_strip_spaces(bkpinfo->netfs_mount); 1680 if (bkpinfo->netfs_mount[strlen(bkpinfo->netfs_mount) - 1] == '/') 1681 bkpinfo->netfs_mount[strlen(bkpinfo->netfs_mount) - 1] = '\0'; 1682 mr_asprintf(command, "mount | grep \"%s \" | cut -d' ' -f3", bkpinfo->netfs_mount); 1683 1683 mr_free(bkpinfo->isodir); 1684 1684 mr_asprintf(bkpinfo->isodir, "%s", call_program_and_get_last_line_of_output(command)); … … 1711 1711 mr_free(command); 1712 1712 1713 p = popup_and_get_string("N FS share", "Which remote NFS share should I mount?", bkpinfo->nfs_mount);1713 p = popup_and_get_string("Network share", "Which remote Network share should I mount?", bkpinfo->netfs_mount); 1714 1714 if (p == NULL) { 1715 1715 log_to_screen("User has chosen not to backup the PC"); 1716 1716 finish(1); 1717 1717 } 1718 mr_free(bkpinfo->n fs_mount);1719 bkpinfo->n fs_mount = p;1718 mr_free(bkpinfo->netfs_mount); 1719 bkpinfo->netfs_mount = p; 1720 1720 } 1721 1721 /* Initiate bkpinfo isodir path from running environment if mount already done */ 1722 1722 mr_free(bkpinfo->isodir); 1723 if (is_this_device_mounted(bkpinfo->n fs_mount)) {1723 if (is_this_device_mounted(bkpinfo->netfs_mount)) { 1724 1724 mr_asprintf(bkpinfo->isodir, "%s", call_program_and_get_last_line_of_output("mount | grep \":\" | cut -d' ' -f3 | head -n1")); 1725 1725 1726 1726 } else { 1727 mr_asprintf(bkpinfo->isodir, "%s/n fsdir", bkpinfo->tmpdir);1727 mr_asprintf(bkpinfo->isodir, "%s/netfsdir", bkpinfo->tmpdir); 1728 1728 mr_asprintf(command, "mkdir -p %s", bkpinfo->isodir); 1729 1729 run_program_and_log_output(command, 5); … … 1731 1731 1732 1732 if (bkpinfo->restore_data) { 1733 mr_asprintf(tmp, "mount -t nfs -o nolock,ro %s %s", bkpinfo->nfs_mount, bkpinfo->isodir); 1733 if (strstr(bkpinfo->netfs_proto, "sshfs")) { 1734 mr_asprintf(tmp, "sshfs -o ro %s %s", bkpinfo->netfs_mount, bkpinfo->isodir); 1735 } else { 1736 mr_asprintf(tmp, "mount -t %s -o nolock,ro %s %s", bkpinfo->netfs_proto, bkpinfo->netfs_mount, bkpinfo->isodir); 1737 } 1734 1738 } else { 1735 mr_asprintf(tmp, "mount -t nfs -o nolock %s %s", bkpinfo->nfs_mount, bkpinfo->isodir); 1739 if (strstr(bkpinfo->netfs_proto, "sshfs")) { 1740 mr_asprintf(tmp, "sshfs %s %s", bkpinfo->netfs_mount, bkpinfo->isodir); 1741 } else { 1742 mr_asprintf(tmp, "mount -t %s -o nolock %s %s", bkpinfo->netfs_proto, bkpinfo->netfs_mount, bkpinfo->isodir); 1743 } 1736 1744 } 1737 1745 run_program_and_log_output(tmp, 3); … … 1741 1749 strcpy(g_selfmounted_isodir, bkpinfo->isodir); 1742 1750 } 1743 if (!is_this_device_mounted(bkpinfo->n fs_mount)) {1751 if (!is_this_device_mounted(bkpinfo->netfs_mount)) { 1744 1752 popup_and_OK("Please mount that partition before you try to backup to or restore from it."); 1745 1753 finish(1); 1746 1754 } 1747 p = popup_and_get_string("Directory", "Which directory within that mountpoint?", bkpinfo->n fs_remote_dir);1755 p = popup_and_get_string("Directory", "Which directory within that mountpoint?", bkpinfo->netfs_remote_dir); 1748 1756 if (p == NULL) { 1749 1757 log_to_screen("User has chosen not to backup the PC"); 1750 1758 finish(1); 1751 1759 } 1752 mr_free(bkpinfo->n fs_remote_dir);1753 bkpinfo->n fs_remote_dir = p;1760 mr_free(bkpinfo->netfs_remote_dir); 1761 bkpinfo->netfs_remote_dir = p; 1754 1762 1755 1763 // check whether writable - we better remove surrounding spaces for this 1756 mr_strip_spaces(bkpinfo->n fs_remote_dir);1764 mr_strip_spaces(bkpinfo->netfs_remote_dir); 1757 1765 1758 1766 p = popup_and_get_string("Prefix.", "Please enter the prefix that will be prepended to your ISO filename. Example: machine1 to obtain machine1-[1-9]*.iso files", bkpinfo->prefix); … … 1765 1773 log_msg(3, "prefix set to %s", bkpinfo->prefix); 1766 1774 1767 log_msg(3, "Just set n fs_remote_dir to %s", bkpinfo->nfs_remote_dir);1775 log_msg(3, "Just set netfs_remote_dir to %s", bkpinfo->netfs_remote_dir); 1768 1776 log_msg(3, "isodir is still %s", bkpinfo->isodir); 1769 1777 break; … … 1873 1881 bkpinfo->include_paths = p; 1874 1882 1875 mr_asprintf(tmp, "%s", list_of_N FS_mounts_only());1883 mr_asprintf(tmp, "%s", list_of_NETFS_mounts_only()); 1876 1884 if (strlen(tmp) > 2) { 1877 1885 mr_strcat(bkpinfo->exclude_paths, " %s",tmp); … … 1946 1954 1947 1955 if (bkpinfo->backup_media_type == iso 1948 || bkpinfo->backup_media_type == n fs) {1956 || bkpinfo->backup_media_type == netfs) { 1949 1957 g_ISO_restore_mode = TRUE; 1950 1958 } … … 1952 1960 // skip 1953 1961 #else 1954 if (bkpinfo->backup_media_type == n fs) {1955 log_msg(3, "I think the NFSmount is mounted at %s", bkpinfo->isodir);1962 if (bkpinfo->backup_media_type == netfs) { 1963 log_msg(3, "I think the Remote mount is mounted at %s", bkpinfo->isodir); 1956 1964 } 1957 1965 log_it("isodir = %s", bkpinfo->isodir); 1958 if (bkpinfo->nfs_mount) { 1959 log_it("nfs_mount = '%s'", bkpinfo->nfs_mount); 1960 } 1961 if (bkpinfo->nfs_user) { 1962 log_it("nfs_user = '%s'", bkpinfo->nfs_user); 1966 if (bkpinfo->netfs_mount) { 1967 log_it("netfs_mount = '%s'", bkpinfo->netfs_mount); 1968 } 1969 if (bkpinfo->netfs_user) { 1970 log_it("netfs_user = '%s'", bkpinfo->netfs_user); 1971 } 1972 if (bkpinfo->netfs_proto) { 1973 log_it("netfs_proto = '%s'", bkpinfo->netfs_proto); 1963 1974 } 1964 1975 #endif … … 2008 2019 */ 2009 2020 /** 2010 * Get a space-separated list of N FS devices and mounts.2021 * Get a space-separated list of NETFS devices and mounts. 2011 2022 * @return The list created. 2012 2023 * @note The return value points to static data that will be overwritten with each call. 2013 2024 */ 2014 char *list_of_N FS_devices_and_mounts(void)2025 char *list_of_NETFS_devices_and_mounts(void) 2015 2026 { 2016 2027 char *exclude_these_devices = NULL; … … 2018 2029 static char result_sz[1024]; 2019 2030 2020 mr_asprintf(exclude_these_directories,"%s",list_of_N FS_mounts_only());2021 mr_asprintf(exclude_these_devices,"%s", call_program_and_get_last_line_of_output("tr -s '\t' ' ' < /etc/fstab | grep -E '( (coda|ncpfs| nfs|nfs4|smbfs|cifs|afs|gfs|ocfs|ocfs2|mvfs|nsspool|nsvol) )' | cut -d' ' -f1 | tr -s '\n' ' ' | awk '{print $0;}'"));2031 mr_asprintf(exclude_these_directories,"%s",list_of_NETFS_mounts_only()); 2032 mr_asprintf(exclude_these_devices,"%s", call_program_and_get_last_line_of_output("tr -s '\t' ' ' < /etc/fstab | grep -E '( (coda|ncpfs|sshfs|nfs|nfs4|smbfs|cifs|afs|gfs|ocfs|ocfs2|mvfs|nsspool|nsvol) )' | cut -d' ' -f1 | tr -s '\n' ' ' | awk '{print $0;}'")); 2022 2033 snprintf(result_sz, 1023, "%s %s", exclude_these_directories, exclude_these_devices); 2023 2034 mr_free(exclude_these_devices); … … 2030 2041 2031 2042 /** 2032 * Get a space-separated list of N FS mounts.2043 * Get a space-separated list of NETFS mounts. 2033 2044 * @return The list created. 2034 2045 * @note The return value points to static data that will be overwritten with each call. 2035 2046 * @bug Even though we only want the mounts, the devices are still checked. 2036 2047 */ 2037 char *list_of_N FS_mounts_only(void)2048 char *list_of_NETFS_mounts_only(void) 2038 2049 { 2039 2050 char *exclude_these_directories = NULL; 2040 2051 static char result_sz[512]; 2041 2052 2042 mr_asprintf(exclude_these_directories,"%s", call_program_and_get_last_line_of_output("mount -t coda,ncpfs, nfs,nfs4,smbfs,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | tr -s '\t' ' ' | cut -d' ' -f3 | tr -s '\n' ' ' | awk '{print $0;}'"));2053 mr_asprintf(exclude_these_directories,"%s", call_program_and_get_last_line_of_output("mount -t coda,ncpfs,fuse.sshfs,nfs,nfs4,smbfs,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | tr -s '\t' ' ' | cut -d' ' -f3 | tr -s '\n' ' ' | awk '{print $0;}'")); 2043 2054 snprintf(result_sz, 511, "%s", exclude_these_directories); 2044 2055 mr_free(exclude_these_directories); … … 2094 2105 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("LANGUAGE=C df -m -P -t nonfs,msdosfs,ntfs,ntfs-3g,smbfs,smb,cifs,afs,gfs,ocfs,ocfs2,mvfs,nsspool,nssvol | grep -vE \"none|Filesystem\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'")); 2095 2106 #else 2096 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("LANGUAGE=C df -m -P -x nfs -x nfs4 -x vfat -x ntfs -x ntfs-3g -x smbfs -x smb -x cifs -x afs -x gfs -x ocfs -x ocfs2 -x mvfs -x nsspool -x nssvol -x iso9660 | grep -vE \"none|Filesystem|/dev/shm\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'"));2107 mr_asprintf(tmp, "%s", call_program_and_get_last_line_of_output("LANGUAGE=C df -m -P -x nfs -x nfs4 -x fuse.sshfs -x vfat -x ntfs -x ntfs-3g -x smbfs -x smb -x cifs -x afs -x gfs -x ocfs -x ocfs2 -x mvfs -x nsspool -x nssvol -x iso9660 | grep -vE \"none|Filesystem|/dev/shm\" | awk '{printf \"%s %s\\n\", $4, $6;}' | sort -n | tail -n1 | awk '{print $NF;}'")); 2097 2108 #endif 2098 2109 … … 2535 2546 struct stat buf; 2536 2547 #endif 2537 log_msg(0, "Looking for partition table format type");2538 2548 mr_asprintf(fdisk, "/sbin/parted2fdisk"); 2539 log_msg(1, "Using %s", fdisk);2540 2549 mr_asprintf(command, "%s -l %s | grep 'EFI GPT'", fdisk, drive); 2541 2550 mr_free(fdisk);
Note:
See TracChangeset
for help on using the changeset viewer.