int gesys_network_start() { char *buf; #ifdef MULTI_NETDRIVER printf("Going to probe for Ethernet chips when initializing networking:\n"); printf("(supported are 3c509 (ISA), 3c90x (PCI) and eepro100 (PCI) variants).\n"); printf("NOTES:\n"); printf(" - Initializing a 3c90x may take a LONG time (~1min); PLUS: it NEEDS media\n"); printf(" autonegotiation!\n"); printf(" - A BOOTP/DHCP server must supply my IF configuration\n"); printf(" (ip address, mask, [gateway, dns, ntp])\n"); #endif #ifdef BSP_NETWORK_SETUP { extern int BSP_NETWORK_SETUP(struct rtems_bsdnet_config *, struct rtems_bsdnet_ifconfig *); BSP_NETWORK_SETUP(&rtems_bsdnet_config, 0); } #endif rtems_bsdnet_initialize_network(); /* remote logging only works after a call to openlog()... */ openlog(0, LOG_PID | LOG_CONS, 0); /* use RTEMS defaults */ #ifdef TFTP_SUPPORT if (rtems_bsdnet_initialize_tftp_filesystem()) perror("TFTP FS initialization failed"); #endif #ifdef NFS_SUPPORT if ( rpcUdpInit() || nfsInit(0,0) ) /* nothing else to do */; #endif if ( rtems_bsdnet_ntpserver_count > 0 ) { printf("Trying to synchronize NTP..."); fflush(stdout); if (rtems_bsdnet_synchronize_ntp(0,0)<0) printf("FAILED\n"); else printf("OK\n"); rtems_time_of_day time; rtems_clock_get(RTEMS_CLOCK_GET_TOD, &time); printf("yr:%u m:%u d:%u hr:%u min:%u sec:%u\n",\ time.year,time.month,time.day,\ time.hour,time.minute,time.second); fflush(stdout); } /* stuff command line 'name=value' pairs into the environment */ if ( (buf = strdup(rtems_bsdnet_bootp_cmdline)) ) { cmdlinePairExtract(buf, putenv, 1); free(buf); } return 0; }
static void initialize_remote_filesystem(char **argv, int hasLocalFilesystem) { #ifdef OMIT_NFS_SUPPORT printf ("***** Initializing TFTP *****\n"); #if __RTEMS_MAJOR__>4 || \ (__RTEMS_MAJOR__==4 && __RTEMS_MINOR__>9) || \ (__RTEMS_MAJOR__==4 && __RTEMS_MINOR__==9 && __RTEMS_REVISION__==99) mount_and_make_target_path(NULL, "/TFTP", RTEMS_FILESYSTEM_TYPE_TFTPFS, RTEMS_FILESYSTEM_READ_WRITE, NULL); #else rtems_bsdnet_initialize_tftp_filesystem (); #endif if (!hasLocalFilesystem) { char *path; int pathsize = 200; int l; path = mustMalloc(pathsize, "Command path name "); strcpy (path, "/TFTP/BOOTP_HOST/epics/"); l = strlen (path); if (gethostname (&path[l], pathsize - l - 10) || (path[l] == '\0')) { LogFatal ("Can't get host name"); } strcat (path, "/st.cmd"); argv[1] = path; } #else char *server_name; char *server_path; char *mount_point; char *cp; int l = 0; printf ("***** Initializing NFS *****\n"); NFS_INIT if (env_nfsServer && env_nfsPath && env_nfsMountPoint) { server_name = env_nfsServer; server_path = env_nfsPath; mount_point = env_nfsMountPoint; cp = mount_point; while ((cp = strchr(cp+1, '/')) != NULL) { *cp = '\0'; if ((mkdir (mount_point, 0755) != 0) && (errno != EEXIST)) LogFatal("Can't create directory \"%s\": %s.\n", mount_point, strerror(errno)); *cp = '/'; } argv[1] = rtems_bsdnet_bootp_cmdline; } else if (hasLocalFilesystem) { return; } else { /* * Use first component of nvram/bootp command line pathname * to set up initial NFS mount. A "/tftpboot/" is prepended * if the pathname does not begin with a '/'. This allows * NFS and TFTP to have a similar view of the remote system. */ if (rtems_bsdnet_bootp_cmdline[0] == '/') cp = rtems_bsdnet_bootp_cmdline + 1; else cp = rtems_bsdnet_bootp_cmdline; cp = strchr(cp, '/'); if ((cp == NULL) || ((l = cp - rtems_bsdnet_bootp_cmdline) == 0)) LogFatal("\"%s\" is not a valid command pathname.\n", rtems_bsdnet_bootp_cmdline); cp = mustMalloc(l + 20, "NFS mount paths"); server_path = cp; server_name = rtems_bsdnet_bootp_server_name; if (rtems_bsdnet_bootp_cmdline[0] == '/') { mount_point = server_path; strncpy(mount_point, rtems_bsdnet_bootp_cmdline, l); mount_point[l] = '\0'; argv[1] = rtems_bsdnet_bootp_cmdline; /* * Its probably common to embed the mount point in the server * name so, when this is occurring, dont clobber the mount point * by appending the first node from the command path. This allows * the mount point to be a different path then the server's mount * path. * * This allows for example a line similar to as follows the DHCP * configuration file. * * server-name "[email protected]:/vol/vol0/bootRTEMS"; */ if ( server_name ) { const size_t allocSize = strlen ( server_name ) + 2; char * const pServerName = mustMalloc( allocSize, "NFS mount paths"); char * const pServerPath = mustMalloc ( allocSize, "NFS mount paths"); const int scanfStatus = sscanf ( server_name, "%[^:] : / %s", pServerName, pServerPath + 1u ); if ( scanfStatus == 2 ) { pServerPath[0u]= '/'; server_name = pServerName; server_path = pServerPath; } else { free ( pServerName ); free ( pServerPath ); } } } else { char *abspath = mustMalloc(strlen(rtems_bsdnet_bootp_cmdline)+2,"Absolute command path"); strcpy(server_path, "/tftpboot/"); mount_point = server_path + strlen(server_path); strncpy(mount_point, rtems_bsdnet_bootp_cmdline, l); mount_point[l] = '\0'; mount_point--; strcpy(abspath, "/"); strcat(abspath, rtems_bsdnet_bootp_cmdline); argv[1] = abspath; } } nfsMount(server_name, server_path, mount_point); #endif }