Changeset 2380 in MondoRescue for branches/2.2.9/mondo/src/common/libmondo-cli.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-cli.c
r2309 r2380 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 (char *mount_point); 59 59 static MOUNTED_FS_STRUCT *find_device_in_list (char *device); … … 178 178 /** 179 179 * Frees the memory for all of the structures on the linked list of 180 * all of the non-N FS mounted file systems.180 * all of the non-NETFS mounted file systems. 181 181 */ 182 182 static void free_mounted_fs_list (void) { … … 195 195 196 196 /** 197 * Creates a singly linked list of all of the non-N FS mounted file systems.197 * Creates a singly linked list of all of the non-NETFS mounted file systems. 198 198 * @param DSFptr A pointer to the structure MOUNTED_FS_STRUCT used to hold 199 199 * the list of mounted file systems. … … 213 213 214 214 /** 215 * Find the structure, in the singly linked list of all of the non-N FS215 * Find the structure, in the singly linked list of all of the non-NETFS 216 216 * mounted file systems, that contains the specified device. 217 217 * @param device The device to find … … 234 234 235 235 /** 236 * Find the structure, in the singly linked list of all of the non-N FS236 * Find the structure, in the singly linked list of all of the non-NETFS 237 237 * mounted file systems, that contains the specified mount point. 238 238 * @param mount_point The mount point to find … … 255 255 256 256 /** 257 * Creates a linked list of all of the non-N FS mounted file systems.257 * Creates a linked list of all of the non-NETFS mounted file systems. 258 258 * We use a linked list because we don't know how many mounted file 259 259 * there are (and there can be a lot). 260 260 * @return 0 on success and greated than 0 on failure. 261 261 */ 262 static int create_list_of_non_N FS_mounted_file_systems (void)262 static int create_list_of_non_NETFS_mounted_file_systems (void) 263 263 { 264 264 int i = 0; … … 388 388 389 389 /* Get a list of the mounted file systems */ 390 if (create_list_of_non_N FS_mounted_file_systems()) {390 if (create_list_of_non_NETFS_mounted_file_systems()) { 391 391 log_to_screen ("Could not get the list of mounted file systems"); 392 392 return (1); … … 992 992 993 993 if (flag_set['n']) { 994 strncpy(bkpinfo->n fs_mount, flag_val['n'], MAX_STR_LEN);994 strncpy(bkpinfo->netfs_mount, flag_val['n'], MAX_STR_LEN); 995 995 if (!flag_set['d']) { 996 strncpy(bkpinfo->nfs_remote_dir, "/", MAX_STR_LEN); 997 } 998 /* test if we specified a user for the NFS dialog */ 999 p = strchr(bkpinfo->nfs_mount, '@'); 996 strncpy(bkpinfo->netfs_remote_dir, "/", MAX_STR_LEN); 997 } 998 /* test for protocol */ 999 p = strchr(bkpinfo->netfs_mount, ':'); 1000 if (p == NULL) { 1001 /* protocol not found abort */ 1002 fatal_error("No protocol specified for remote share mount. Please do man mondoarchive as syntax changed"); 1003 } else { 1004 /* Proto found. Store the 2 values */ 1005 p++; 1006 if (*p != '/') { 1007 fatal_error("No protocol correctly specified for remote share mount. Use protocol://server:share"); 1008 } 1009 p++; 1010 if (*p != '/') { 1011 fatal_error("No protocol correctly specified for remote share mount. Use protocol://server:share"); 1012 } 1013 /* new netfs mount */ 1014 strcpy(tmp,p); 1015 p--; 1016 p--; 1017 p--; 1018 *p = '\0'; 1019 mr_asprintf(&q,"%s",bkpinfo->netfs_mount); 1020 bkpinfo->netfs_proto = q; 1021 strcpy(bkpinfo->netfs_mount,tmp); 1022 } 1023 /* test if we specified a user */ 1024 p = strchr(bkpinfo->netfs_mount, '@'); 1000 1025 if (p != NULL) { 1001 1026 /* User found. Store the 2 values */ 1002 1027 p++; 1003 /* new NFSmount */1028 /* new netfs mount */ 1004 1029 strcpy(tmp,p); 1005 1030 p--; 1006 1031 *p = '\0'; 1007 mr_asprintf(&q,"%s",bkpinfo->n fs_mount);1008 bkpinfo->n fs_user = q;1009 strcpy(bkpinfo->n fs_mount,tmp);1032 mr_asprintf(&q,"%s",bkpinfo->netfs_mount); 1033 bkpinfo->netfs_user = q; 1034 strcpy(bkpinfo->netfs_mount,tmp); 1010 1035 } 1011 1036 sprintf(tmp, "mount | grep -E \"^%s[/]* .*\" | cut -d' ' -f3", 1012 bkpinfo->n fs_mount);1037 bkpinfo->netfs_mount); 1013 1038 strncpy(bkpinfo->isodir, 1014 1039 call_program_and_get_last_line_of_output(tmp), 1015 1040 MAX_STR_LEN / 4); 1016 1041 if (strlen(bkpinfo->isodir) < 3) { 1017 log_to_screen("NFS share is not mounted. Trying to mount it for you.\n"); 1018 sprintf(tmp, "mount %s", bkpinfo->nfs_mount); 1042 log_to_screen("Network share is not mounted. Trying to mount it for you.\n"); 1043 if (strstr(bkpinfo->netfs_proto, "sshfs")) { 1044 sprintf(tmp, "sshfs %s", bkpinfo->netfs_mount); 1045 } else { 1046 sprintf(tmp, "mount %s", bkpinfo->netfs_mount); 1047 } 1019 1048 if (system(tmp)) { 1020 log_to_screen("Unable to mount N FS share %s. Please mount manually.\n", bkpinfo->nfs_mount);1049 log_to_screen("Unable to mount Network share %s. Please mount manually.\n", bkpinfo->netfs_mount); 1021 1050 retval++; 1022 1051 } else { 1023 1052 sprintf(tmp, "mount | grep -E \"^%s[/]* .*\" | cut -d' ' -f3", 1024 bkpinfo->n fs_mount);1053 bkpinfo->netfs_mount); 1025 1054 strncpy(bkpinfo->isodir, 1026 1055 call_program_and_get_last_line_of_output(tmp), … … 1028 1057 if (strlen(bkpinfo->isodir) < 3) { 1029 1058 retval++; 1030 log_to_screen("N FS share %s is strangely not mounted. Please mount manually...\n", bkpinfo->nfs_mount);1059 log_to_screen("Network share %s is strangely not mounted. Please mount manually...\n", bkpinfo->netfs_mount); 1031 1060 } 1032 1061 } 1033 1062 } 1034 log_msg(3, "mount = %s", bkpinfo->n fs_mount);1063 log_msg(3, "mount = %s", bkpinfo->netfs_mount); 1035 1064 log_msg(3, "isodir= %s", bkpinfo->isodir); 1036 1065 } … … 1046 1075 } 1047 1076 if (flag_set['n']) { 1048 bkpinfo->backup_media_type = n fs;1049 /* Never try to eject a N FSdevice */1077 bkpinfo->backup_media_type = netfs; 1078 /* Never try to eject a Network device */ 1050 1079 bkpinfo->please_dont_eject = TRUE; 1051 1080 } … … 1155 1184 } 1156 1185 1157 if ((flag_set['N']) && (! bkpinfo->restore_data)) // exclude N FSmounts & devices1186 if ((flag_set['N']) && (! bkpinfo->restore_data)) // exclude Network mounts & devices 1158 1187 { 1159 // strncpy(psz, list_of_NFS_devices_and_mounts(), MAX_STR_LEN); 1160 mr_asprintf(&psz, "%s", list_of_NFS_mounts_only()); 1188 mr_asprintf(&psz, "%s", list_of_NETFS_mounts_only()); 1161 1189 if (bkpinfo->exclude_paths[0]) { 1162 1190 strncat(bkpinfo->exclude_paths, " ", 4*MAX_STR_LEN); … … 1233 1261 } 1234 1262 1235 if (flag_set['d']) { /* backup directory (if ISO/N FS) */1263 if (flag_set['d']) { /* backup directory (if ISO/NETFS) */ 1236 1264 if (flag_set['i']) { 1237 1265 strncpy(bkpinfo->isodir, flag_val['d'], MAX_STR_LEN / 4); … … 1242 1270 } 1243 1271 } else if (flag_set['n']) { 1244 strncpy(bkpinfo->n fs_remote_dir, flag_val['d'], MAX_STR_LEN);1272 strncpy(bkpinfo->netfs_remote_dir, flag_val['d'], MAX_STR_LEN); 1245 1273 } else { /* backup device (if tape/CD-R/CD-RW) */ 1246 1274 strncpy(bkpinfo->media_device, flag_val['d'], MAX_STR_LEN / 4); … … 1249 1277 1250 1278 if ((flag_set['n']) && (! bkpinfo->restore_data)) { 1251 mr_asprintf(&tmp1,"%s/%s/.dummy.txt", bkpinfo->isodir,bkpinfo->n fs_remote_dir);1252 if ( bkpinfo->nfs_user) {1253 sprintf(tmp, "su - %s -c \"echo hi > %s\"", bkpinfo->n fs_user, tmp1);1279 mr_asprintf(&tmp1,"%s/%s/.dummy.txt", bkpinfo->isodir,bkpinfo->netfs_remote_dir); 1280 if ((bkpinfo->netfs_user) && (strstr(bkpinfo->netfs_proto,"nfs"))) { 1281 sprintf(tmp, "su - %s -c \"echo hi > %s\"", bkpinfo->netfs_user, tmp1); 1254 1282 } else { 1255 1283 sprintf(tmp, "echo hi > %s", tmp1); … … 1259 1287 sprintf(tmp, 1260 1288 "Are you sure directory '%s' exists in remote dir '%s'?\nIf so, do you have rights to write to it?\n", 1261 bkpinfo->n fs_remote_dir, bkpinfo->nfs_mount);1289 bkpinfo->netfs_remote_dir, bkpinfo->netfs_mount); 1262 1290 log_to_screen(tmp); 1263 1291 }
Note:
See TracChangeset
for help on using the changeset viewer.