On Sun, 2002-07-07 at 22:18, Johannes Erdfelt wrote:
> I know strace will do something similar for other system calls, so I
> suspect it'll be relatively straight forward.
here is an example patch, it does only usb controls.
it this what you thought of? "works for me", i.e. i can
see the ioctl / usb control done by that binary only driver.
regards, andreas
diff -udrNP strace-4.4.orig/Makefile.in strace-4.4/Makefile.in
--- strace-4.4.orig/Makefile.in Fri Feb 16 23:07:01 2001
+++ strace-4.4/Makefile.in Mon Jul 8 21:26:35 2002
@@ -54,7 +54,7 @@
OBJ = strace.o version.o syscall.o util.o desc.o file.o ipc.o \
io.o ioctl.o mem.o net.o process.o bjm.o \
resource.o signal.o sock.o system.o term.o time.o \
- proc.o stream.o
+ proc.o stream.o usbdevfs.o
all: strace
diff -udrNP strace-4.4.orig/defs.h strace-4.4/defs.h
--- strace-4.4.orig/defs.h Sat Jul 14 00:07:44 2001
+++ strace-4.4/defs.h Mon Jul 8 21:10:18 2002
@@ -414,6 +414,7 @@
extern int sock_ioctl P((struct tcb *, long, long));
extern int proc_ioctl P((struct tcb *, int, int));
extern int stream_ioctl P((struct tcb *, int, int));
+extern int usbdevfs_ioctl P((struct tcb *, int, int));
extern void tv_tv P((struct timeval *, int, int));
extern int tv_nz P((struct timeval *));
diff -udrNP strace-4.4.orig/ioctl.c strace-4.4/ioctl.c
--- strace-4.4.orig/ioctl.c Sun Aug 19 14:06:50 2001
+++ strace-4.4/ioctl.c Mon Jul 8 21:27:22 2002
@@ -132,6 +132,10 @@
case 'S':
return stream_ioctl(tcp, code, arg);
#endif /* HAVE_SYS_STREAM_H */
+#ifdef LINUX
+ case 'U':
+ return usbdevfs_ioctl(tcp,code,arg);
+#endif /* LINUX */
default:
break;
}
diff -udrNP strace-4.4.orig/usbdevfs.c strace-4.4/usbdevfs.c
--- strace-4.4.orig/usbdevfs.c Thu Jan 1 01:00:00 1970
+++ strace-4.4/usbdevfs.c Mon Jul 8 22:38:11 2002
@@ -0,0 +1,74 @@
+/* Decoder for usb device ioctls on linux.
+ * Handling all Group "U" io controls.
+ *
+ * parts taken from usbdevice_fs.h
+ * Copyright (C) 2000 Thomas Sailer ([EMAIL PROTECTED])
+ */
+
+#include "config.h"
+
+#ifdef LINUX
+
+#define USBDEVFS_CONTROL 0
+
+#include "defs.h"
+
+struct usbdevfs_ctrltransfer {
+ u_int8_t requesttype;
+ u_int8_t request;
+ u_int8_t value;
+ u_int16_t index;
+ u_int16_t length;
+ u_int32_t timeout; /* in milliseconds */
+ void *data;
+};
+
+
+int usbdevfs_ioctl(struct tcb *tcp, int code, int arg)
+{
+ struct usbdevfs_ctrltransfer ctrl;
+
+ if (!verbose(tcp))
+ return 0;
+
+ if (((code >> 8) & 255) != 'U')
+ return 0;
+
+ switch (code & 255) {
+ case USBDEVFS_CONTROL:
+ if (umoven(tcp, arg, sizeof(ctrl), (char *) &ctrl))
+ return 0;
+ if (entering(tcp)) {
+ if ((ctrl.requesttype & 0x80) == 0) {
+ tprintf
+ (", {requesttype=%hhd(write), request=%hhd,
+value=%hd, index=%hd, length=%hd, timeout=%d}",
+ ctrl.requesttype, ctrl.request,
+ ctrl.value, ctrl.index, ctrl.length,
+ ctrl.timeout);
+ if (ctrl.length > 0) {
+ tprintf("\n");
+ dumpstr(tcp, (long) ctrl.data,
+ ctrl.length);
+ }
+ }
+ } else {
+ if (ctrl.requesttype & 0x80) {
+ tprintf
+ (", {requesttype=%hhd(read), request=%hhd,
+value=%hd, index=%hd, length=%hd, timeout=%d}",
+ ctrl.requesttype, ctrl.request,
+ ctrl.value, ctrl.index, ctrl.length,
+ ctrl.timeout);
+ if (ctrl.length > 0) {
+ tprintf("\n");
+ dumpstr(tcp, (long) ctrl.data,
+ ctrl.length);
+ }
+ }
+ }
+
+ default:
+ return 0;
+ }
+}
+
+#endif /* LINUX */
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Oh, it's good to be a geek.
http://thinkgeek.com/sf
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-users