RFC: registry keys of serial ports

Christian Gmeiner christian.gmeiner at gmail.com
Fri Sep 11 05:30:01 CDT 2009


Hi Stefan,

I like the idea of adding more registry keys for hardware components.
I want some registry keys for usb devices
so I had a look at your patch. I don't like the mess with the added
goto serial. If in future there will be support
for usb and the whole source will be quite hard to follow. The usb
registry keys are needed e.g. for this [1].
So i like to propose my idea how it could look like.

In function new_device( LibHalContext *ctx, const char *udi ) we could
readout the info.subsystem setting of the newly added device and add a
if for info.subsystem strings like
block - block devices
tty - serial
usb_devices/usb - usb

could look like

/* HAL callback for new device */
static void new_device( LibHalContext *ctx, const char *udi )
{
    DBusError error;
    char *subsystem = NULL;

    p_dbus_error_init( &error );

    if (!(subsystem = p_libhal_device_get_property_string( ctx, udi,
"info.subsystem", &error )))
        goto done;

    if (strcmp(subsystem == "block") == 0)
        block_device( ctx, udi, &error );
    else if (strcmp(subsystem == "usb_device") == 0)
        usb_device( ctx, udi, &error );
    else if (strcmp(subsystem == "tty") == 0)
        serial_device( ctx, udi, &error );

    p_dbus_error_free( &error );
}

Now we have a ability to handle each device type with an own function, like

static void block_device( LibHalContext *ctx, const char *udi,
DBusError *error )
{
    char *device = NULL;
    char *mount_point = NULL;
    char *parent = NULL;
    char *uuid_str = NULL;
    char *type = NULL;
    GUID guid, *guid_ptr = NULL;
    enum device_type drive_type;

    if (!(device = p_libhal_device_get_property_string( ctx, udi,
"block.device", error )))
        goto done;

    if (!(mount_point = p_libhal_device_get_property_string( ctx, udi,
"volume.mount_point", error )))
        goto done;

    if (!(parent = p_libhal_device_get_property_string( ctx, udi,
"info.parent", error )))
        goto done;

    if (!(uuid_str = p_libhal_device_get_property_string( ctx, udi,
"volume.uuid", error )))
        p_dbus_error_free( &error );  /* ignore error */
    else
        guid_ptr = parse_uuid( &guid, uuid_str );

    if (!(type = p_libhal_device_get_property_string( ctx, parent,
"storage.drive_type", error )))
        p_dbus_error_free( &error );  /* ignore error */

    if (type && !strcmp( type, "cdrom" )) drive_type = DEVICE_CDROM;
    else if (type && !strcmp( type, "floppy" )) drive_type = DEVICE_FLOPPY;
    else drive_type = DEVICE_UNKNOWN;

    if (p_libhal_device_get_property_bool( ctx, parent,
"storage.removable", error ))
    {
        add_dos_device( -1, udi, device, mount_point, drive_type, guid_ptr );
        /* add property watch for mount point */
        p_libhal_device_add_property_watch( ctx, udi, error );
    }
    else if (guid_ptr) add_volume( udi, device, mount_point,
DEVICE_HARDDISK_VOL, guid_ptr );

done:
    if (type) p_libhal_free_string( type );
    if (parent) p_libhal_free_string( parent );
    if (device) p_libhal_free_string( device );
    if (uuid_str) p_libhal_free_string( uuid_str );
    if (mount_point) p_libhal_free_string( mount_point );
}

Keep in mind that i am not sure if this source samples compile - was a
quick copy & paste action.

What do you think about it?


[1] http://wiki.winehq.org/USB


-- 
Christian Gmeiner, B.Sc.

2009/9/11 Stefan Leichter <Stefan.Leichter at camline.com>:
> Hi,
>
> i like to know what modifikations the attached patch needs to go into git.
>
> More things need to be done in this area. I know of:
> - more registry keys [1]
> - remove the registry keys when a serial port disappears (USB)
> - the links in the dosdevice directory needs to be created
>
> Patches for the items above will be created, when the current patch went into
> git
>
> References:
> 1 http://www.winehq.org/pipermail/wine-patches/2009-April/071999.html
> - http://www.winehq.org/pipermail/wine-devel/2009-April/074476.html
>
> --
> Stefan
>
>
>
>



More information about the wine-devel mailing list