From 62b9af0706d54cd4e44f40f0da057e04d7b14ec5 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Tue, 3 Nov 2009 14:50:40 -0800 Subject: =?UTF-8?q?From=20M=C3=A1rton=20N=C3=A9meth:?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The usbmon text interface was moved from /sys/kernel/debug/usbmon to /sys/kernel/debug/usb/usbmon as of patch http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=f49ce96f11112a84c16ac217490ebd6f8d9a8977 . Please add this new directory also into the search list when finding USB devices. Get rid of older address for Gisle Vanem; convert Love's address to UTF-8 (as it is in the tcpdump CREDITS file). --- pcap-usb-linux.c | 41 ++++++++++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 9 deletions(-) (limited to 'pcap-usb-linux.c') diff --git a/pcap-usb-linux.c b/pcap-usb-linux.c index bcbe45a..fea527f 100644 --- a/pcap-usb-linux.c +++ b/pcap-usb-linux.c @@ -65,7 +65,8 @@ static const char rcsid[] _U_ = #endif #define USB_IFACE "usbmon" -#define USB_TEXT_DIR "/sys/kernel/debug/usbmon" +#define USB_TEXT_DIR_OLD "/sys/kernel/debug/usbmon" +#define USB_TEXT_DIR "/sys/kernel/debug/usb/usbmon" #define SYS_USB_BUS_DIR "/sys/bus/usb/devices" #define PROC_USB_BUS_DIR "/proc/bus/usb" #define USB_LINE_LEN 4096 @@ -354,10 +355,21 @@ usb_activate(pcap_t* handle) handle->fd = open(full_path, O_RDONLY, 0); if (handle->fd < 0) { - /* no more fallback, give it up*/ - snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, - "Can't open USB bus file %s: %s", full_path, strerror(errno)); - return PCAP_ERROR; + if (errno == ENOENT) + { + /* + * Not found at the new location; try + * the old location. + */ + snprintf(full_path, USB_LINE_LEN, USB_TEXT_DIR_OLD"/%dt", handle->md.ifindex); + handle->fd = open(full_path, O_RDONLY, 0); + } + if (handle->fd < 0) { + /* no more fallback, give it up*/ + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "Can't open USB bus file %s: %s", full_path, strerror(errno)); + return PCAP_ERROR; + } } if (handle->opt.rfmon) { @@ -614,10 +626,21 @@ usb_stats_linux(pcap_t *handle, struct pcap_stat *stats) fd = open(string, O_RDONLY, 0); if (fd < 0) { - snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, - "Can't open USB stats file %s: %s", - string, strerror(errno)); - return -1; + if (errno == ENOENT) + { + /* + * Not found at the new location; try the old + * location. + */ + snprintf(string, USB_LINE_LEN, USB_TEXT_DIR_OLD"/%ds", handle->md.ifindex); + fd = open(string, O_RDONLY, 0); + } + if (fd < 0) { + snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, + "Can't open USB stats file %s: %s", + string, strerror(errno)); + return -1; + } } /* read stats line */ -- cgit v1.2.3