0

I am trying to write scull device according to this tutorial : linux device drivers. My source is here my scull repo, where is dmesg2.err file with kern log dump. I had previously problem to initilize the char device kernel output weird dmesg of my driver module which I have fixed. The problem now is, when I try to read from the empty device /dev/scull0, I receive killed. Or when I try to write echo "abc" >/dev/stdin, then Segmentation fault. I would really like to learn to how to debug from the kern.log, but do not have skills for that yet (I am intermediate c, and basic of GAS asm), and therefor would like to have some really good book for debuging kernel + what skills I need to understand it. You could find the bug in the source but my intend is to solve these bugs by myself in the future. Thanks for advices.

autistic456
  • 183
  • 1
  • 10
  • regarding: `echo "abc" >/dev/stdin` `stdin` is a input stream. You cannot write to `stdin`, like you can to `stdout` and `stderr`. – user3629249 May 31 '20 at 23:20
  • Please post your code as text, Do not link to the code, as links can change, etc. – user3629249 May 31 '20 at 23:21
  • regarding: `#ifndef _SCULL_H_ /*beginning*/ #define _SCULL_H_` do not use leading underscores, especially when followed by a capital letter. Such sequences are 'reserved' for the implementation. Strongly suggest removing the leading underscores – user3629249 May 31 '20 at 23:25
  • OT: a header file 'should' be able to be compiled on its' own. However, the file: `scull.h` does not compile! Also, regarding the parameter: `char __user *buf,` This does not compile! the `__user` is not defined. – user3629249 May 31 '20 at 23:44
  • OT: When `copy_to_user` or `copy_from_user` fails, the return value should be `-EFAULT`, not `-1`. – Ian Abbott Jun 02 '20 at 15:14
  • @IanAbbott that is detail. It is only important, when you want to know the exact errno, otherwise, it just failed – autistic456 Jun 04 '20 at 11:43
  • @autistic456 Yes, it is not really related to the question, which is why I marked it 'OT' for 'off-topic'. It just means that userspace's errno would be set to the wrong value if userspace passes a bad pointer to the operation. – Ian Abbott Jun 04 '20 at 13:39

0 Answers0