Ignore:
Timestamp:
Sep 9, 2009, 8:30:47 PM (15 years ago)
Author:
Bruno Cornec
Message:
  • Change NFS support into a NetFS support to allow for multiple protocol in addition to NFS (NEEDS TESTING)
  • Better logging to detect a potential nuke issue
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mondo/src/common/libmondo-files.c

    r2242 r2380  
    10911091
    10921092/**
    1093  * Store the client's NFS configuration in files to be restored at restore-time.
    1094  * Assumes that @c bkpinfo->media_type = nfs, 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.
    10951095 * @param bkpinfo The backup information structure. Fields used:
    1096  * - @c nfs_mount
    1097  * - @c nfs_remote_dir
     1096 * - @c netfs_mount
     1097 * - @c netfs_remote_dir
    10981098 * - @c tmpdir
    10991099 */
    1100 void store_nfs_config()
     1100void store_netfs_config()
    11011101{
    11021102
    11031103    /*@ buffers ******** */
    1104     char nfs_dev[MAX_STR_LEN];
     1104    char netfs_dev[MAX_STR_LEN];
    11051105    char mac_addr[MAX_STR_LEN];
    1106     char nfs_mount[MAX_STR_LEN];
    1107     char nfs_client_ipaddr[MAX_STR_LEN];
    1108     char nfs_client_netmask[MAX_STR_LEN];
    1109     char nfs_client_broadcast[MAX_STR_LEN];
    1110     char nfs_client_defgw[MAX_STR_LEN];
    1111     char nfs_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];
    11121112    char tmp[MAX_STR_LEN];
    11131113    char command[MAX_STR_LEN * 2];
     
    11161116    char *p;
    11171117
    1118     log_it("Storing NFS configuration");
    1119     strcpy(tmp, bkpinfo->nfs_mount);
     1118    log_it("Storing Network configuration");
     1119    strcpy(tmp, bkpinfo->netfs_mount);
    11201120    p = strchr(tmp, ':');
    11211121    if (!p) {
    11221122        fatal_error
    1123             ("NFS mount 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");
    11241124    }
    11251125    *(p++) = '\0';
    1126     strcpy(nfs_server_ipaddr, tmp);
    1127     strcpy(nfs_mount, p);
     1126    strcpy(netfs_server_ipaddr, tmp);
     1127    strcpy(netfs_mount, p);
    11281128
    11291129    /* BERLIOS : there is a bug #67 here as it only considers the first NIC */
    11301130    sprintf(command,
    11311131            "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\n' | head -n1 | cut -d' ' -f1");
    1132     strcpy(nfs_dev, call_program_and_get_last_line_of_output(command));
     1132    strcpy(netfs_dev, call_program_and_get_last_line_of_output(command));
    11331133    sprintf(command,
    11341134            "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f7 | cut -d':' -f2");
    1135     strcpy(nfs_client_ipaddr,
     1135    strcpy(netfs_client_ipaddr,
    11361136           call_program_and_get_last_line_of_output(command));
    11371137    sprintf(command,
    11381138            "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f9 | cut -d':' -f2");
    1139     strcpy(nfs_client_netmask,
     1139    strcpy(netfs_client_netmask,
    11401140           call_program_and_get_last_line_of_output(command));
    11411141    sprintf(command,
    11421142            "ifconfig | tr '\n' '#' | sed s/##// | tr '#' ' ' | tr '' '\\n' | head -n1 | tr -s '\t' ' ' | cut -d' ' -f8 | cut -d':' -f2");
    1143     strcpy(nfs_client_broadcast,
     1143    strcpy(netfs_client_broadcast,
    11441144           call_program_and_get_last_line_of_output(command));
    11451145    sprintf(command,
    11461146            "route -n | grep '^0.0.0.0' | awk '{print $2}'");
    1147     strcpy(nfs_client_defgw,
     1147    strcpy(netfs_client_defgw,
    11481148           call_program_and_get_last_line_of_output(command));
    11491149    sprintf(tmp,
    1150             "nfs_client_ipaddr=%s; nfs_server_ipaddr=%s; nfs_mount=%s",
    1151             nfs_client_ipaddr, nfs_server_ipaddr, nfs_mount);
    1152     if (strlen(nfs_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) {
    11531153        fatal_error
    1154             ("Unable to find ethN (eth0, eth1, ...) adapter via NFS mount you specified.");
     1154            ("Unable to find ethN (eth0, eth1, ...) adapter via Network mount you specified.");
    11551155    }
    11561156    /********
    1157     * If the NFS device that found above is a bonded device,
     1157    * If the Network device that found above is a bonded device,
    11581158    * we need to replace it with an ethN device or the
    1159     * networking will not start during an NFS restore.
     1159    * networking will not start during an Network restore.
    11601160    *
    1161     * If the NFS device in nfs_dev begins with the word "bond", or alb or aft
    1162     * look for the corresponding slave ethN device and copy it to nfs_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.
    11631163    * Using the common MAC address
    11641164    ********/
    1165     if (!strncmp(nfs_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", nfs_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);
    11671167        sprintf(command,
    1168                 "ifconfig %s | awk '{print $5}' | head -n1", nfs_dev);
     1168                "ifconfig %s | awk '{print $5}' | head -n1", netfs_dev);
    11691169        strcpy(mac_addr, call_program_and_get_last_line_of_output(command));
    11701170        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);
    11931196    sprintf(tmp, "%s/ISO-PREFIX", bkpinfo->tmpdir);
    11941197    write_one_liner_data_file(tmp, bkpinfo->prefix);
    1195     log_it("Finished storing NFS configuration");
     1198    log_it("Finished storing Network configuration");
    11961199}
    11971200
Note: See TracChangeset for help on using the changeset viewer.