Exemple #1
0
	void LoadPlugins()
	{
		if( m_bPluginsLoaded )
			return;
			
		
		String zFileName;
		String zPath = String( "/boot/System/extensions/media" );

		/* Open all media plugins in /system/media */
		Directory *pcDirectory = new Directory();
		if( pcDirectory->SetTo( zPath ) != 0 )
			return;

		std::cout<<"Start plugin scan.."<<std::endl;
		m_nPlugins.clear();

		while( pcDirectory->GetNextEntry( &zFileName ) )
		{
			/* Load image */
			if( zFileName == "." || zFileName == ".." )
				continue;
			zFileName = zPath + String( "/" ) + zFileName;
			
			/* Check category attribute. We load audio drivers later */
			char zCategory[256];
			memset( zCategory, 0, 256 );
			os::FSNode cNode( zFileName );
			if( cNode.ReadAttr( "os::Category", ATTR_TYPE_STRING, zCategory, 0, 255 ) > 0 )
			{
				if( os::String( zCategory ) == "AudioDriver" )
					continue;
			}

			image_id nID = load_library( zFileName.c_str(), 0 );
			if( nID >= 0 ) {
				init_media_addon *pInit;
				/* Call init_media_addon() */
				if( get_symbol_address( nID, "init_media_addon",
				-1, (void**)&pInit ) == 0 ) {
					MediaAddon* pcAddon = pInit( "" );
					if( pcAddon ) {
						if( pcAddon->GetAPIVersion() != MEDIA_ADDON_API_VERSION )
						{
							std::cout<<zFileName.c_str()<<" has wrong api version"<<std::endl;
						}
						else if( pcAddon->Initialize() != 0 )
						{
							std::cout<<pcAddon->GetIdentifier().c_str()<<" failed to initialize"<<std::endl;
						} else {
							std::cout<<pcAddon->GetIdentifier().c_str()<<" initialized"<<std::endl;
							m_nPlugins.push_back( MediaPlugin( nID, pcAddon ) );
						}
					}
				} else {
					std::cout<<zFileName.c_str()<<" does not export init_media_addon()"<<std::endl;
				}
			}
		}
		m_bPluginsLoaded = true;
		
		/* Load audio drivers */
		
		zPath = String( "/dev/audio" );
		if( pcDirectory->SetTo( zPath ) != 0 )
			return;
		while( pcDirectory->GetNextEntry( &zFileName ) )
		{
			if( zFileName == "." || zFileName == ".." )
				continue;
			zPath = String( "/dev/audio" );
			os::String zDevFileName = zPath + String( "/" ) + zFileName;
			
			/* Get userspace driver name */
			char zDriverPath[PATH_MAX];
			memset( zDriverPath, 0, PATH_MAX );
			int nFd = open( zDevFileName.c_str(), O_RDONLY );
			if( nFd < 0 )
				continue;
			if( ioctl( nFd, IOCTL_GET_USERSPACE_DRIVER, zDriverPath ) != 0 )
			{
				close( nFd );
				continue;
			}
			close( nFd );
			
		
			/* Construct plugin path */
			zPath = String( "/boot/System/extensions/media" );
			zFileName = zPath + String( "/" ) + zDriverPath;
			
			image_id nID = load_library( zFileName.c_str(), 0 );
			if( nID >= 0 ) {
				init_media_addon *pInit;
				/* Call init_media_addon() */
				if( get_symbol_address( nID, "init_media_addon",
				-1, (void**)&pInit ) == 0 ) {
					MediaAddon* pcAddon = pInit( zDevFileName );
					if( pcAddon ) {
						if( pcAddon->GetAPIVersion() != MEDIA_ADDON_API_VERSION )
						{
							std::cout<<zFileName.c_str()<<" has wrong api version"<<std::endl;
						}
						else if( pcAddon->Initialize() != 0 )
						{
							std::cout<<pcAddon->GetIdentifier().c_str()<<" failed to initialize"<<std::endl;
						} else {
							std::cout<<pcAddon->GetIdentifier().c_str()<<" initialized"<<std::endl;
							m_nPlugins.push_back( MediaPlugin( nID, pcAddon ) );
						}
					}
				} else {
					std::cout<<zFileName.c_str()<<" does not export init_media_addon()"<<std::endl;
				}
			}
		}		
		

		std::cout<<"Plugin scan finished"<<std::endl;
	}
Exemple #2
0
status_t
mount_file_systems(stage2_args *args)
{
	// mount other partitions on boot device (if any)
	NodeIterator iterator = gPartitions.GetIterator();

	Partition *partition = NULL;
	while ((partition = (Partition *)iterator.Next()) != NULL) {
		// don't scan known partitions again
		if (partition->IsFileSystem())
			continue;

		// remove the partition if it doesn't contain a (known) file system
		if (partition->Scan(true) != B_OK && !partition->IsFileSystem()) {
			gPartitions.Remove(partition);
			delete partition;
		}
	}

	// add all block devices the platform has for us

	status_t status = platform_add_block_devices(args, &gBootDevices);
	if (status < B_OK)
		return status;

	iterator = gBootDevices.GetIterator();
	Node *device = NULL, *last = NULL;
	while ((device = iterator.Next()) != NULL) {
		// don't scan former boot device again
		if (device == sBootDevice)
			continue;

		if (add_partitions_for(device, true) == B_OK) {
			// ToDo: we can't delete the object here, because it must
			//	be removed from the list before we know that it was
			//	deleted.

/*			// if the Release() deletes the object, we need to skip it
			if (device->Release() > 0) {
				list_remove_item(&gBootDevices, device);
				device = last;
			}
*/
(void)last;
		}
		last = device;
	}

	if (gPartitions.IsEmpty())
		return B_ENTRY_NOT_FOUND;

#if 0
	void *cookie;
	if (gRoot->Open(&cookie, O_RDONLY) == B_OK) {
		Directory *directory;
		while (gRoot->GetNextNode(cookie, (Node **)&directory) == B_OK) {
			char name[256];
			if (directory->GetName(name, sizeof(name)) == B_OK)
				printf(":: %s (%p)\n", name, directory);

			void *subCookie;
			if (directory->Open(&subCookie, O_RDONLY) == B_OK) {
				while (directory->GetNextEntry(subCookie, name, sizeof(name)) == B_OK) {
					printf("\t%s\n", name);
				}
				directory->Close(subCookie);
			}
		}
		gRoot->Close(cookie);
	}
#endif

	return B_OK;
}
Exemple #3
0
int
main(int argc,char **argv)
{
	puts("Copyright (c) 2001-2008 pinc Software.");

	char *toolName = argv[0];
	if (argc < 2 || !strcmp(argv[1],"--help"))
	{
		printUsage(toolName);
		return -1;
	}

	while (*++argv)
	{
		char *arg = *argv;
		if (*arg == '-')
		{
			while (*++arg && isalpha(*arg))
			{
				switch (*arg)
				{
					case 'i':
						gDoNotCheckIndex = true;
						break;
					case 'f':
						gDoNotCheckForFiles = true;
						break;
					case 'a':
						gCheckAll = true;
						break;
				}
			}
		}
		else
			break;
	}

	char *attribute = argv[0];
	if (!gCheckAll && attribute == NULL)
	{
		printUsage(toolName);
		return -1;
	}

	dev_t device = dev_for_path(".");
	if (device < B_OK)
	{
		fprintf(stderr,"Could not find device for current location: %s\n",strerror(device));
		return -1;
	}

	fs_info info;
	if (fs_stat_dev(device,&info) < B_OK)
	{
		fprintf(stderr,"Could not get stats for device: %s\n",strerror(errno));
		return -1;
	}

	Disk disk(info.device_name);
	status_t status;
	if ((status = disk.InitCheck()) < B_OK)
	{
		fprintf(stderr,"Could not open device or file \"%s\": %s\n",info.device_name,strerror(status));
		return -1;
	}

	if (disk.ValidateSuperBlock() < B_OK)
	{
		fprintf(stderr,"The disk's superblock is corrupt!\n");
		return -1;
	}

	Directory *indices = (Directory *)Inode::Factory(&disk,disk.Indices());
	if (indices == NULL || (status = indices->InitCheck()) < B_OK)
	{
		fprintf(stderr,"  Could not get indices directory: %s!\n",indices ? strerror(status) : "not found/corrupted");
		delete indices;
		return -1;
	}
	BPlusTree *tree;
	if (indices->GetTree(&tree) < B_OK || tree->Validate() < B_OK)
	{
		fprintf(stderr,"  Indices B+Tree seems to be corrupt!\n");
		delete indices;
		return -1;
	}

	block_run run;

	if (gCheckAll)
	{
		putchar('\n');
		collectFiles(disk);

		char name[B_FILE_NAME_LENGTH];
		while (indices->GetNextEntry(name,&run) >= B_OK)
			checkIndex(disk,name,run,false);
	}
	else if (indices->FindEntry(attribute,&run) == B_OK)
		checkIndex(disk,attribute,run,true);
	else
		fprintf(stderr,"  Could not find index directory for \"%s\"!\n",attribute);

	delete indices;

	gHashtable.MakeEmpty(HASH_EMPTY_NONE,HASH_EMPTY_FREE);

	return 0;
}