Jan Hudec wrote: >>On 11/4/05, Bahadir Balban <bilgehan.balban@xxxxxxxxx> wrote: >>>I want to log data, (mainly usb transactions) into a file from >>> within >>>the kernel. The code writing to the file may well be running in >>>interrupt context, so it won't be associated with a process. > > I suppose you meant to say procfs, not sysfs. Sysfs is a specific > way of accessing kobject properties. Procfs is much more general, so it > can be (ab)used for things like this. I have trace data that I export to user space via procfs, using seq_file operations. I copied this technique from Ingo Molnar's code to trace preemption issues, and it has been working well for my tracing system. Patches are available at: http://tree.celinuxforum.org/CelfPubWiki/KernelFunctionTrace (follow the link under Downloads to the CELF patch archive, and look for kft-all-in-one-2.6.12.patch. Sorry, patches for later kernels are not available yet.) The code which performs the output of the trace log is in the routines k_start, k_next, k_stop and k_show, in the file kernel/kft.c. Those functions are in the struct seq_operations kft_data_op which is referenced in the patch for fs/proc/proc_misc.c The trace log is written to from any context in the kernel, and read in process context. In my system the trace is stopped while the data is being read. This is pretty straightforward to use, and hopefully the KFT patch has enough material to get you started. I shove a lot of data through the interface, it supports using simple tools like 'cat' to extract the data. Hope this helps. -- Tim ============================= Tim Bird Architecture Group Chair, CE Linux Forum Senior Staff Engineer, Sony Electronics ============================= -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/