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; }
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; }
int main() { kern_return_t err; mach_port_t bootstrap; struct trivfs_control *fsys; task_get_bootstrap_port(mach_task_self(), &bootstrap); if (bootstrap == MACH_PORT_NULL) { printf("bootstrap.\n"); } err = trivfs_startup(bootstrap, 0, 0, 0, 0, 0, &fsys); if (err) { printf("the trivfs_startup.\n"); } ports_manage_port_operations_one_thread(fsys -> pi.bucket, demuxer, 0); return 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, ¶ms); 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; }
int main(int argc, char *argv[]) { int err; mach_port_t bootstrap; struct trivfs_control *fsys; if (argc > 1) { fprintf(stderr, "Usage: settrans [opts] node %s\n", program_invocation_name); exit (1); } 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,&fsys); mach_port_deallocate (mach_task_self (), bootstrap); if (err) { return (0); } ports_manage_port_operations_one_thread (fsys->pi.bucket, demuxer, 0); return 0; }
/* main */ int main (int argc, char *argv[]) { error_t err; mach_port_t bootstrap; struct trivfs_control *fsys; err = argp_parse(&argp, argc, argv, 0, NULL, NULL); if (err) { error(1, err, "argp_parse"); } task_get_bootstrap_port(mach_task_self(), &bootstrap); if (bootstrap == MACH_PORT_NULL) { error(1, 0, "must be started as translator"); } /* reply to our parent */ err = trivfs_startup(bootstrap, 0, NULL, NULL, NULL, NULL, &fsys); if (err) { error(3, err, "trivfs_startup"); } /* launch translator */ init_logging(); info("start oss translator"); info("init rump"); rump_init(); debug("open rump audio device"); audio_fd = rump_sys_open(RUMP_AUDIO_DEVICE, O_WRONLY); if (audio_fd < 0) { err("rump_open(%s, O_WRONLY): %s", RUMP_AUDIO_DEVICE, rump_strerror(errno)); return EIO; } /* set default parameters */ audio_info_t info; AUDIO_INITINFO(&info); info.play.sample_rate = 44100; info.play.channels = 1; info.play.precision = 16; info.play.encoding = AUDIO_ENCODING_LINEAR; info.play.samples = 0; if (rump_sys_ioctl(audio_fd, AUDIO_SETINFO, &info)) { err("rump_sys_ioctl AUDIO_SETINFO: %s", rump_strerror(errno)); return EIO; } /* wait for orders */ info("wait for orders"); ports_manage_port_operations_one_thread(fsys->pi.bucket, oss_demuxer, 0); return 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; }
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; }
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; }
int main(int argc, char *argv[]) { mach_port_t bootstrap; struct trivfs_control *control; error_t err; argp_parse(&kgi_argp, argc, argv, 0, NULL, NULL); init_module(); if(!display) error(3, 0, "No suitable display found... I'm bored, bye."); task_get_bootstrap_port(mach_task_self(), &bootstrap); if(bootstrap == MACH_PORT_NULL) { /* not started as translator */ printf("Init complete; press <return>.\n"); getchar(); setmode(); printf("setmode() complete; press <return>.\n"); getchar(); draw_crap(); printf("draw_crap() complete; press <return>.\n"); getchar(); unsetmode(); printf("unsetmode() complete; press <return>.\n"); getchar(); cleanup_module(); assert(!display); return 0; } err = trivfs_startup(bootstrap, 0, NULL, NULL, NULL, NULL, &control); mach_port_deallocate(mach_task_self(), bootstrap); if(err) error(2, err, "trivfs_startup"); ports_manage_port_operations_one_thread(control->pi.bucket, kgi_demuxer, 0); return 0; /* not reached */ }
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; }