1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
$NetBSD: patch-ab,v 1.3 2001/06/15 16:36:51 drochner Exp $
--- freebsd.c.orig Tue Oct 10 00:08:22 2000
+++ freebsd.c Fri Jun 15 18:07:19 2001
@@ -41,16 +41,18 @@
{
int i;
struct freebsd_usb_dev_handle_info *info;
+ char ctlpath[PATH_MAX];
info = malloc(sizeof(*info));
if (!info)
USB_ERROR(-ENOMEM);
dev->impl_info = info;
- dev->fd = open(dev->device->filename, O_RDWR);
+ snprintf(ctlpath, PATH_MAX, "%s.00", dev->device->filename);
+ dev->fd = open(ctlpath, O_RDWR);
if (dev->fd < 0)
{
- dev->fd = open(dev->device->filename, O_RDONLY);
+ dev->fd = open(ctlpath, O_RDONLY);
if (dev->fd < 0)
{
free(info);
@@ -152,10 +154,10 @@
if(info->ep_fd[ep] < 0)
{
- sprintf(buf, "%s.%d", dev->device->filename, ep);
- fd = open(buf, O_RDONLY);
+ sprintf(buf, "%s.%02d", dev->device->filename, ep);
+ fd = open(buf, mode);
if(fd < 0)
- USB_ERROR_STR(fd, "can't open %s for bulk read: %s\n",
+ USB_ERROR_STR(fd, "can't open %s for bulk operations: %s\n",
buf, strerror(errno));
info->ep_fd[ep] = fd;
}
@@ -234,10 +236,12 @@
req.data = bytes;
req.flags = 0;
+#if 0
ret = ioctl(dev->fd, USB_SET_TIMEOUT, &timeout);
if (ret < 0)
USB_ERROR_STR(ret, "error setting timeout: %s",
strerror(errno));
+#endif
ret = ioctl(dev->fd, USB_DO_REQUEST, &req);
if (ret < 0)
@@ -285,7 +289,7 @@
/* Open its control endpoint */
- sprintf(buf, "/dev/%s", di.devnames[0]);
+ sprintf(buf, "/dev/%s.00", di.devnames[0]);
dfd = open(buf, O_RDONLY);
if(dfd < 0)
{
@@ -302,7 +306,7 @@
dev->bus = bus;
- strcpy(dev->filename, buf);
+ sprintf(dev->filename, "/dev/%s", di.devnames[0]);
if(ioctl(dfd, USB_GET_DEVICE_DESC, &dev->descriptor) < 0)
USB_ERROR_STR(-errno, "couldn't get device descriptor for %s: %s",
|