Exemplo n.º 1
0
void
netfs_init ()
{
  netfs_protid_class = ports_create_class (netfs_release_protid, 0);
  netfs_control_class = ports_create_class (0, 0);
  netfs_port_bucket = ports_create_bucket ();
  netfs_auth_server_port = getauth ();
  mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE, 
		      &netfs_fsys_identity);
}
Exemplo n.º 2
0
int
main (int argc, char **argv)
{
  error_t err;
  mach_port_t bootstrap;
  struct argp argp = { 0, 0, 0, "Hurd standard exec server." };

  argp_parse (&argp, argc, argv, 0, 0, 0);

  save_argv = argv;

#ifdef BFD
  /* Put the Mach kernel's idea of what flavor of machine this is into the
     fake BFD against which architecture compatibility checks are made.  */
  err = bfd_mach_host_arch_mach (mach_host_self (),
				 &host_bfd.arch_info->arch,
				 &host_bfd.arch_info->mach);
  if (err)
    error (1, err, "Getting host architecture from Mach");
#endif

  task_get_bootstrap_port (mach_task_self (), &bootstrap);
  if (bootstrap == MACH_PORT_NULL)
    error (2, 0, "Must be started as a translator");

  /* Fetch our proc server port for easy use.  If we are booting, it is not
     set yet and `getproc' returns MACH_PORT_NULL; we reset PROCSERVER in
     S_exec_init (below).  */
  procserver = getproc ();

  port_bucket = ports_create_bucket ();
  trivfs_cntl_portclasses[0] = ports_create_class (trivfs_clean_cntl, 0);
  trivfs_protid_portclasses[0] = ports_create_class (trivfs_clean_protid, 0);
  execboot_portclass = ports_create_class (deadboot, NULL);

  /* Reply to our parent.  */
  err = trivfs_startup (bootstrap, 0,
			trivfs_cntl_portclasses[0], port_bucket,
			trivfs_protid_portclasses[0], port_bucket,
			&fsys);
  mach_port_deallocate (mach_task_self (), bootstrap);
  if (err)
    error (3, err, "Contacting parent");

  /* Launch.  */
  ports_manage_port_operations_multithread (port_bucket, exec_demuxer,
					    2 * 60 * 1000, 0, 0);

  return 0;
}
Exemplo n.º 3
0
Arquivo: pager.c Projeto: Larhard/hurd
/* Initialize the pager for the display component.  */
void
user_pager_init (void)
{
  pthread_t thread;
  error_t err;

  /* Create the pager bucket, and start to serve paging requests.  */
  pager_bucket = ports_create_bucket ();
  if (! pager_bucket)
    error (5, errno, "Cannot create pager bucket");

  /* Start libpagers worker threads.  */
  err = pager_start_workers (pager_bucket);
  if (err)
    error (5, err, "Cannot start pager worker threads");
}
Exemplo n.º 4
0
int
main (int argc, char **argv)
{
  error_t err;
  mach_port_t pflocal;
  mach_port_t bootstrap;
  char buf[512];
  const struct argp argp = { 0, 0, 0, doc };

  argp_parse (&argp, argc, argv, 0, 0, 0);

  control_class = ports_create_class (trivfs_clean_cntl, 0);
  node_class = ports_create_class (trivfs_clean_protid, 0);
  port_bucket = ports_create_bucket ();
  trivfs_protid_portclasses[0] = node_class;
  trivfs_cntl_portclasses[0] = control_class;

  task_get_bootstrap_port (mach_task_self (), &bootstrap);
  if (bootstrap == MACH_PORT_NULL)
    error(1, 0, "Must be started as a translator");

  /* Reply to our parent */
  err = trivfs_startup (bootstrap, 0, control_class, port_bucket,
			node_class, port_bucket, NULL);
  mach_port_deallocate (mach_task_self (), bootstrap);
  if (err)
    error(2, err, "Contacting parent");

  /* Try and connect to the pflocal server */
  sprintf (buf, "%s/%d", _SERVERS_SOCKET, PF_LOCAL);
  pflocal = file_name_lookup (buf, 0, 0);

  if (pflocal == MACH_PORT_NULL)
    address_port = MACH_PORT_NULL;
  else
    {
      err = socket_fabricate_address (pflocal, AF_LOCAL, &address_port);
      if (err)
	address_port = MACH_PORT_NULL;
      mach_port_deallocate (mach_task_self (), pflocal);
    }

  /* Launch. */
  ports_manage_port_operations_one_thread (port_bucket, demuxer, 0);
  return 0;
}
Exemplo n.º 5
0
void
ethernet_initialize (void)
{
  pthread_t thread;
  error_t err;
  etherport_bucket = ports_create_bucket ();
  etherreadclass = ports_create_class (0, 0);

  err = pthread_create (&thread, NULL, ethernet_thread, NULL);
  if (!err)
    pthread_detach (thread);
  else
    {
      errno = err;
      perror ("pthread_create");
    }
}
Exemplo n.º 6
0
Arquivo: main.c Projeto: Larhard/hurd
int
main (int argc, char **argv, char **envp)
{
  mach_port_t boot;
  error_t err;
  void *genport;
  process_t startup_port;
  mach_port_t startup;
  struct argp argp = { 0, 0, 0, "Hurd process server" };

  argp_parse (&argp, argc, argv, 0, 0, 0);

  initialize_version_info ();

  err = task_get_bootstrap_port (mach_task_self (), &boot);
  assert_perror (err);
  if (boot == MACH_PORT_NULL)
    error (2, 0, "proc server can only be run by init during boot");

  proc_bucket = ports_create_bucket ();
  proc_class = ports_create_class (0, 0);
  generic_port_class = ports_create_class (0, 0);
  exc_class = ports_create_class (exc_clean, 0);
  ports_create_port (generic_port_class, proc_bucket,
		     sizeof (struct port_info), &genport);
  generic_port = ports_get_right (genport);

  /* Create the initial proc object for init (PID 1).  */
  init_proc = create_init_proc ();

  /* Create the startup proc object for /hurd/init (PID 2).  */
  startup_proc = allocate_proc (MACH_PORT_NULL);
  startup_proc->p_deadmsg = 1;
  complete_proc (startup_proc, HURD_PID_STARTUP);

  /* Create our own proc object.  */
  self_proc = allocate_proc (mach_task_self ());
  assert (self_proc);

  complete_proc (self_proc, HURD_PID_PROC);

  startup_port = ports_get_send_right (startup_proc);
  err = startup_procinit (boot, startup_port, &startup_proc->p_task,
			  &authserver, &_hurd_host_priv, &_hurd_device_master);
  assert_perror (err);
  mach_port_deallocate (mach_task_self (), startup_port);

  mach_port_mod_refs (mach_task_self (), authserver, MACH_PORT_RIGHT_SEND, 1);
  _hurd_port_set (&_hurd_ports[INIT_PORT_AUTH], authserver);
  mach_port_deallocate (mach_task_self (), boot);

  proc_death_notify (startup_proc);
  add_proc_to_hash (startup_proc); /* Now that we have the task port.  */

  /* Set our own argv and envp locations.  */
  self_proc->p_argv = (vm_address_t) argv;
  self_proc->p_envp = (vm_address_t) envp;

  /* Give ourselves good scheduling performance, because we are so
     important. */
  err = increase_priority ();
  if (err)
    error (0, err, "Increasing priority failed");

#if 0
  err = register_new_task_notification (_hurd_host_priv,
					generic_port,
					MACH_MSG_TYPE_MAKE_SEND);
  if (err)
    error (0, err, "Registering task notifications failed");
#endif

  {
    /* Get our stderr set up to print on the console, in case we have
       to panic or something.  */
    mach_port_t cons;
    error_t err;
    err = device_open (_hurd_device_master, D_READ|D_WRITE, "console", &cons);
    assert_perror (err);
    stdin = mach_open_devstream (cons, "r");
    stdout = stderr = mach_open_devstream (cons, "w");
    mach_port_deallocate (mach_task_self (), cons);
  }

  startup = file_name_lookup (_SERVERS_STARTUP, 0, 0);
  if (MACH_PORT_VALID (startup))
    {
      err = startup_essential_task (startup, mach_task_self (),
				    MACH_PORT_NULL, "proc", _hurd_host_priv);
      if (err)
	/* Due to the single-threaded nature of /hurd/startup, it can
	   only handle requests once the core server bootstrap has
	   completed.  Therefore, it does not bind itself to
	   /servers/startup until it is ready.	*/
	/* Fall back to abusing the message port lookup.  */
	startup_fallback = 1;

      err = mach_port_deallocate (mach_task_self (), startup);
      assert_perror (err);
    }
  else
    /* Fall back to abusing the message port lookup.	*/
    startup_fallback = 1;

  while (1)
    ports_manage_port_operations_multithread (proc_bucket,
					      message_demuxer,
					      0, 0, 0);
}
Exemplo n.º 7
0
int
main (int argc, char **argv, char **envp)
{
  mach_port_t boot;
  error_t err;
  mach_port_t pset, psetcntl;
  void *genport;
  process_t startup_port;
  struct argp argp = { 0, 0, 0, "Hurd process server" };

  argp_parse (&argp, argc, argv, 0, 0, 0);

  initialize_version_info ();

  err = task_get_bootstrap_port (mach_task_self (), &boot);
  assert_perror (err);
  if (boot == MACH_PORT_NULL)
    error (2, 0, "proc server can only be run by init during boot");

  proc_bucket = ports_create_bucket ();
  proc_class = ports_create_class (0, 0);
  generic_port_class = ports_create_class (0, 0);
  exc_class = ports_create_class (exc_clean, 0);
  ports_create_port (generic_port_class, proc_bucket,
		     sizeof (struct port_info), &genport);
  generic_port = ports_get_right (genport);

  /* Create the initial proc object for init (PID 1).  */
  startup_proc = create_startup_proc ();

  /* Create our own proc object (we are PID 0).  */
  self_proc = allocate_proc (mach_task_self ());
  assert (self_proc);

  complete_proc (self_proc, 0);

  startup_port = ports_get_send_right (startup_proc);
  err = startup_procinit (boot, startup_port, &startup_proc->p_task,
			  &authserver, &master_host_port, &master_device_port);
  assert_perror (err);
  mach_port_deallocate (mach_task_self (), startup_port);

  mach_port_mod_refs (mach_task_self (), authserver, MACH_PORT_RIGHT_SEND, 1);
  _hurd_port_set (&_hurd_ports[INIT_PORT_AUTH], authserver);
  mach_port_deallocate (mach_task_self (), boot);

  proc_death_notify (startup_proc);
  add_proc_to_hash (startup_proc); /* Now that we have the task port.  */

  /* Set our own argv and envp locations.  */
  self_proc->p_argv = (vm_address_t) argv;
  self_proc->p_envp = (vm_address_t) envp;

  /* Give ourselves good scheduling performance, because we are so
     important. */
  err = thread_get_assignment (mach_thread_self (), &pset);
  assert_perror (err);
  err = host_processor_set_priv (master_host_port, pset, &psetcntl);
  assert_perror (err);
  thread_max_priority (mach_thread_self (), psetcntl, 0);
  assert_perror (err);
  err = task_priority (mach_task_self (), 2, 1);
  assert_perror (err);

  mach_port_deallocate (mach_task_self (), pset);
  mach_port_deallocate (mach_task_self (), psetcntl);

  {
    /* Get our stderr set up to print on the console, in case we have
       to panic or something.  */
    mach_port_t cons;
    error_t err;
    err = device_open (master_device_port, D_READ|D_WRITE, "console", &cons);
    assert_perror (err);
    stdin = mach_open_devstream (cons, "r");
    stdout = stderr = mach_open_devstream (cons, "w");
    mach_port_deallocate (mach_task_self (), cons);
  }

  while (1)
    ports_manage_port_operations_multithread (proc_bucket,
					      message_demuxer,
					      0, 0, 0);
}
Exemplo n.º 8
0
int
main (int argc,
      char **argv)
{
    error_t err;
    mach_port_t bootstrap;
    struct stat st;
    pthread_t thread;

    pfinet_bucket = ports_create_bucket ();
    addrport_class = ports_create_class (clean_addrport, 0);
    socketport_class = ports_create_class (clean_socketport, 0);
    mach_port_allocate (mach_task_self (), MACH_PORT_RIGHT_RECEIVE,
                        &fsys_identity);

    /* Generic initialization */

    init_time ();
    ethernet_initialize ();
    err = pthread_create (&thread, NULL, net_bh_worker, NULL);
    if (!err)
        pthread_detach (thread);
    else
    {
        errno = err;
        perror ("pthread_create");
    }

    pthread_mutex_lock (&global_lock);

    prepare_current (1);		/* Set up to call into Linux initialization. */

    sk_init ();
#ifdef SLAB_SKB
    skb_init ();
#endif
    inet_proto_init (0);

    /* This initializes the Linux network device layer, including
       initializing each device on the `dev_base' list.  For us,
       that means just loopback_dev, which will get fully initialized now.
       After this, we can use `register_netdevice' for new interfaces.  */
    net_dev_init ();

    /* ifconfig lo up 127.0.0.1 netmask 0xff000000 */
    configure_device (&loopback_dev,
                      htonl (INADDR_LOOPBACK), htonl (IN_CLASSA_NET),
                      htonl (INADDR_NONE), htonl (INADDR_NONE));

    pthread_mutex_unlock (&global_lock);

    /* Parse options.  When successful, this configures the interfaces
       before returning; to do so, it will acquire the global_lock.
       (And when not successful, it never returns.)  */
    argp_parse (&pfinet_argp, argc, argv, 0,0,0);

    task_get_bootstrap_port (mach_task_self (), &bootstrap);

    pfinet_owner = pfinet_group = 0;

    if (bootstrap != MACH_PORT_NULL) {
        /* Create portclass to install on the bootstrap port. */
        if(pfinet_protid_portclasses[pfinet_bootstrap_portclass]
                != MACH_PORT_NULL)
            error(1, 0, "No portclass left to assign to bootstrap port");

#ifdef CONFIG_IPV6
        if (pfinet_bootstrap_portclass == PORTCLASS_INET6)
            pfinet_activate_ipv6 ();
#endif

        err = trivfs_add_protid_port_class (
                  &pfinet_protid_portclasses[pfinet_bootstrap_portclass]);
        if (err)
            error (1, 0, "error creating control port class");

        err = trivfs_add_control_port_class (
                  &pfinet_cntl_portclasses[pfinet_bootstrap_portclass]);
        if (err)
            error (1, 0, "error creating control port class");

        /* Talk to parent and link us in.  */
        err = trivfs_startup (bootstrap, 0,
                              pfinet_cntl_portclasses[pfinet_bootstrap_portclass],
                              pfinet_bucket,
                              pfinet_protid_portclasses[pfinet_bootstrap_portclass],
                              pfinet_bucket,
                              &pfinetctl);

        if (err)
            error (1, err, "contacting parent");

        /* Initialize status from underlying node.  */
        err = io_stat (pfinetctl->underlying, &st);
        if (! err)
        {
            pfinet_owner = st.st_uid;
            pfinet_group = st.st_gid;
        }
    }
    else { /* no bootstrap port. */
        int i;
        /* Check that at least one portclass has been bound,
           error out otherwise. */
        for (i = 0; i < ARRAY_SIZE (pfinet_protid_portclasses); i++)
            if (pfinet_protid_portclasses[i] != MACH_PORT_NULL)
                break;

        if (i == ARRAY_SIZE (pfinet_protid_portclasses))
            error (1, 0, "should be started as a translator.\n");
    }

    /* Ask init to tell us when the system is going down,
       so we can try to be friendly to our correspondents on the network.  */
    arrange_shutdown_notification ();

    /* Launch */
    ports_manage_port_operations_multithread (pfinet_bucket,
            pfinet_demuxer,
            30 * 1000, 2 * 60 * 1000, 0);
    return 0;
}