Changeset 2382 in MondoRescue for branches/2.2.10/mondo/src/common/libmondo-cli.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-cli.c
r2338 r2382 55 55 static void free_mounted_fs_list (void); 56 56 static int get_dsf_mount_list (const char *dsf, char **included_dsf_list, char **excluded_dsf_list); 57 static int create_list_of_non_N FS_mounted_file_systems (void);57 static int create_list_of_non_NETFS_mounted_file_systems (void); 58 58 static MOUNTED_FS_STRUCT *find_mount_point_in_list (const char *mount_point); 59 59 static MOUNTED_FS_STRUCT *find_device_in_list (const char *device); … … 162 162 /** 163 163 * Frees the memory for all of the structures on the linked list of 164 * all of the non-N FS mounted file systems.164 * all of the non-NETFS mounted file systems. 165 165 */ 166 166 static void free_mounted_fs_list (void) { … … 179 179 180 180 /** 181 * Creates a singly linked list of all of the non-N FS mounted file systems.181 * Creates a singly linked list of all of the non-NETFS mounted file systems. 182 182 * @param DSFptr A pointer to the structure MOUNTED_FS_STRUCT used to hold 183 183 * the list of mounted file systems. … … 197 197 198 198 /** 199 * Find the structure, in the singly linked list of all of the non-N FS199 * Find the structure, in the singly linked list of all of the non-NETFS 200 200 * mounted file systems, that contains the specified device. 201 201 * @param device The device to find … … 218 218 219 219 /** 220 * Find the structure, in the singly linked list of all of the non-N FS220 * Find the structure, in the singly linked list of all of the non-NETFS 221 221 * mounted file systems, that contains the specified mount point. 222 222 * @param mount_point The mount point to find … … 239 239 240 240 /** 241 * Creates a linked list of all of the non-N FS mounted file systems.241 * Creates a linked list of all of the non-NETFS mounted file systems. 242 242 * We use a linked list because we don't know how many mounted file 243 243 * there are (and there can be a lot). 244 244 * @return 0 on success and greated than 0 on failure. 245 245 */ 246 static int create_list_of_non_N FS_mounted_file_systems (void)246 static int create_list_of_non_NETFS_mounted_file_systems (void) 247 247 { 248 248 int i = 0; … … 372 372 373 373 /* Get a list of the mounted file systems */ 374 if (create_list_of_non_N FS_mounted_file_systems()) {374 if (create_list_of_non_NETFS_mounted_file_systems()) { 375 375 log_to_screen ("Could not get the list of mounted file systems"); 376 376 return (1); … … 967 967 968 968 if (flag_set['n']) { 969 mr_free(bkpinfo->n fs_mount);970 mr_asprintf(bkpinfo->n fs_mount, "%s", flag_val['n']);969 mr_free(bkpinfo->netfs_mount); 970 mr_asprintf(bkpinfo->netfs_mount, "%s", flag_val['n']); 971 971 if (!flag_set['d']) { 972 mr_free(bkpinfo->nfs_remote_dir); 973 mr_asprintf(bkpinfo->nfs_remote_dir, "/"); 974 } 975 /* test if we specified a user for the NFS dialog */ 976 p = strchr(bkpinfo->nfs_mount, '@'); 972 mr_free(bkpinfo->netfs_remote_dir); 973 mr_asprintf(bkpinfo->netfs_remote_dir, "/"); 974 } 975 /* test for protocol */ 976 p = strchr(bkpinfo->netfs_mount, ':'); 977 if (p == NULL) { 978 /* protocol not found abort */ 979 fatal_error("No protocol specified for remote share mount. Please do man mondoarchive as syntax changed"); 980 } else { 981 /* Proto found. Store the 2 values */ 982 bkpinfo->netfs_proto = bkpinfo->netfs_mount; 983 p++; 984 if (*p != '/') { 985 fatal_error("No protocol correctly specified for remote share mount. Use protocol://server:share"); 986 } 987 p++; 988 if (*p != '/') { 989 fatal_error("No protocol correctly specified for remote share mount. Use protocol://server:share"); 990 } 991 bkpinfo->netfs_mount = p; 992 /* new netfs mount - remove :// from proto */ 993 p--; 994 p--; 995 p--; 996 *p = '\0'; 997 } 998 /* test if we specified a user */ 999 p = strchr(bkpinfo->netfs_mount, '@'); 977 1000 if (p != NULL) { 978 1001 /* User found. Store the 2 values */ 979 bkpinfo->n fs_user = bkpinfo->nfs_mount;1002 bkpinfo->netfs_user = bkpinfo->netfs_mount; 980 1003 p++; 981 /* new NFSmount */982 bkpinfo->n fs_mount = p;1004 /* new netfs mount */ 1005 bkpinfo->netfs_mount = p; 983 1006 p--; 984 1007 *p = '\0'; 985 1008 } 986 mr_asprintf(tmp1, "mount | grep -E \"^%s[/]* .*\" | cut -d' ' -f3", bkpinfo->n fs_mount);1009 mr_asprintf(tmp1, "mount | grep -E \"^%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_mount); 987 1010 mr_free(bkpinfo->isodir); 988 1011 mr_asprintf(bkpinfo->isodir, "%s", call_program_and_get_last_line_of_output(tmp1)); … … 990 1013 991 1014 if (strlen(bkpinfo->isodir) < 3) { 992 log_to_screen("NFS share is not mounted. Trying to mount it for you.\n"); 993 mr_asprintf(tmp1, "mount %s", bkpinfo->nfs_mount); 1015 log_to_screen("Network share is not mounted. Trying to mount it for you.\n"); 1016 if (strstr(bkpinfo->netfs_proto, "sshfs")) { 1017 mr_asprintf(tmp1, "sshfs %s", bkpinfo->netfs_mount); 1018 } else { 1019 mr_asprintf(tmp1, "mount %s", bkpinfo->netfs_mount); 1020 } 994 1021 i = system(tmp1); 995 1022 mr_free(tmp1); 996 1023 if (i) { 997 log_to_screen("Unable to mount N FS share %s. Please mount manually.\n", bkpinfo->nfs_mount);1024 log_to_screen("Unable to mount Network share %s. Please mount manually.\n", bkpinfo->netfs_mount); 998 1025 retval++; 999 1026 } else { 1000 mr_asprintf(tmp1, "mount | grep -E \"^%s[/]* .*\" | cut -d' ' -f3", bkpinfo->n fs_mount);1027 mr_asprintf(tmp1, "mount | grep -E \"^%s[/]* .*\" | cut -d' ' -f3", bkpinfo->netfs_mount); 1001 1028 mr_free(bkpinfo->isodir); 1002 1029 mr_asprintf(bkpinfo->isodir, "%s", call_program_and_get_last_line_of_output(tmp1)); … … 1005 1032 if (strlen(bkpinfo->isodir) < 3) { 1006 1033 retval++; 1007 log_to_screen("N FS share %s is strangely not mounted. Please mount manually...\n", bkpinfo->nfs_mount);1034 log_to_screen("Network share %s is strangely not mounted. Please mount manually...\n", bkpinfo->netfs_mount); 1008 1035 } 1009 1036 } 1010 1037 } 1011 log_msg(3, "mount = %s", bkpinfo->n fs_mount);1038 log_msg(3, "mount = %s", bkpinfo->netfs_mount); 1012 1039 log_msg(3, "isodir= %s", bkpinfo->isodir); 1013 1040 } … … 1023 1050 } 1024 1051 if (flag_set['n']) { 1025 bkpinfo->backup_media_type = n fs;1026 /* Never try to eject a N FSdevice */1052 bkpinfo->backup_media_type = netfs; 1053 /* Never try to eject a Network device */ 1027 1054 bkpinfo->please_dont_eject = TRUE; 1028 1055 } … … 1134 1161 } 1135 1162 1136 if ((flag_set['N']) && (! bkpinfo->restore_data)) // exclude N FSmounts & devices1163 if ((flag_set['N']) && (! bkpinfo->restore_data)) // exclude Network mounts & devices 1137 1164 { 1138 mr_asprintf(psz, "%s", list_of_N FS_mounts_only());1165 mr_asprintf(psz, "%s", list_of_NETFS_mounts_only()); 1139 1166 mr_strcat(bkpinfo->exclude_paths, " %s ", psz); 1140 1167 mr_free(psz); … … 1201 1228 } 1202 1229 1203 if (flag_set['d']) { /* backup directory (if ISO/N FS) */1230 if (flag_set['d']) { /* backup directory (if ISO/NETFS) */ 1204 1231 if (flag_set['i']) { 1205 1232 mr_free(bkpinfo->isodir); … … 1212 1239 mr_free(tmp1); 1213 1240 } else if (flag_set['n']) { 1214 mr_free(bkpinfo->n fs_remote_dir);1215 mr_asprintf(bkpinfo->n fs_remote_dir, "%s", flag_val['d']);1241 mr_free(bkpinfo->netfs_remote_dir); 1242 mr_asprintf(bkpinfo->netfs_remote_dir, "%s", flag_val['d']); 1216 1243 } else { /* backup device (if tape/CD-R/CD-RW) */ 1217 1244 mr_free(bkpinfo->media_device); … … 1221 1248 1222 1249 if ((flag_set['n']) && (! bkpinfo->restore_data)) { 1223 mr_asprintf(tmp1,"%s/%s/.dummy.txt", bkpinfo->isodir,bkpinfo->n fs_remote_dir);1224 if ( bkpinfo->nfs_user) {1225 mr_asprintf(tmp2, "su - %s -c \"echo hi > %s\"", bkpinfo->n fs_user, tmp1);1250 mr_asprintf(tmp1,"%s/%s/.dummy.txt", bkpinfo->isodir,bkpinfo->netfs_remote_dir); 1251 if ((bkpinfo->netfs_user) && (strstr(bkpinfo->netfs_proto,"nfs"))) { 1252 mr_asprintf(tmp2, "su - %s -c \"echo hi > %s\"", bkpinfo->netfs_user, tmp1); 1226 1253 } else { 1227 1254 mr_asprintf(tmp2, "echo hi > %s", tmp1); … … 1232 1259 if (i) { 1233 1260 retval++; 1234 log_to_screen(tmp2, "Are you sure directory '%s' exists in remote dir '%s'?\nIf so, do you have rights to write to it?\n", bkpinfo->n fs_remote_dir, bkpinfo->nfs_mount);1261 log_to_screen(tmp2, "Are you sure directory '%s' exists in remote dir '%s'?\nIf so, do you have rights to write to it?\n", bkpinfo->netfs_remote_dir, bkpinfo->netfs_mount); 1235 1262 } 1236 1263 unlink(tmp1);
Note:
See TracChangeset
for help on using the changeset viewer.