Exemple #1
0
bool 
Process::BuildYourselfFromYourValueSet(){

	int					temp;
	U32					ls;
	
	ManagedObject::BuildYourselfFromYourValueSet();

	GetInt( SSAPI_PROCESS_FID_CAN_START, &temp );
	m_canStart = temp? true : false;

	GetInt( SSAPI_PROCESS_FID_CAN_ABORT, &temp );
	m_canAbort = temp? true : false;

	GetInt( SSAPI_PROCESS_FID_CAN_PAUSE, &temp );
	m_canPause = temp? true : false;

	GetU32( SSAPI_PROCESS_FID_PERCENT_COMPLETE, &m_percentComplete );
	GetU32( SSAPI_PROCESS_FID_PRIORITY, &m_priority );
	GetInt64( SSAPI_PROCESS_FID_TIME_STARTED, &m_timeStarted );
	GetU32( SSAPI_PROCESS_FID_STATE, &m_state );

	if( GetU32( SSAPI_PROCESS_FID_NAME, &ls ) )
		m_name = ls;

	GetU32( SSAPI_PROCESS_FID_OWNER_MANAGER_CLASS_TYPE, &m_ownerManagerClassType );
	GetGenericValue( (char *)&m_ownerId, sizeof(m_ownerId), SSAPI_PROCESS_FID_OWNER_ID );

	return true;

}
void 
StorageIdInfo::BuildYourselfFromYourValueSet(){

	GetString( SSAPI_STORAGE_ID_INFO_FID_VENDOR, &m_vendor );
	GetString( SSAPI_STORAGE_ID_INFO_FID_PRODUCT, &m_product );
	GetString( SSAPI_STORAGE_ID_INFO_FID_REVISION, &m_revision );
	GetString( SSAPI_STORAGE_ID_INFO_FID_SERIAL_NUMBER, &m_serialNumber );
	GetString( SSAPI_STORAGE_ID_INFO_FID_WWNAME, &m_wwName );
	GetU32( SSAPI_STORAGE_ID_INFO_FID_TARGET_LUN, &m_targetLUN );
	GetU32( SSAPI_STORAGE_ID_INFO_FID_TARGET_ID, &m_targetId );
}
bool
SoftwareDescriptor::BuildYourselfFromYourValueSet(){

	int temp;

	ManagedObject::BuildYourselfFromYourValueSet();

	GetU32( SSAPI_IOP_SW_IMAGE_DESCRIPTOR_FID_MAJOR_VERSION, &m_majorVersion );
	GetU32( SSAPI_IOP_SW_IMAGE_DESCRIPTOR_FID_MINOR_VERSION, &m_minorVersion);
	GetU32( SSAPI_IOP_SW_IMAGE_DESCRIPTOR_FID_REFERENCE_COUNT, &m_referenceCount );
	GetInt64( SSAPI_IOP_SW_IMAGE_DESCRIPTOR_FID_LOADED_ON, &m_loadedOn );
	GetInt( SSAPI_IOP_SW_IMAGE_DESCRIPTOR_FID_IS_DEFAULT, &temp );
	m_isDefault = temp? true : false;

	return true;
}
	Dictionary::Dictionary(char const *filename) : mDefinition(null)
	{
		mFile = LoadFile("english.dictionary", &mFileSize);

		if(mFile != null)
		{
			uint8 const *p = mFile;
			uint8 const *bufferEnd = p + mFileSize;

			char const *id = (char const *)p;
			if(strncmp(id, "dictionary", 10) == 0)
			{
				p += 10;

				mVersion = GetU16(p);
				mNumWords = GetU32(p);

				mWord = (char *)p;
				p += mNumWords * 8;

				mDefinition = new char *[mNumWords];

				int wordIndex = 0;
				while(p < bufferEnd)
				{
					mDefinition[wordIndex] = (char *)p;

					uint16 definitionMask = GetU16(p);

					for(int i = 0; i < eWordType::kNumWordTypes; ++i)
					{
						if((definitionMask & (1 << i)) != 0)
						{
							if(*p++ == eReferenceType::kNone)
							{
								p += strlen((char *)p) + 1;
							}
							else
							{
								p += 3;
							}
						}
					}
					++wordIndex;
				}
			}
		}
		SaveAsJSON();
	}
bool 
StorageElementArray::BuildYourselfFromYourValueSet(){

	int temp;
	
	StorageElement::BuildYourselfFromYourValueSet();

	GetInt64( SSAPI_STORAGE_ELEMENT_ARRAY_FID_MEMBER_CAPACITY, &m_memberCapacity );
	GetInt64( SSAPI_STORAGE_ELEMENT_ARRAY_FID_DATA_BLOCK_SIZE, &m_dataBlockSize );
	GetInt64( SSAPI_STORAGE_ELEMENT_ARRAY_FID_PARITY_BLOCK_SIZE, &m_parityBlockSize );
	GetInt( SSAPI_STORAGE_ELEMENT_ARRAY_FID_PECKING_ORDER, (int *)&m_peckingOrder );

	GetInt( SSAPI_STORAGE_ELEMENT_ARRAY_FID_IS_INITED, &temp );
	m_isInited = temp? true : false;
	GetU32( SSAPI_STORAGE_ELEMENT_ARRAY_FID_SERIAL_NUMBER, &m_serialNumber );
	GetGenericValue( (char *)&m_hostSparePoolId, sizeof(m_hostSparePoolId), SSAPI_STORAGE_ELEMENT_ARRAY_FID_HOST_SPAREPOOL_ID ); 
	GetInt64( SSAPI_STORAGE_ELEMENT_ARRAY_FID_CREATION_TIME, &m_creationTime );

	return true;
}
Exemple #6
0
int MountFS(uint8_t *buffer, VolumeInfo *vinfo)
{
    uint8_t  sectorsPerCluster, numberOfFATs;
    uint16_t bytesPerSector, reservedSectorCount, rootEntryCount;
    uint32_t start, firstFATSector, firstRootDirectorySector, rootDirectorySectorCount;
    uint32_t firstDataSector, dataSectorCount, clusterCount, totalSectorCount, FATSize;
    uint32_t endOfClusterChain;
#ifdef FSDEBUG
    char *volumeLabel;
#endif
    int type;
       
    if (SD_ReadSector(0, buffer) != 0) {
        DPRINTF("SD_ReadSector 0 failed\n");
        return -1;
    }
    
    // check to see if there is a master boot record
    if (strncmp((char *)&buffer[BOOT_FILE_SYSTEM_TYPE], "FAT12", 5) != 0
    &&  strncmp((char *)&buffer[BOOT_FILE_SYSTEM_TYPE], "FAT16", 5) != 0
    &&  strncmp((char *)&buffer[BOOT_FILE_SYSTEM_TYPE_32], "FAT32", 5) != 0) {

        // get the first partition information
#ifdef FSDEBUG
        uint8_t status = buffer[MBR_PARTITIONS + PART_STATUS];
        uint32_t size = GetU32(buffer, MBR_PARTITIONS + PART_SECTOR_COUNT);
#endif
        start = GetU32(buffer, MBR_PARTITIONS + PART_FIRST_SECTOR);
#ifdef FSDEBUG
        DPRINTF("status: %02x, start: %08x, size %08x\n", status, start, size);
#endif            
        // get the boot sector of the first partition
        if (SD_ReadSector(start, buffer) != 0) {
            DPRINTF("SD_ReadSector %d failed\n", start);
            return -1;
        }
    }
    
    // no master boot record
    else
        start = 0;
    
    bytesPerSector = GetU16(buffer, BOOT_BYTES_PER_SECTOR);
    sectorsPerCluster = buffer[BOOT_SECTORS_PER_CLUSTER];
    reservedSectorCount = GetU16(buffer, BOOT_RESERVED_SECTOR_COUNT);
    numberOfFATs = buffer[BOOT_NUMBER_OF_FATS];
    rootEntryCount = GetU16(buffer, BOOT_ROOT_ENTRY_COUNT);
    if ((totalSectorCount = GetU16(buffer, BOOT_TOTAL_SECTOR_COUNT)) == 0)
        totalSectorCount = GetU32(buffer, BOOT_TOTAL_SECTOR_COUNT_32);
    if ((FATSize = GetU16(buffer, BOOT_FAT_SIZE)) == 0)
        FATSize = GetU32(buffer, BOOT_FAT_SIZE_32);
    firstFATSector = start + reservedSectorCount;
    firstRootDirectorySector = firstFATSector + numberOfFATs * FATSize; // recomputed for FAT32 later
    rootDirectorySectorCount = (rootEntryCount * ENTRY_SIZE + bytesPerSector - 1) / bytesPerSector;
    firstDataSector = firstRootDirectorySector + rootDirectorySectorCount;
    dataSectorCount = totalSectorCount - reservedSectorCount - numberOfFATs * FATSize - rootDirectorySectorCount;
    clusterCount = dataSectorCount / sectorsPerCluster;
    
    // these magic numbers come from a Microsoft paper on the FAT32 File System
    if (clusterCount < 4085) {
        type = TYPE_FAT12;
        endOfClusterChain = 0x00000ff8;
    }
    else if (clusterCount < 65525) {
        type = TYPE_FAT16;
        endOfClusterChain = 0x0000fff8;
    }
    else {
        type = TYPE_FAT32;
        endOfClusterChain = 0xfffffff8;
    }
        
    switch (type) {
    case TYPE_FAT12:
    case TYPE_FAT16:
#ifdef FSDEBUG
        volumeLabel = (char *)&buffer[BOOT_VOLUME_LABEL];
#endif
        vinfo->rootDirectoryCluster = 0;
        break;
    case TYPE_FAT32:
#ifdef FSDEBUG
        volumeLabel = (char *)&buffer[BOOT_VOLUME_LABEL_32];
#endif
        vinfo->rootDirectoryCluster = GetU32(buffer, BOOT_ROOT_CLUSTER_32);
        firstRootDirectorySector = firstDataSector + (vinfo->rootDirectoryCluster - 2) * sectorsPerCluster;
        rootDirectorySectorCount = sectorsPerCluster;
        break;
    }
    
    vinfo->type = type;
    vinfo->bytesPerSector = bytesPerSector;
    vinfo->sectorsPerCluster = sectorsPerCluster;
    vinfo->firstRootDirectorySector = firstRootDirectorySector;
    vinfo->rootDirectorySectorCount = rootDirectorySectorCount;
    vinfo->rootEntryCount = rootEntryCount;
    vinfo->firstFATSector = firstFATSector;
    vinfo->firstDataSector = firstDataSector;
    vinfo->clusterCount = clusterCount;
    vinfo->endOfClusterChain = endOfClusterChain;
    
#ifdef FSDEBUG
    DPRINTF("label:                    %-11.11s\n", volumeLabel);
    DPRINTF("type:                     ");
    switch (type) {
    case TYPE_FAT12:
        DPRINTF("FAT12\n");
        break;
    case TYPE_FAT16:
        DPRINTF("FAT16\n");
        break;
    case TYPE_FAT32:
        DPRINTF("FAT32\n");
        break;
    default:
        DPRINTF("UNKNOWN\n");
        break;
    }
    DPRINTF("bytesPerSector:           %d\n", bytesPerSector);
    DPRINTF("sectorsPerCluster:        %d\n", sectorsPerCluster);
    DPRINTF("reservedSectorCount:      %d\n", reservedSectorCount);
    DPRINTF("numberOfFATs:             %d\n", numberOfFATs);
    DPRINTF("rootEntryCount:           %d\n", rootEntryCount);
    DPRINTF("totalSectorCount:         %d\n", totalSectorCount);
    DPRINTF("FATSize:                  %d\n", FATSize);
    DPRINTF("firstRootDirectorySector: %d\n", firstRootDirectorySector);
    DPRINTF("rootDirectorySectorCount: %d\n", rootDirectorySectorCount);
    DPRINTF("firstFATSector:           %d\n", firstFATSector);
    DPRINTF("firstDataSector:          %d\n", firstDataSector);
    DPRINTF("dataSectorCount:          %d\n", dataSectorCount);
    DPRINTF("clusterCount:             %d\n", clusterCount);
#endif
    
    return 0;
}
Exemple #7
0
int FindFile(uint8_t *buffer, VolumeInfo *vinfo, const char *name, FileInfo *finfo)
{
    uint32_t cluster, sector, count;
    int i, j;
    
    // start with the first root directory sector
    cluster = vinfo->rootDirectoryCluster;
    sector = vinfo->firstRootDirectorySector;
    count = vinfo->rootDirectorySectorCount;
    
    // loop through all directory clusters
    for (;;) {
    
        // loop through each sector of the current cluster
        for (j = 0; j < count; ++j) {
        
            // get the next sector in this cluster
            if (SD_ReadSector(sector + j, buffer) != 0) {
                DPRINTF("SD_ReadSector %d failed\n", sector + j);
                return -1;
            }

            // find a file in this directory sector
            for (i = 0; i < SECTOR_SIZE; i += ENTRY_SIZE) {
                uint8_t flag = buffer[i + ENTRY_NAME];
                uint32_t firstCluster;
                uint8_t attr;
                switch (flag) {
                case 0xe5:
                case 0x00:
                    break;
                default:
                    attr = buffer[i + ENTRY_ATTRIBUTES];
                    firstCluster = (GetU16(buffer, i + ENTRY_CLUSTER_HIGH) << 16) | GetU16(buffer, i + ENTRY_CLUSTER_LOW);
                    if ((attr & ATTR_LONG_NAME_MASK) != ATTR_LONG_NAME
                    && !(attr & ATTR_HIDDEN)
                    && !(attr & ATTR_VOLUME_ID)) {
                        if (strncmp(name, (char *)&buffer[i + ENTRY_NAME], NAME_SIZE) == 0) {
                            finfo->vinfo = vinfo;
                            finfo->cluster = firstCluster;
                            finfo->sector = vinfo->firstDataSector + (firstCluster - 2) * vinfo->sectorsPerCluster;
                            finfo->sectorsRemainingInCluster = vinfo->sectorsPerCluster;
                            finfo->bytesRemaining = GetU32(buffer, i + ENTRY_FILESIZE);
                            return 0;
                        }
                    }
                    break;
                }
                
                // check for the end of the directory
                if (flag == 0x00)
                    return -1;
            }
        }
        
        // move ahead to the next cluster
        if (!cluster)
            break;
            
        // get the next cluster number
        if (GetFATEntry(vinfo, buffer, cluster, &cluster) != 0)
            return -1;
            
        // check for the end of the cluster chain
        if (cluster < 2)
            break;
            
        // setup to process the next cluster
        sector = vinfo->firstDataSector + (cluster - 2) * vinfo->sectorsPerCluster;
        count = vinfo->sectorsPerCluster;
    }
    
    return -1;
}
	_U32 CConstObject::GetU32(const char* name, _U32 index) const
	{
		return GetU32(Zion::StringFormat("%s[%d]", name, index).c_str());
	}
	static inline uint32 GetU32(uint8 const * &d)
	{
		return GetU32((char const * &)d);
	}
Exemple #10
0
uint32_t utils::GetU32c(char *str,int &pos){
       uint32_t r = GetU32(str,pos);
       pos += 4;
       return r;
}