mco_get_media_context

Retrieve the custom media context associated with a file-based device.

Prototype

    void *mco_get_media_context(
        /*IN*/ const mco_device_t *dev
    );

Arguments

dev
Pointer to a mco_device_t structure describing a storage device.

Description

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-NULL value only if:

The returned pointer may be either:

This mechanism enables embedded applications to pass platform-specific context (e.g., driver handles, global simulator instances, or hardware descriptors) without requiring global variables.

Return Value

void *
Pointer to the associated media context, or NULL if the device is not configured for custom media context usage.

Example

    // 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.
    }

Files

Header file:
mcodb.h
Source file:
mcoconn.c
Library:
libmcolib.a