Changeset 1051
- Timestamp:
- 05/22/08 13:07:31 (4 years ago)
- File:
-
- 1 edited
-
trunk/src/ifd/sys-bsd.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/ifd/sys-bsd.c
r973 r1051 14 14 #if defined(__NetBSD__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined(__FreeBSD_kernel__) || defined(__DragonFly__) 15 15 #include <sys/types.h> 16 #if defined(__DragonFly__) 17 #include <bus/usb/usb.h> 18 #else 16 19 #include <dev/usb/usb.h> 20 #endif 17 21 #include <sys/stat.h> 18 22 #include <sys/ioctl.h> … … 64 68 } 65 69 66 sprintf((char *)&filename, "%s.%d", name, endpoint); 70 #ifdef __OpenBSD__ 71 snprintf(filename, sizeof(filename), "%s.%02d", name, endpoint); 72 #else 73 snprintf(filename, sizeof(filename), "%s.%d", name, endpoint); 74 #endif /* __OpenBSD__ */ 67 75 68 76 if ((interfaces[interface][endpoint].ep_fd = open(filename, flags)) < 0) { … … 95 103 ct_debug("ifd_sysdep_usb_bulk: endpoint=%d direction=%d", endpoint, 96 104 direction); 97 if (open_ep(dev->name, 0, endpoint, O_RDWR | O_NONBLOCK)) {98 ct_debug("ifd_sysdep_usb_bulk: opening endpoint failed");99 return -1;100 }101 105 if (direction) { 106 int one = 1; 107 108 if (open_ep(dev->name, 0, endpoint, O_RDONLY | O_NONBLOCK)) { 109 ct_debug("ifd_sysdep_usb_bulk: opening endpoint failed"); 110 return -1; 111 } 112 113 if (ioctl(interfaces[0][endpoint].ep_fd, USB_SET_SHORT_XFER, 114 &one) < 0) { 115 ifd_debug(6, "ifd_sysdep_usb_bulk: USB_SET_SHORT_XFER" 116 " failed: %s", strerror(errno)); 117 ct_error("usb_bulk read failed: %s", strerror(errno)); 118 } 102 119 if ((bytes_to_process = 103 120 read(interfaces[0][endpoint].ep_fd, buffer, len)) < 0) { … … 111 128 return bytes_to_process; 112 129 } else { 130 if (open_ep(dev->name, 0, endpoint, O_WRONLY | O_NONBLOCK)) { 131 ct_debug("ifd_sysdep_usb_bulk: opening endpoint failed"); 132 return -1; 133 } 134 113 135 bytes_to_process = len; 114 136 if ((bytes_processed = … … 315 337 int ifd_sysdep_usb_open(const char *device) 316 338 { 339 #ifdef __OpenBSD__ 340 char path[256]; 341 342 if (snprintf(&path, sizeof(path), "%s.00", device) < 0) 343 return -1; 344 return open(path, O_RDWR); 345 #else 317 346 return open(device, O_RDWR); 347 #endif /* __OpenBSD__ */ 318 348 } 319 349 … … 385 415 if (!(driver = ifd_driver_for_id(&id))) 386 416 continue; 387 #ifdef __OpenBSD__388 snprintf(typedev, sizeof(typedev),389 "usb:/dev/%s.00", device_info.udi_devnames[0]);390 #else391 417 snprintf(typedev, sizeof(typedev), 392 418 "usb:/dev/%s", device_info.udi_devnames[0]); 393 #endif /* __OpenBSD__ */394 419 395 420 ifd_spawn_handler(driver, typedev, -1);
Note: See TracChangeset
for help on using the changeset viewer.
