Retrieve the custom media context associated with a file-based device.
void *mco_get_media_context(
/*IN*/ const mco_device_t *dev
);
dev
mco_device_t structure describing a storage device.This function extracts the user-defined media context from a device configured for custom I/O handling. It is primarily used internally by eXtremeDB to bind high-level file operations (e.g., in the xFile module) to low-level storage backends such as raw flash, block devices, or simulators.
The function returns a non-
NULLvalue only if:
- The device type is
MCO_MEMORY_FILE, and- The flag
MCO_FILE_OPEN_WITH_MEDIA_CTXis set indev->dev.file.flags.The returned pointer may be either:
- A direct pointer stored in
dev->dev.file.media_context, or- An offset-relative address (if
MCO_FILE_OPEN_CTX_OFFSis set), computed as(char*)dev + media_context.This mechanism enables embedded applications to pass platform-specific context (e.g., driver handles, global simulator instances, or hardware descriptors) without requiring global variables.
void *
NULL if the device is not configured for custom media context usage.
// Assume 'storage_dev' is a MCO_MEMORY_FILE device with media context
mco_device_t *media_dev = (mco_device_t *) mco_get_media_context(storage_dev);
if (media_dev) {
// Use media_dev to access flash simulator, block device, etc.
}