static PP_Bool Instance_DidCreate(PP_Instance instance, uint32_t argc, const char* argn[], const char* argv[]) { g_instance = instance; nacl_io_init_ppapi(instance, get_browser_interface); umount("/"); mount("", "/", "memfs", 0, ""); mount("", "/persistent", "html5fs", 0, "type=PERSISTENT,expected_size=1048576"); mount("", "/http", "httpfs", 0, ""); pthread_create(&g_handle_message_thread, NULL, &HandleMessageThread, NULL); InitializeMessageQueue(); return PP_TRUE; }
static PP_Bool Instance_DidCreate(PP_Instance instance, uint32_t argc, const char* argn[], const char* argv[]) { g_instance = instance; nacl_io_init_ppapi(instance, get_browser_interface); // By default, nacl_io mounts / to pass through to the original NaCl // filesystem (which doesn't do much). Let's remount it to a memfs // filesystem. umount("/"); mount("", "/", "memfs", 0, ""); mount("", /* source */ "/persistent", /* target */ "html5fs", /* filesystemtype */ 0, /* mountflags */ "type=PERSISTENT,expected_size=1048576"); /* data */ mount("", /* source. Use relative URL */ "/http", /* target */ "httpfs", /* filesystemtype */ 0, /* mountflags */ ""); /* data */ pthread_create(&g_handle_message_thread, NULL, &HandleMessageThread, NULL); InitializeMessageQueue(); return PP_TRUE; }
static PP_Bool Instance_DidCreate(PP_Instance instance,uint32_t argc,const char* argn[],const char* argv[]) { int nacl_io_init_ppapi(PP_Instance instance, PPB_GetInterface get_interface); static pthread_t g_handle_message_thread; static pthread_t iguana_thread; int64_t allocsize; g_instance = instance; // By default, nacl_io mounts / to pass through to the original NaCl // filesystem (which doesn't do much). Let's remount it to a memfs // filesystem. InitializeMessageQueue(); pthread_create(&g_handle_message_thread, NULL, &HandleMessageThread, NULL); pthread_create(&iguana_thread,NULL,&iguana,iguana_filestr(&allocsize,"iguana.conf")); nacl_io_init_ppapi(instance,g_get_browser_interface); umount("/"); mount("", "/memfs", "memfs", 0, ""); mount("", /* source */ "/", /* target */ "html5fs", /* filesystemtype */ 0, /* mountflags */ "type=PERSISTENT,expected_size=10000000000"); /* data */ mount("", /* source. Use relative URL */ "/http", /* target */ "httpfs", /* filesystemtype */ 0, /* mountflags */ ""); /* data */ PostMessage("finished DidCreate\n"); return PP_TRUE; }
void init_fs(MS_AppInstance* inst, const std::vector<std::string>& persistent_dirs) { nacl_io_init_ppapi(inst->pp_instance(), pp::Module::Get()->get_browser_interface()); umount("/"); mount("", "/", "memfs", 0, ""); #if defined(MUTANTSPIDER_HAS_RESOURCES) nacl_io_register_fs_type("rez_fs", &rezfs_ops); mount("", "/resources", "rez_fs", 0, ""); #endif if (persistent_dirs.empty()) { inst->AsyncStartupComplete(); inst->PostCommand("async_startup_complete:"); } else { nacl_io_register_fs_type("persist_backed_mem_fs", &pbmemfs_ops); mount("", html5_shadow_name.c_str(), "html5fs", 0, "type=PERSISTENT,expected_size=1048576"); #if defined(_do_clear_) std::thread(clear_all).detach(); return; #endif mount("", persistent_name.c_str(), "persist_backed_mem_fs", 0, ""); std::thread(std::bind(populate_memfs,inst,persistent_dirs)).detach(); } }
// Initialize the module, staring a worker thread to load the shared object. virtual bool Init(uint32_t argc, const char* argn[], const char* argv[]) { nacl_io_init_ppapi( pp_instance(), pp::Module::Get()->get_browser_interface()); // printf( "Constructor thread id '%p'\n", pthread_self()); // printf( "createFS thread id '%p'\n", pthread_self()); umount("/"); int res = mount("", "/", "memfs", 0, ""); // int res = mount("", "/web", "httpfs", 0, ""); if (res) { // std::cout << "unable to mount httpfs file system!" << std::endl; bCreatedFS_ = true; return false; } // std::cout << "mount res: " << res << std::endl; if (pthread_create( &message_thread_, NULL, &LASzipInstance::HandleMessageThread, this)) { PostError("Init", "Unable to initialize thread!", "null"); return false; } InitializeMessageQueue(); return true; }
DiagrammarInterface::DiagrammarInterface(PP_Instance instance, pp::Module* module) : pp::Instance(instance) { // initialize the file system nacl_io_init_ppapi(instance, pp::Module::Get()->get_browser_interface()); umount("/"); mount("", "/http", "httpfs", 0, ""); }
int nacl_main(int argc, char *argv[]) { int status; PSEvent* ps_event; PP_Resource event; struct PP_Rect rect; int ready = 0; const PPB_View *ppb_view = PSInterfaceView(); /* This is started in a worker thread by ppapi_simple! */ /* Wait for the first PSE_INSTANCE_DIDCHANGEVIEW event before starting the app */ PSEventSetFilter(PSE_INSTANCE_DIDCHANGEVIEW); while (!ready) { /* Process all waiting events without blocking */ while (!ready && (ps_event = PSEventWaitAcquire()) != NULL) { event = ps_event->as_resource; switch(ps_event->type) { /* From DidChangeView, contains a view resource */ case PSE_INSTANCE_DIDCHANGEVIEW: ppb_view->GetRect(event, &rect); NACL_SetScreenResolution(rect.size.width, rect.size.height, 0); ready = 1; break; default: break; } PSEventRelease(ps_event); } } /* Do a default httpfs mount on /, * apps can override this by unmounting / * and remounting with the desired configuration */ nacl_io_init_ppapi(PSGetInstanceId(), PSGetInterface); umount("/"); mount( "", /* source */ "/", /* target */ "httpfs", /* filesystemtype */ 0, /* mountflags */ ""); /* data specific to the html5fs type */ /* Everything is ready, start the user main function */ SDL_SetMainReady(); status = SDL_main(argc, argv); return 0; }
void init_fs() { nacl_io_init_ppapi(gGlobalPPInstance->pp_instance(), pp::Module::Get()->get_browser_interface()); umount("/"); mount("", "/", "memfs", 0, ""); #if defined(MS_HAS_RESOURCES) nacl_io_register_fs_type("rez_fs", &rezfs_ops); mount("", "/resources", "rez_fs", 0, ""); #endif }
explicit MoonlightInstance(PP_Instance instance) : pp::Instance(instance), pp::MouseLock(this), m_IsPainting(false), m_OpusDecoder(NULL), m_CallbackFactory(this), m_MouseLocked(false), m_KeyModifiers(0), m_WaitingForAllModifiersUp(false) { // This function MUST be used otherwise sockets don't work (nacl_io_init() doesn't work!) nacl_io_init_ppapi(pp_instance(), pp::Module::Get()->get_browser_interface()); m_GamepadApi = static_cast<const PPB_Gamepad*>(pp::Module::Get()->GetBrowserInterface(PPB_GAMEPAD_INTERFACE)); }
explicit HelloWorldInstance(PP_Instance instance) : pp::Instance(instance), callback_factory_(this) { rei_instance = this; printf("Reicast NACL loaded\n"); nacl_io_init_ppapi(instance, pp::Module::Get()->get_browser_interface()); umount("/"); mount("", "/", "memfs", 0, ""); mount("", /* source. Use relative URL */ "/http", /* target */ "httpfs", /* filesystemtype */ 0, /* mountflags */ ""); /* data */ pthread_create(&emut, NULL, emuthread, 0); }
static PP_Bool Instance_DidCreate(PP_Instance instance, uint32_t argc, const char* argn[], const char* argv[]) { g_instance = instance; nacl_io_init_ppapi(instance, g_get_browser_interface); // By default, nacl_io mounts / to pass through to the original NaCl // filesystem (which doesn't do much). Let's remount it to a memfs // filesystem. umount("/"); mount("", "/", "memfs", 0, ""); mount("", "/temporary", "html5fs", 0, "type=TEMPORARY,expected_size=5242880"); pthread_create(&g_handle_message_thread, NULL, &HandleMessageThread, NULL); return PP_TRUE; }
virtual bool Init(uint32_t argc, const char* arg_n[], const char* argv[]) { // Create file system to hold the binaries that will be loaded into the // emulator nacl_io_init_ppapi(pp_instance(), pp::Module::Get()->get_browser_interface()); umount("/"); mount("", "/", "memfs", 0, ""); mount("bin", "/bin", "httpfs", 0, ""); // Init the main emulator objects cpu = new CPU(this); // Create thread to load boot images if (pthread_create(&tid, NULL, LoadResourcesAndStart, this)) { fprintf(stderr, "ERROR: OREmulatorInstance.Init() failed to create pthread"); return false; } return true; }
explicit MoonlightInstance(PP_Instance instance) : pp::Instance(instance), pp::MouseLock(this), m_IsPainting(false), m_RequestIdrFrame(false), m_OpusDecoder(NULL), m_CallbackFactory(this), m_MouseLocked(false), m_KeyModifiers(0), m_WaitingForAllModifiersUp(false), m_AccumulatedTicks(0), openHttpThread(this) { // This function MUST be used otherwise sockets don't work (nacl_io_init() doesn't work!) nacl_io_init_ppapi(pp_instance(), pp::Module::Get()->get_browser_interface()); LiInitializeStreamConfiguration(&m_StreamConfig); pp::TextInputController(this).SetTextInputType(PP_TEXTINPUT_TYPE_NONE); m_GamepadApi = static_cast<const PPB_Gamepad*>(pp::Module::Get()->GetBrowserInterface(PPB_GAMEPAD_INTERFACE)); openHttpThread.Start(); }
int ProcessProperties(void) { /* Reset verbosity if passed in */ const char* verbosity = getenv("PS_VERBOSITY"); if (verbosity) PSInstanceSetVerbosity(atoi(verbosity)); /* Enable NaCl IO to map STDIN, STDOUT, and STDERR */ nacl_io_init_ppapi(PSGetInstanceId(), PSGetInterface); s_tty_prefix = getenv("PS_TTY_PREFIX"); if (s_tty_prefix) { s_tty_fd = open("/dev/tty", O_WRONLY); if (s_tty_fd >= 0) { PSEventRegisterMessageHandler(s_tty_prefix, MessageHandlerInput, NULL); const char* tty_resize = getenv("PS_TTY_RESIZE"); if (tty_resize) PSEventRegisterMessageHandler(tty_resize, MessageHandlerResize, NULL); char* tty_rows = getenv("PS_TTY_ROWS"); char* tty_cols = getenv("PS_TTY_COLS"); if (tty_rows && tty_cols) { char* end = tty_rows; int rows = strtol(tty_rows, &end, 10); if (*end != '\0' || rows < 0) { PSInstanceError("Invalid value for PS_TTY_ROWS: %s\n", tty_rows); } else { end = tty_cols; int cols = strtol(tty_cols, &end, 10); if (*end != '\0' || cols < 0) PSInstanceError("Invalid value for PS_TTY_COLS: %s\n", tty_cols); else HandleResize(cols, rows); } } else if (tty_rows || tty_cols) { PSInstanceError("PS_TTY_ROWS and PS_TTY_COLS must be set together\n"); } struct tioc_nacl_output handler; handler.handler = TtyOutputHandler; handler.user_data = NULL; ioctl(s_tty_fd, TIOCNACLOUTPUT, &handler); } else { PSInstanceError("Failed to open /dev/tty.\n"); } } /* Set default values */ setenv("PS_STDIN", "/dev/stdin", 0); setenv("PS_STDOUT", "/dev/stdout", 0); setenv("PS_STDERR", "/dev/console3", 0); int fd0 = open(getenv("PS_STDIN"), O_RDONLY); dup2(fd0, 0); int fd1 = open(getenv("PS_STDOUT"), O_WRONLY); dup2(fd1, 1); int fd2 = open(getenv("PS_STDERR"), O_WRONLY); dup2(fd2, 2); PSEventRegisterMessageHandler("jspipe1", MessageHandlerInput, NULL); PSEventRegisterMessageHandler("jspipe2", MessageHandlerInput, NULL); PSEventRegisterMessageHandler("jspipe3", MessageHandlerInput, NULL); s_exit_message = getenv("PS_EXIT_MESSAGE"); /* If PS_EXIT_MESSAGE is set in the environment then we perform a handshake * with JavaScript when program exits. */ if (s_exit_message != NULL) nacl_io_set_exit_callback(ExitHandshake, NULL); /* Set line buffering on stdout and stderr */ #if !defined(WIN32) setvbuf(stderr, NULL, _IOLBF, 0); setvbuf(stdout, NULL, _IOLBF, 0); #endif return 1; }