Changeset 72cd53d in mainline for uspace/drv/vhc/conndev.c


Ignore:
Timestamp:
2011-05-17T07:18:11Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3375bd4
Parents:
50cd285 (diff), e913cc9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Small fixes and improvements

Fixed buffer overflow in lsusb.
lsusb scans all adresses, not only first ones.
Played with logging levels, now it is configurable.
VHC prints name of connected device and destroys pending transfers
when device is unplugged.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/vhc/conndev.c

    r50cd285 r72cd53d  
    3737#include <errno.h>
    3838#include <ddf/driver.h>
     39#include <usbvirt/ipc.h>
    3940#include "conn.h"
    4041
    4142static fibril_local uintptr_t plugged_device_handle = 0;
     43#define PLUGGED_DEVICE_NAME_MAXLEN 256
     44static fibril_local char plugged_device_name[PLUGGED_DEVICE_NAME_MAXLEN + 1] = "<unknown>";
     45
     46/** Receive device name.
     47 *
     48 * @warning Errors are silently ignored.
     49 *
     50 * @param phone Phone to the virtual device.
     51 */
     52static void receive_device_name(int phone)
     53{
     54        aid_t opening_request = async_send_0(phone, IPC_M_USBVIRT_GET_NAME, NULL);
     55        if (opening_request == 0) {
     56                return;
     57        }
     58
     59
     60        ipc_call_t data_request_call;
     61        aid_t data_request = async_data_read(phone,
     62             plugged_device_name, PLUGGED_DEVICE_NAME_MAXLEN,
     63             &data_request_call);
     64
     65        if (data_request == 0) {
     66                async_wait_for(opening_request, NULL);
     67                return;
     68        }
     69
     70        sysarg_t data_request_rc;
     71        sysarg_t opening_request_rc;
     72        async_wait_for(data_request, &data_request_rc);
     73        async_wait_for(opening_request, &opening_request_rc);
     74
     75        if ((data_request_rc != EOK) || (opening_request_rc != EOK)) {
     76                return;
     77        }
     78
     79        size_t len = IPC_GET_ARG2(data_request_call);
     80        plugged_device_name[len] = 0;
     81}
    4282
    4383/** Default handler for IPC methods not handled by DDF.
     
    65105                async_answer_0(icallid, EOK);
    66106
    67                 usb_log_info("New virtual device `%s' (id = %" PRIxn ").\n",
    68                     rc == EOK ? "XXX" : "<unknown>", plugged_device_handle);
     107                receive_device_name(callback);
     108
     109                usb_log_info("New virtual device `%s' (id: %" PRIxn ").\n",
     110                    plugged_device_name, plugged_device_handle);
    69111
    70112                return;
     
    85127
    86128        if (plugged_device_handle != 0) {
    87                 usb_log_info("Virtual device disconnected (id = %" PRIxn ").\n",
    88                     plugged_device_handle);
     129                usb_log_info("Virtual device `%s' disconnected (id: %" PRIxn ").\n",
     130                    plugged_device_name, plugged_device_handle);
    89131                vhc_virtdev_unplug(vhc, plugged_device_handle);
    90132        }
Note: See TracChangeset for help on using the changeset viewer.