Changeset 2380 in MondoRescue for branches/2.2.9/mondo/src/common/libmondo-files.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-files.c
r2242 r2380 1091 1091 1092 1092 /** 1093 * Store the client's N FS configuration in files to be restored at restore-time.1094 * Assumes that @c bkpinfo->media_type = n fs, but does not check for this.1093 * Store the client's NETFS configuration in files to be restored at restore-time. 1094 * Assumes that @c bkpinfo->media_type = netfs, but does not check for this. 1095 1095 * @param bkpinfo The backup information structure. Fields used: 1096 * - @c n fs_mount1097 * - @c n fs_remote_dir1096 * - @c netfs_mount 1097 * - @c netfs_remote_dir 1098 1098 * - @c tmpdir 1099 1099 */ 1100 void store_n fs_config()1100 void store_netfs_config() 1101 1101 { 1102 1102 1103 1103 /*@ buffers ******** */ 1104 char n fs_dev[MAX_STR_LEN];1104 char netfs_dev[MAX_STR_LEN]; 1105 1105 char mac_addr[MAX_STR_LEN]; 1106 char n fs_mount[MAX_STR_LEN];1107 char n fs_client_ipaddr[MAX_STR_LEN];1108 char n fs_client_netmask[MAX_STR_LEN];1109 char n fs_client_broadcast[MAX_STR_LEN];1110 char n fs_client_defgw[MAX_STR_LEN];1111 char n fs_server_ipaddr[MAX_STR_LEN];1106 char netfs_mount[MAX_STR_LEN]; 1107 char netfs_client_ipaddr[MAX_STR_LEN]; 1108 char netfs_client_netmask[MAX_STR_LEN]; 1109 char netfs_client_broadcast[MAX_STR_LEN]; 1110 char netfs_client_defgw[MAX_STR_LEN]; 1111 char netfs_server_ipaddr[MAX_STR_LEN]; 1112 1112 char tmp[MAX_STR_LEN]; 1113 1113 char command[MAX_STR_LEN * 2]; … … 1116 1116 char *p; 1117 1117 1118 log_it("Storing N FSconfiguration");1119 strcpy(tmp, bkpinfo->n fs_mount);1118 log_it("Storing Network configuration"); 1119 strcpy(tmp, bkpinfo->netfs_mount); 1120 1120 p = strchr(tmp, ':'); 1121 1121 if (!p) { 1122 1122 fatal_error 1123 ("N FSmount doesn't have a colon in it, e.g. 192.168.1.4:/home/nfs");1123 ("Network mount doesn't have a colon in it, e.g. 192.168.1.4:/home/nfs"); 1124 1124 } 1125 1125 *(p++) = '\0'; 1126 strcpy(n fs_server_ipaddr, tmp);1127 strcpy(n fs_mount, p);1126 strcpy(netfs_server_ipaddr, tmp); 1127 strcpy(netfs_mount, p); 1128 1128 1129 1129 /* BERLIOS : there is a bug #67 here as it only considers the first NIC */ 1130 1130 sprintf(command, 1131 1131 "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\n' | head -n1 | cut -d' ' -f1"); 1132 strcpy(n fs_dev, call_program_and_get_last_line_of_output(command));1132 strcpy(netfs_dev, call_program_and_get_last_line_of_output(command)); 1133 1133 sprintf(command, 1134 1134 "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f7 | cut -d':' -f2"); 1135 strcpy(n fs_client_ipaddr,1135 strcpy(netfs_client_ipaddr, 1136 1136 call_program_and_get_last_line_of_output(command)); 1137 1137 sprintf(command, 1138 1138 "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f9 | cut -d':' -f2"); 1139 strcpy(n fs_client_netmask,1139 strcpy(netfs_client_netmask, 1140 1140 call_program_and_get_last_line_of_output(command)); 1141 1141 sprintf(command, 1142 1142 "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f8 | cut -d':' -f2"); 1143 strcpy(n fs_client_broadcast,1143 strcpy(netfs_client_broadcast, 1144 1144 call_program_and_get_last_line_of_output(command)); 1145 1145 sprintf(command, 1146 1146 "route -n | grep '^0.0.0.0' | awk '{print $2}'"); 1147 strcpy(n fs_client_defgw,1147 strcpy(netfs_client_defgw, 1148 1148 call_program_and_get_last_line_of_output(command)); 1149 1149 sprintf(tmp, 1150 "n fs_client_ipaddr=%s; nfs_server_ipaddr=%s; nfs_mount=%s",1151 n fs_client_ipaddr, nfs_server_ipaddr, nfs_mount);1152 if (strlen(n fs_dev) < 2) {1150 "netfs_client_ipaddr=%s; netfs_server_ipaddr=%s; netfs_mount=%s", 1151 netfs_client_ipaddr, netfs_server_ipaddr, netfs_mount); 1152 if (strlen(netfs_dev) < 2) { 1153 1153 fatal_error 1154 ("Unable to find ethN (eth0, eth1, ...) adapter via N FSmount you specified.");1154 ("Unable to find ethN (eth0, eth1, ...) adapter via Network mount you specified."); 1155 1155 } 1156 1156 /******** 1157 * If the N FSdevice that found above is a bonded device,1157 * If the Network device that found above is a bonded device, 1158 1158 * we need to replace it with an ethN device or the 1159 * networking will not start during an N FSrestore.1159 * networking will not start during an Network restore. 1160 1160 * 1161 * If the N FS device in nfs_dev begins with the word "bond", or alb or aft1162 * look for the corresponding slave ethN device and copy it to n fs_dev.1161 * If the Network device in netfs_dev begins with the word "bond", or alb or aft 1162 * look for the corresponding slave ethN device and copy it to netfs_dev. 1163 1163 * Using the common MAC address 1164 1164 ********/ 1165 if (!strncmp(n fs_dev, "bond", 4) || !strncmp(nfs_dev, "alb", 3) || !strncmp(nfs_dev, "aft", 3)) {1166 log_to_screen("Found bonding device %s; looking for corresponding ethN slave device\n", n fs_dev);1165 if (!strncmp(netfs_dev, "bond", 4) || !strncmp(netfs_dev, "alb", 3) || !strncmp(netfs_dev, "aft", 3)) { 1166 log_to_screen("Found bonding device %s; looking for corresponding ethN slave device\n", netfs_dev); 1167 1167 sprintf(command, 1168 "ifconfig %s | awk '{print $5}' | head -n1", n fs_dev);1168 "ifconfig %s | awk '{print $5}' | head -n1", netfs_dev); 1169 1169 strcpy(mac_addr, call_program_and_get_last_line_of_output(command)); 1170 1170 sprintf(command, 1171 "ifconfig | grep -E '%s' | grep -v '%s' | head -n1 | cut -d' ' -f1", mac_addr,nfs_dev); 1172 strcpy(nfs_dev, call_program_and_get_last_line_of_output(command)); 1173 log_to_screen("Replacing it with %s\n", nfs_dev); 1174 } 1175 1176 sprintf(tmp, "%s/NFS-DEV", bkpinfo->tmpdir); 1177 write_one_liner_data_file(tmp, nfs_dev); 1178 1179 sprintf(tmp, "%s/NFS-CLIENT-IPADDR", bkpinfo->tmpdir); 1180 write_one_liner_data_file(tmp, nfs_client_ipaddr); 1181 sprintf(tmp, "%s/NFS-CLIENT-NETMASK", bkpinfo->tmpdir); 1182 write_one_liner_data_file(tmp, nfs_client_netmask); 1183 sprintf(tmp, "%s/NFS-CLIENT-BROADCAST", bkpinfo->tmpdir); 1184 write_one_liner_data_file(tmp, nfs_client_broadcast); 1185 sprintf(tmp, "%s/NFS-CLIENT-DEFGW", bkpinfo->tmpdir); 1186 write_one_liner_data_file(tmp, nfs_client_defgw); 1187 sprintf(tmp, "%s/NFS-SERVER-IPADDR", bkpinfo->tmpdir); 1188 write_one_liner_data_file(tmp, nfs_server_ipaddr); 1189 sprintf(tmp, "%s/NFS-SERVER-MOUNT", bkpinfo->tmpdir); 1190 write_one_liner_data_file(tmp, bkpinfo->nfs_mount); 1191 sprintf(tmp, "%s/NFS-SERVER-PATH", bkpinfo->tmpdir); 1192 write_one_liner_data_file(tmp, bkpinfo->nfs_remote_dir); 1171 "ifconfig | grep -E '%s' | grep -v '%s' | head -n1 | cut -d' ' -f1", mac_addr,netfs_dev); 1172 strcpy(netfs_dev, call_program_and_get_last_line_of_output(command)); 1173 log_to_screen("Replacing it with %s\n", netfs_dev); 1174 } 1175 1176 sprintf(tmp, "%s/NETFS-DEV", bkpinfo->tmpdir); 1177 write_one_liner_data_file(tmp, netfs_dev); 1178 1179 sprintf(tmp, "%s/NETFS-PROTO", bkpinfo->tmpdir); 1180 write_one_liner_data_file(tmp, bkpinfo->netfs_proto); 1181 1182 sprintf(tmp, "%s/NETFS-CLIENT-IPADDR", bkpinfo->tmpdir); 1183 write_one_liner_data_file(tmp, netfs_client_ipaddr); 1184 sprintf(tmp, "%s/NETFS-CLIENT-NETMASK", bkpinfo->tmpdir); 1185 write_one_liner_data_file(tmp, netfs_client_netmask); 1186 sprintf(tmp, "%s/NETFS-CLIENT-BROADCAST", bkpinfo->tmpdir); 1187 write_one_liner_data_file(tmp, netfs_client_broadcast); 1188 sprintf(tmp, "%s/NETFS-CLIENT-DEFGW", bkpinfo->tmpdir); 1189 write_one_liner_data_file(tmp, netfs_client_defgw); 1190 sprintf(tmp, "%s/NETFS-SERVER-IPADDR", bkpinfo->tmpdir); 1191 write_one_liner_data_file(tmp, netfs_server_ipaddr); 1192 sprintf(tmp, "%s/NETFS-SERVER-MOUNT", bkpinfo->tmpdir); 1193 write_one_liner_data_file(tmp, bkpinfo->netfs_mount); 1194 sprintf(tmp, "%s/NETFS-SERVER-PATH", bkpinfo->tmpdir); 1195 write_one_liner_data_file(tmp, bkpinfo->netfs_remote_dir); 1193 1196 sprintf(tmp, "%s/ISO-PREFIX", bkpinfo->tmpdir); 1194 1197 write_one_liner_data_file(tmp, bkpinfo->prefix); 1195 log_it("Finished storing N FSconfiguration");1198 log_it("Finished storing Network configuration"); 1196 1199 } 1197 1200
Note:
See TracChangeset
for help on using the changeset viewer.