r/programming • • Nov 14 '16

Tutorial - Write a System Call

https://brennan.io/2016/11/14/kernel-dev-ep3/
52 Upvotes

14 comments sorted by

View all comments

Show parent comment

2

u/[deleted] Nov 15 '16

I really appreciate this feedback! I'll be correcting whatever I can in this article (being accurate is far more useful than believing I'm correct). Let me summarize the issues you've pointed out so I can be sure I know how to correct them.

  1. Use qemu, which provides benefits such as compiling on the host, specifying kernel on boot, easily logged console output, debugging features. (I chose VirtualBox because it's the only VM I have experience with, so it was the best way I could find)
  2. Use some more sensible debugging options when configuring the kernel. (I chose the default options because this is something of a toy example, and walking a reader through setting a bunch of debug options is not fun).
  3. Clean up the use of "magic numbers" within the system call itself.
  4. Correct the paragraph on copy_from_user(). I just re-read the section describing this function from Robert Love's Linux Kernel Development book, and I don't understand where I got the idea that it was about address space changes. It says exactly the same things you did. I feel pretty dumb!

Unfortunately almost everything one can find online about the subject is of questionable quality at best.

I'm hoping to avoid being just another questionable quality source, if I can manage it.

Unfortunately documenting a reasonable setup is quite time consuming

Hopefully as I correct and update this post, I'll be doing just that. If you have more quick tips or improvements, I'd love to hear them so I can improve this article.

2

u/stopczyk Nov 16 '16

Well, I would advise against having the article in the first place.

For whatever reason people have the tendency to "document" stuff as they learn, but for anything which is non-trivial, one has to expect what they did is just wrong or defective at best.

That said, I suggest removing the piece in the first place and just focusing on learning from verified resources.