예제 #1
0
파일: network.c 프로젝트: gz/aos10
void
network_init(void)
{
    printf("\nStarting %s\n", __FUNCTION__);

    // Initialise the nslu2 hardware
    ixOsalOemInit(); 

    /* Initialise lwIP */
    mem_init();
    memp_init();
    pbuf_init();
    netif_init();
    udp_init();
    etharp_init();

    /* Setup the network interface */
    struct ip_addr netmask, ipaddr, gw;
    IP4_ADDR(&netmask, 255, 255, 255, 0);	// Standard net mask
    IP4_ADDR(&gw,      192, 168, 0, 1);		// Your host system
    IP4_ADDR(&ipaddr,  192, 168, 0, 2);		// The Slug's IP address

    struct netif *netif = netif_add(&ipaddr,&netmask,&gw, sosIfInit, ip_input);
    netif_set_default(netif);

    // Generate an arp entry for our gateway
    // We should only need to do this once, but Linux seems to love ignoring
    // ARP queries (why??!), so we keep trying until we get a response
    struct pbuf *p = etharp_query(netif, &netif->gw, NULL);
    do {
        (*netif_default->linkoutput)(netif, p);	// Direct output
        sos_usleep(100000);	// Wait a while for a reply
    } while (!etharp_entry_present(&netif->gw));
    pbuf_free(p);

    // Finish the initialisation of the nslu2 hardware
    ixOsalOSServicesFinaliseInit();


    /* Initialise NFS */
    int r = nfs_init(gw); assert(!r);

    mnt_get_export_list();	// Print out the exports on this server

    const char *msg;
    if (mnt_mount(NFS_DIR, &mnt_point))		// Mount aos_nfs
	msg = "%s: Error mounting path '%s'!\n";
    else
	msg = "Successfully mounted '%s'\n";
    printf(msg, __FUNCTION__, NFS_DIR);

    printf("Finished %s\n\n", __FUNCTION__);
}
예제 #2
0
파일: afs.C 프로젝트: bougyman/sfs
static void
afs_init2 (cbv cb, int stat, u_int64_t dev)
{
  if (stat)
    fatal ("mount (%s): %s\n", sfsroot, strerror (stat));
  root_dev = dev;
  update_devdb ();

  nfs_fh fh;
  afs_wait->mkfh (&fh);
  mnt_mount (dup (afsfd), "(sfswait)", strbuf ("%s/.mnt/wait", sfsroot),
	     v3flag | NMOPT_NOAC | NMOPT_RO | NMOPT_SOFT,
	     nfs_fh2tobytes (fh), wrap (afs_init3, cb));
}
예제 #3
0
파일: afs.C 프로젝트: bougyman/sfs
void
afs_init (cbv cb)
{
  tzset ();
  sfs_hosttab_init ();

  afsnode::sbp2aid = sbp2aid;

  afs_root = afsroot::alloc ();
  afs_root.Xleak ();		// Avoid global destruction order worries
  afs_sfsroot = afsusrdir::alloc (afs_root, sfsaid_sfs);
  afs_sfsroot.Xleak ();
  afs_naroot = afsusrroot::alloc (afs_root, sfsaid_nobody);
  afs_naroot.Xleak ();

  afs_mnt = afs_root->mkdir (".mnt");
  afs_wait = afsdir::alloc ();
  afs_wait.Xleak ();

  afs_mnt->mkdir ("wait");
  afs_sfsroot->link (afsreg::alloc (), ".root");
  afs_root->link (afsreg::alloc (VERSION "\n"), ".version");
  afs_root->link (afsreg::alloc (strbuf ("%d\n", int (getpid ()))), ".pid");
#if FIX_MNTPOINT
  if (opt_fix_mntpoint)
    afs_linuxbug = afs_root->mkdir (".linuxmnt");
#endif /* FIX_MNTPOINT */

  afsfd = inetsocket (SOCK_DGRAM, nomounting ? 2490 : 0, INADDR_LOOPBACK);
  if (afsfd < 0)
    fatal ("afs_init: inetsocket: %m\n");
  ref<axprt> x (axprt_dgram::alloc (afsfd));
  afssrv = asrv::alloc (x, nfs_program_2, wrap (afs_dispatch));
  afssrv3 = asrv::alloc (x, nfs_program_3, wrap (afs_dispatch));

  sigcb (SIGINT, wrap (afs_shutdown, true));
  sigcb (SIGTERM, wrap (afs_shutdown, true));

  nfs_fh fh;
  afs_root->mkfh (&fh);
  mnt_mount (dup (afsfd), "(sfs)", sfsroot,
	     v3flag | NMOPT_NOAC | NMOPT_SOFT,
	     nfs_fh2tobytes (fh), wrap (afs_init2, cb));
}