Changeset 2380 in MondoRescue for branches/2.2.9/mondo/src/common/libmondo-devices.c
- Timestamp:
- Sep 9, 2009, 8:30:47 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2.9/mondo/src/common/libmondo-devices.c
r2368 r2380 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() … … 179 179 strcpy(output, "cdstream"); 180 180 break; 181 case n fs:182 strcpy(output, "n fs");181 case netfs: 182 strcpy(output, "netfs"); 183 183 break; 184 184 case tape: … … 1376 1376 run_program_and_log_output(tmp, 5); 1377 1377 if (g_ISO_restore_mode || bkpinfo->backup_media_type == iso 1378 || bkpinfo->backup_media_type == n fs) {1378 || bkpinfo->backup_media_type == netfs) { 1379 1379 log_msg(3, "Remounting CD"); 1380 1380 g_ISO_restore_mode = TRUE; … … 1387 1387 (void)system(tmp); 1388 1388 sprintf(tmp, "%s/%s/%s-%d.iso", bkpinfo->isodir, 1389 bkpinfo->n fs_remote_dir, bkpinfo->prefix,1389 bkpinfo->netfs_remote_dir, bkpinfo->prefix, 1390 1390 cd_number_i_want); 1391 1391 if (!does_file_exist(tmp)) { 1392 1392 sprintf(tmp, "%s/isodir/%s/%s-%d.iso", bkpinfo->tmpdir, 1393 bkpinfo->n fs_remote_dir, bkpinfo->prefix,1393 bkpinfo->netfs_remote_dir, bkpinfo->prefix, 1394 1394 cd_number_i_want); 1395 1395 if (does_file_exist(tmp)) { … … 1486 1486 bkpinfo->nonbootable_backup = FALSE; 1487 1487 1488 // Tape, CD, N FS, ...?1488 // Tape, CD, NETFS, ...? 1489 1489 srandom(getpid()); 1490 1490 bkpinfo->backup_media_type = … … 1726 1726 1727 1727 1728 case n fs:1729 /* Never try to eject a N FS device */1728 case netfs: 1729 /* Never try to eject a NETFS device */ 1730 1730 bkpinfo->please_dont_eject = TRUE; 1731 1731 1732 /* Initiate bkpinfo n fs_mount path from running environment if not already done */1733 if (!bkpinfo->n fs_mount[0]) {1734 strcpy(bkpinfo->n fs_mount,1732 /* Initiate bkpinfo netfs_mount path from running environment if not already done */ 1733 if (!bkpinfo->netfs_mount[0]) { 1734 strcpy(bkpinfo->netfs_mount, 1735 1735 call_program_and_get_last_line_of_output 1736 1736 ("mount | grep \":\" | cut -d' ' -f1 | head -n1")); … … 1743 1743 { 1744 1744 if (!popup_and_get_string 1745 ("N FSdir.",1745 ("Network shared dir.", 1746 1746 "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.)", 1747 bkpinfo->n fs_mount, MAX_STR_LEN / 4)) {1747 bkpinfo->netfs_mount, MAX_STR_LEN / 4)) { 1748 1748 log_to_screen("User has chosen not to backup the PC"); 1749 1749 finish(1); … … 1758 1758 // check whether already mounted - we better remove 1759 1759 // surrounding spaces and trailing '/' for this 1760 strip_spaces(bkpinfo->n fs_mount);1761 if (bkpinfo->n fs_mount[strlen(bkpinfo->nfs_mount) - 1] == '/')1762 bkpinfo->n fs_mount[strlen(bkpinfo->nfs_mount) - 1] = '\0';1760 strip_spaces(bkpinfo->netfs_mount); 1761 if (bkpinfo->netfs_mount[strlen(bkpinfo->netfs_mount) - 1] == '/') 1762 bkpinfo->netfs_mount[strlen(bkpinfo->netfs_mount) - 1] = '\0'; 1763 1763 sprintf(command, "mount | grep \"%s \" | cut -d' ' -f3", 1764 bkpinfo->n fs_mount);1764 bkpinfo->netfs_mount); 1765 1765 strcpy(bkpinfo->isodir, 1766 1766 call_program_and_get_last_line_of_output(command)); … … 1788 1788 (void)system(command); 1789 1789 if (!popup_and_get_string 1790 ("N FS share", "Which remote NFSshare should I mount?",1791 bkpinfo->n fs_mount, MAX_STR_LEN)) {1790 ("Network share", "Which remote share should I mount?", 1791 bkpinfo->netfs_mount, MAX_STR_LEN)) { 1792 1792 log_to_screen("User has chosen not to backup the PC"); 1793 1793 finish(1); … … 1795 1795 } 1796 1796 /* Initiate bkpinfo isodir path from running environment if mount already done */ 1797 if (is_this_device_mounted(bkpinfo->n fs_mount)) {1797 if (is_this_device_mounted(bkpinfo->netfs_mount)) { 1798 1798 strcpy(bkpinfo->isodir, 1799 1799 call_program_and_get_last_line_of_output 1800 1800 ("mount | grep \":\" | cut -d' ' -f3 | head -n1")); 1801 1801 } else { 1802 sprintf(bkpinfo->isodir, "%s/n fsdir", bkpinfo->tmpdir);1802 sprintf(bkpinfo->isodir, "%s/netfsdir", bkpinfo->tmpdir); 1803 1803 sprintf(command, "mkdir -p %s", bkpinfo->isodir); 1804 1804 run_program_and_log_output(command, 5); 1805 1805 if (bkpinfo->restore_data) { 1806 mr_asprintf(&tmp, "mount -t nfs -o nolock,ro %s %s", bkpinfo->nfs_mount, bkpinfo->isodir); 1806 if (strstr(bkpinfo->netfs_proto, "sshfs")) { 1807 mr_asprintf(&tmp, "sshfs -o ro %s %s", bkpinfo->netfs_mount, bkpinfo->isodir); 1808 } else { 1809 mr_asprintf(&tmp, "mount -t %s -o nolock,ro %s %s", bkpinfo->netfs_proto, bkpinfo->netfs_mount, bkpinfo->isodir); 1810 } 1807 1811 } else { 1808 mr_asprintf(&tmp, "mount -t nfs -o nolock %s %s", bkpinfo->nfs_mount, bkpinfo->isodir); 1812 if (strstr(bkpinfo->netfs_proto, "sshfs")) { 1813 mr_asprintf(&tmp, "sshfs %s %s", bkpinfo->netfs_mount, bkpinfo->isodir); 1814 } else { 1815 mr_asprintf(&tmp, "mount -t %s -o nolock %s %s", bkpinfo->netfs_proto, bkpinfo->netfs_mount, bkpinfo->isodir); 1816 } 1809 1817 } 1810 1818 run_program_and_log_output(tmp, 3); … … 1814 1822 strcpy(g_selfmounted_isodir, bkpinfo->isodir); 1815 1823 } 1816 if (!is_this_device_mounted(bkpinfo->n fs_mount)) {1824 if (!is_this_device_mounted(bkpinfo->netfs_mount)) { 1817 1825 popup_and_OK 1818 1826 ("Please mount that partition before you try to backup to or restore from it."); 1819 1827 finish(1); 1820 1828 } 1821 strcpy(tmp1, bkpinfo->n fs_remote_dir);1829 strcpy(tmp1, bkpinfo->netfs_remote_dir); 1822 1830 if (!popup_and_get_string 1823 1831 ("Directory", "Which directory within that mountpoint?", tmp1, … … 1826 1834 finish(1); 1827 1835 } 1828 strcpy(bkpinfo->n fs_remote_dir, tmp1);1836 strcpy(bkpinfo->netfs_remote_dir, tmp1); 1829 1837 1830 1838 // check whether writable - we better remove surrounding spaces for this 1831 strip_spaces(bkpinfo->n fs_remote_dir);1839 strip_spaces(bkpinfo->netfs_remote_dir); 1832 1840 1833 1841 if (!popup_and_get_string … … 1843 1851 bkpinfo->media_size[i] = 650; 1844 1852 } 1845 log_msg(3, "Just set n fs_remote_dir to %s",1846 bkpinfo->n fs_remote_dir);1853 log_msg(3, "Just set netfs_remote_dir to %s", 1854 bkpinfo->netfs_remote_dir); 1847 1855 log_msg(3, "isodir is still %s", bkpinfo->isodir); 1848 1856 break; … … 1961 1969 finish(1); 1962 1970 } 1963 mr_asprintf(&tmp, "%s", list_of_N FS_mounts_only());1971 mr_asprintf(&tmp, "%s", list_of_NETFS_mounts_only()); 1964 1972 if (strlen(tmp) > 2) { 1965 1973 if (bkpinfo->exclude_paths[0]) { … … 2033 2041 2034 2042 if (bkpinfo->backup_media_type == iso 2035 || bkpinfo->backup_media_type == n fs) {2043 || bkpinfo->backup_media_type == netfs) { 2036 2044 g_ISO_restore_mode = TRUE; 2037 2045 } … … 2039 2047 // skip 2040 2048 #else 2041 if (bkpinfo->backup_media_type == n fs) {2042 log_msg(3, "I think the NFSmount is mounted at %s",2049 if (bkpinfo->backup_media_type == netfs) { 2050 log_msg(3, "I think the Remote mount is mounted at %s", 2043 2051 bkpinfo->isodir); 2044 2052 } 2045 2053 log_it("isodir = %s", bkpinfo->isodir); 2046 log_it("nfs_mount = '%s'", bkpinfo->nfs_mount); 2047 if (bkpinfo->nfs_user) { 2048 log_it("nfs_user = '%s'", bkpinfo->nfs_user); 2054 log_it("netfs_mount = '%s'", bkpinfo->netfs_mount); 2055 log_it("netfs_proto = '%s'", bkpinfo->netfs_proto); 2056 if (bkpinfo->netfs_user) { 2057 log_it("netfs_user = '%s'", bkpinfo->netfs_user); 2049 2058 } 2050 2059 #endif … … 2087 2096 */ 2088 2097 /** 2089 * Get a space-separated list of N FS devices and mounts.2098 * Get a space-separated list of NETFS devices and mounts. 2090 2099 * @return The list created. 2091 2100 * @note The return value points to static data that will be overwritten with each call. 2092 2101 */ 2093 char *list_of_N FS_devices_and_mounts(void)2102 char *list_of_NETFS_devices_and_mounts(void) 2094 2103 { 2095 2104 char *exclude_these_devices = NULL; … … 2097 2106 static char result_sz[1024]; 2098 2107 2099 mr_asprintf(&exclude_these_directories,"%s",list_of_N FS_mounts_only());2100 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;}'"));2108 mr_asprintf(&exclude_these_directories,"%s",list_of_NETFS_mounts_only()); 2109 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;}'")); 2101 2110 snprintf(result_sz, 1023, "%s %s", exclude_these_directories, exclude_these_devices); 2102 2111 mr_free(exclude_these_devices); … … 2109 2118 2110 2119 /** 2111 * Get a space-separated list of N FS mounts.2120 * Get a space-separated list of NETFS mounts. 2112 2121 * @return The list created. 2113 2122 * @note The return value points to static data that will be overwritten with each call. 2114 2123 * @bug Even though we only want the mounts, the devices are still checked. 2115 2124 */ 2116 char *list_of_N FS_mounts_only(void)2125 char *list_of_NETFS_mounts_only(void) 2117 2126 { 2118 2127 char *exclude_these_directories = NULL; 2119 2128 static char result_sz[512]; 2120 2129 2121 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;}'"));2130 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;}'")); 2122 2131 snprintf(result_sz, 511, "%s", exclude_these_directories); 2123 2132 mr_free(exclude_these_directories); … … 2176 2185 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;}'")); 2177 2186 #else 2178 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;}'"));2187 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;}'")); 2179 2188 #endif 2180 2189 … … 2606 2615 malloc_string(command); 2607 2616 malloc_string(fdisk); 2608 log_msg(0, "Looking for partition table format type");2609 2617 sprintf(fdisk, "/sbin/parted2fdisk"); 2610 log_msg(1, "Using %s", fdisk);2611 2618 sprintf(command, "%s -l %s | grep 'EFI GPT'", fdisk, drive); 2612 2619 mr_asprintf(&tmp, "%s", call_program_and_get_last_line_of_output(command));
Note:
See TracChangeset
for help on using the changeset viewer.