Example #1
0
/*1st step zrt initializer*/
void zrt_internal_init( const struct UserManifest const* manifest ){
    ITEMS_CREATOR;

    /*construct memory manager and pass zerovm MANIFEST members:
      (1)heap start address, (2)heap size, (3)existing brk address got
      from zcalls_prolog interface*/
    CONSTRUCT_L(MEMORY_MANAGER) ( manifest->heap_ptr, 
				  manifest->heap_size, 
				  static_prolog_brk() );

    /*manage mounted filesystems*/
    s_mounts_manager = get_mounts_manager();

    /*alloc filesystem based on channels*/
    struct ChannelsModeUpdaterPublicInterface *nvram_mode_setting_updater;

    s_channels_mount = 
	CONSTRUCT_L(CHANNELS_FILESYSTEM)( &nvram_mode_setting_updater,
					  s_mounts_manager->handle_allocator,
					  manifest->channels, 
					  manifest->channels_count,
					  s_emu_channels, 
					  sizeof(s_emu_channels)/sizeof(struct ZVMChannel));
    set_mapping_channels_settings_updater( nvram_mode_setting_updater ); 

    /*alloc main filesystem that combines all filesystems mounts*/
    s_transparent_mount = alloc_transparent_mount( s_mounts_manager );

    s_zrt_ready = 1;

    /*open standard files to conform C*/
    s_channels_mount->open( s_channels_mount, DEV_STDIN, O_RDONLY, 0 );
    s_channels_mount->open( s_channels_mount, DEV_STDOUT, O_WRONLY, 0 );
    s_channels_mount->open( s_channels_mount, DEV_STDERR, O_WRONLY, 0 );

    /*create mem mount*/
    s_mem_mount = CONSTRUCT_L(INMEMORY_FILESYSTEM)( s_mounts_manager->handle_allocator );

    /*Mount filesystems*/
    s_mounts_manager->mount_add( "/dev", s_channels_mount );
    s_mounts_manager->mount_add( "/", s_mem_mount );

    /*explicitly create /dev directory in memmount, it's required for consistent
      FS structure, readdir from now can list /dev dir recursively from root */
    s_mem_mount->mkdir( s_mem_mount, "/dev", 0777 );
    /*add directories here that can be expected by some user applications */
    s_mem_mount->mkdir( s_mem_mount, "/tmp", 0777 );

    /*user main execution just after zrt initialization*/
}
Example #2
0
int mm_fusemount_add( struct MountsManager *mounts_manager,
                      const char* path, 
                      struct fuse_operations* fuse_mount,
                      char expect_absolute_path,
                      char proxy_mode){
    struct MountsPublicInterface* fs 
	= CONSTRUCT_L(FUSE_OPERATIONS_MOUNT)( get_handle_allocator(),
					      get_open_files_pool(),
					      fuse_mount,
                                              proxy_mode);
    return mm_mount_add( mounts_manager, path, fs, expect_absolute_path );
}