コード例 #1
0
bool AllocationManager_impl::deallocateLocal(const std::string& allocationID)
{
    ossie::AllocationTable::iterator alloc = this->_allocations.find(allocationID);
    if (alloc == this->_allocations.end()) {
        return false;
    }

    const ossie::AllocationType& localAlloc = alloc->second;
    std::vector<CF::Properties> allocations;
    partitionProperties(localAlloc.allocationProperties, allocations);
    LOG_TRACE(AllocationManager_impl, "Deallocating " << localAlloc.allocationProperties.length()
              << " properties (" << allocations.size() << " calls) for local allocation " << allocationID);
    if (!ossie::corba::objectExists(localAlloc.allocatedDevice)) {
        LOG_WARN(AllocationManager_impl, "Not deallocating capacity a device because it no longer exists");
    } else {
        bool warned = false;
        for (size_t index = 0; index < allocations.size(); ++index) {
            try {
                localAlloc.allocatedDevice->deallocateCapacity(allocations[index]);
            } catch (...) {
                if (!warned) {
                    // If a symmetric deallocateCapacity failes, the device is
                    // probably in a bad state; only warn about it once
                    LOG_WARN(AllocationManager_impl, "Deallocation raised an exception");
                    warned = true;
                }
            }
        }
    }
    this->_allocations.erase(alloc);
    return true;
}
コード例 #2
0
ファイル: task.cpp プロジェクト: aromis/zuluCrypt
void Task::runVolumeTask()
{
	/*
	  Root user can create encrypted volumes in all partitions including system partitions.
	  Show all partitions, not only non system.
	  */
	if( m_partitionType == QString( " -N" ) && getuid() == 0 ){
		m_partitionType = QString( " -A" ) ;
	}

	QString exe   = QString( ZULUCRYPTzuluCrypt ) + m_partitionType + QString( " -Z" ) ;
	QStringList l = utility::Task( exe ).splitOutput( '\n' ) ;
	QStringList list ;
	QString entry ;

	for( const auto& it : l ){
		list = utility::split( it,'\t' ) ;
		if( list.size() >= 4 ){
			entry = list.at( 3 ) ;
			/*
			 * MDRAID partitions have "linux_raid_member" as their file system
			 * LVM partitions have "LVM2_member" as their file system
			 *
			 * we are not showing these partitions since we dont support them
			 */
			if( !entry.contains( "member" ) ){
				emit partitionProperties( list ) ;
			}
		}
	}
}
コード例 #3
0
bool AllocationManager_impl::allocateDevice(const CF::Properties& requestedProperties, ossie::DeviceNode& node, CF::Properties& allocatedProperties, const std::vector<std::string>& processorDeps, const std::vector<ossie::SPD::NameVersionPair>& osDeps)
{
    if (!ossie::corba::objectExists(node.device)) {
        LOG_WARN(AllocationManager_impl, "Not using device for uses_device allocation " << node.identifier << " because it no longer exists");
        return false;
    }
    try {
        if (node.device->usageState() == CF::Device::BUSY) {
            return false;
        }
    } catch ( ... ) {
        // bad device reference or device in an unusable state
        LOG_WARN(AllocationManager_impl, "Unable to verify state of device " << node.identifier);
        return false;
    }

    LOG_TRACE(AllocationManager_impl, "Allocating against device " << node.identifier);

    // Determine whether or not the device in question has the required matching properties
    CF::Properties allocProps;
    if (!checkDeviceMatching(node.prf, allocProps, requestedProperties, processorDeps, osDeps)) {
        LOG_TRACE(AllocationManager_impl, "Matching failed");
        return false;
    }

    // If there are no external properties to allocate, the allocation is
    // already successful
    if (allocProps.length() == 0) {
        LOG_TRACE(AllocationManager_impl, "Allocation requires no capacity from device");
        return true;
    }

    // If there are duplicates in the allocation sequence, break up the allocation into multiple calls
    std::vector<CF::Properties> allocations;
    partitionProperties(allocProps, allocations);

    LOG_TRACE(AllocationManager_impl, "Allocating " << allocProps.length() << " properties ("
              << allocations.size() << " calls)");
    try {
        if (!this->completeAllocations(node.device, allocations)) {
            LOG_TRACE(AllocationManager_impl, "Device lacks sufficient capacity");
            return false;
        }
    } catch (const CF::Device::InvalidCapacity& e) {
        LOG_TRACE(AllocationManager_impl, "Device reported invalid capacity");
        return false;
    } catch (const CF::Device::InsufficientCapacity& e) {
        LOG_TRACE(AllocationManager_impl, "Device reported insufficient capacity");
        return false;
    }

    // Transfer ownership of the allocated properties to the caller
    ossie::corba::move(allocatedProperties, allocProps);
    LOG_TRACE(AllocationManager_impl, "Allocation successful");
    return true;
}