Magellan Linux

Annotation of /trunk/usbip/patches/usbip-0.1.7-bind-parseable-output.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1540 - (hide annotations) (download)
Mon Sep 19 19:13:22 2011 UTC (12 years, 8 months ago) by niro
File size: 2283 byte(s)
-fixed patch
1 niro 1539 diff -Naur usbip-0.1.7/src/cmd/bind-driver.c usbip-0.1.7-magellan/src/cmd/bind-driver.c
2     --- usbip-0.1.7/src/cmd/bind-driver.c 2009-01-13 18:10:51.000000000 +0100
3 niro 1540 +++ usbip-0.1.7-magellan/src/cmd/bind-driver.c 2011-09-19 22:50:25.000000000 +0200
4 niro 1539 @@ -16,6 +16,7 @@
5     {"usbip", required_argument, NULL, 'u'},
6     {"other", required_argument, NULL, 'o'},
7     {"list", no_argument, NULL, 'l'},
8     + {"list2", no_argument, NULL, 'L'},
9     {"help", no_argument, NULL, 'h'},
10     #if 0
11     {"allusbip", no_argument, NULL, 'a'},
12 niro 1540 @@ -37,6 +38,7 @@
13     printf(" --usbip busid make a device exportable\n");
14     printf(" --other busid use a device by a local driver\n");
15     printf(" --list print usb devices and their drivers\n");
16     + printf(" --list2 print usb devices and their drivers in parseable mode\n");
17     printf(" --allusbip make all devices exportable\n");
18    
19     #if 0
20     @@ -378,6 +380,49 @@
21 niro 1539 return 0;
22     }
23    
24     +static int show_devices2(void)
25     +{
26     + DIR *dir;
27     +
28     + dir = opendir("/sys/bus/usb/devices/");
29     + if (!dir)
30     + g_error("opendir: %s", strerror(errno));
31     +
32     + for (;;) {
33     + struct dirent *dirent;
34     + char *busid;
35     +
36     + dirent = readdir(dir);
37     + if (!dirent)
38     + break;
39     +
40     + busid = dirent->d_name;
41     +
42     + if (is_usb_device(busid)) {
43     + char name[100] = {'\0'};
44     + char driver[100] = {'\0'};
45     + int conf, ninf = 0;
46     + int i;
47     +
48     + conf = read_bConfigurationValue(busid);
49     + ninf = read_bNumInterfaces(busid);
50     +
51     + getdevicename(busid, name, sizeof(name));
52     +
53     + printf("busid=%s#usbid=%s#", busid, name);
54     +
55     + for (i = 0; i < ninf; i++) {
56     + getdriver(busid, conf, i, driver, sizeof(driver));
57     + printf("%s:%d.%d=%s#", busid, conf, i, driver);
58     + }
59     + printf("\n");
60     + }
61     + }
62     +
63     + closedir(dir);
64     +
65     + return 0;
66     +}
67    
68     #if 0
69     static int export_to(char *host, char *busid) {
70 niro 1540 @@ -504,6 +549,7 @@
71     cmd_use_by_usbip,
72     cmd_use_by_other,
73     cmd_list,
74     + cmd_list2,
75     cmd_allusbip,
76     cmd_export_to,
77     cmd_unexport,
78     @@ -533,6 +579,9 @@
79 niro 1539 case 'l' :
80     cmd = cmd_list;
81     break;
82     + case 'L' :
83     + cmd = cmd_list2;
84     + break;
85     case 'a' :
86     cmd = cmd_allusbip;
87     break;
88 niro 1540 @@ -569,6 +618,9 @@
89 niro 1539 case cmd_list:
90     show_devices();
91     break;
92     + case cmd_list2:
93     + show_devices2();
94     + break;
95     #if 0
96     case cmd_allusbip:
97     allusbip();