Esempio n. 1
0
int
main (int argc, char *argv[])
{
  error_t err;
  mach_port_t bootstrap;
  struct dev device;
  struct storeio_argp_params params;

  bzero (&device, sizeof device);
  mutex_init (&device.lock);

  params.dev = &device;
  argp_parse (&argp, argc, argv, 0, 0, &params);

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

  /* Reply to our parent */
  err = trivfs_startup (bootstrap, 0, 0, 0, 0, 0, &storeio_fsys);
  if (err)
    error (3, err, "trivfs_startup");

  storeio_fsys->hook = &device;

  /* Launch. */
  ports_manage_port_operations_multithread (storeio_fsys->pi.bucket,
					    trivfs_demuxer,
					    30*1000, 5*60*1000, 0);

  return 0;
}
Esempio n. 2
0
int
main (int argc, char **argv)
{
    error_t err;
    mach_port_t bootstrap;
    struct trivfs_control *fsys;

    fifo_pipe_class = stream_pipe_class;

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

    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, 0, 0, 0, 0, &fsys);
    mach_port_deallocate (mach_task_self (), bootstrap);
    if (err)
        error (3, err, "Contacting parent");

    /* Launch. */
    do
    {
        ports_enable_class (fsys->protid_class);
        ports_manage_port_operations_multithread (fsys->pi.bucket,
                trivfs_demuxer,
                30*1000, 5*60*1000, 0);
    }
    while (ports_count_class (fsys->protid_class) > 0);

    return 0;
}
Esempio n. 3
0
int
main (int argc, char **argv)
{
  error_t err;
  mach_port_t bootstrap;

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

  if (MACH_PORT_VALID (opt_device_master))
    {
      err = open_console (opt_device_master);
      assert_perror (err);
      mach_port_deallocate (mach_task_self (), opt_device_master);
    }

  save_argv = argv;

  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 ();

  err = trivfs_add_port_bucket (&port_bucket);
  if (err)
    error (1, 0, "error creating port bucket");

  err = trivfs_add_control_port_class (&trivfs_control_class);
  if (err)
    error (1, 0, "error creating control port class");

  err = trivfs_add_protid_port_class (&trivfs_protid_class);
  if (err)
    error (1, 0, "error creating protid port class");

  execboot_portclass = ports_create_class (deadboot, NULL);

  /* Reply to our parent.  */
  err = trivfs_startup (bootstrap, 0,
                        trivfs_control_class, port_bucket,
                        trivfs_protid_class, port_bucket, &fsys);

  /* Reply to our parent.  */
  err = trivfs_startup (bootstrap, 0,
			trivfs_control_class, port_bucket,
			trivfs_protid_class, 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;
}
Esempio n. 4
0
/* A top-level function for the paging thread that just services paging
   requests.  */
static void
service_paging_requests (any_t arg)
{
  struct port_bucket *pager_bucket = arg;
  for (;;)
    ports_manage_port_operations_multithread (pager_bucket,
					      pager_demuxer,
					      1000 * 60 * 2,
					      1000 * 60 * 10, 0);
}
Esempio n. 5
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;
}
Esempio n. 6
0
void
netfs_server_loop ()
{
  error_t err;

  do 
    {
      ports_manage_port_operations_multithread (netfs_port_bucket,
						netfs_demuxer,
						thread_timeout,
						server_timeout,
						0);
      err = netfs_shutdown (0);
    }
  while (err);
  
  exit (0);
}
Esempio n. 7
0
int
main (int argc, char **argv)
{
  error_t err;
  mach_port_t bootstrap;
  struct trivfs_control *fsys;
  mach_port_t host_priv;

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

  err = get_privileged_ports (&host_priv, &dev_master);
  if (err)
    error (2, err, "cannot get privileged ports");
  real_defpager = MACH_PORT_NULL;
  err = vm_set_default_memory_manager (host_priv, &real_defpager);
  mach_port_deallocate (mach_task_self (), host_priv);
  if (err)
    error (3, err, "vm_set_default_memory_manager");
  if (real_defpager == MACH_PORT_NULL)
    error (1, 0, "no default memory manager set!");

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

  err = trivfs_add_protid_port_class (&trivfs_protid_class);
  if (err)
    error (1, 0, "error creating protid port class");

  /* Reply to our parent.  */
  err = trivfs_startup (bootstrap, 0, 0, 0, trivfs_protid_class, 0, &fsys);
  mach_port_deallocate (mach_task_self (), bootstrap);
  if (err)
    error (4, err, "Contacting parent");

  /* Launch. */
  ports_manage_port_operations_multithread (fsys->pi.bucket,
					    proxy_defpager_demuxer,
					    2 * 60 * 1000, 0, 0);

  return 0;
}
Esempio n. 8
0
/* Handle socket requests while there are sockets around.  */
static void *
handle_sock_requests (void *unused)
{
  while (ports_count_bucket (sock_port_bucket) > 0)
    {
      ports_enable_bucket (sock_port_bucket);
      ports_manage_port_operations_multithread (sock_port_bucket, sock_demuxer,
						30*1000, 2*60*1000, 0);
    }

  /* The last service thread is about to exist; make this known.  */
  pthread_spin_lock (&sock_server_active_lock);
  sock_server_active = 0;
  pthread_spin_unlock (&sock_server_active_lock);

  /* Let the whole joke start once again.  */
  ports_enable_bucket (sock_port_bucket);

  return NULL;
}
Esempio n. 9
0
File: main.c Progetto: 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);
}
Esempio n. 10
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);
}
Esempio n. 11
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;
}