Thread: printing from kernel

  1. #1
    Registered User
    Join Date
    Oct 2008

    printing from kernel

    i am a beginner kernel programmer. i need to write a kernel code for a new system call called
    int sys_printstr(void *buf);
    This system call returns the usual success/failure codes. The buf argument that it gets is an
    encoded string as follows:
    the first byte in buf contains the length of the string in bytes
    the bytes that follow in buf contain the actual string, excluding the terminating null it should correctly printk this encoded string which is passed from user-land.

    any clue/suggestion?

    thanks in advance..


  2. #2
    Registered User valaris's Avatar
    Join Date
    Jun 2008
    RING 0
    Well I believe printk still takes a null terminated string, so if you know how long it is either move all the memory over one byte where the length used to be, or move it to a new buffer and throw a nul terminator on the end.
    Last edited by valaris; 10-30-2008 at 11:25 PM.

  3. #3
    Registered User
    Join Date
    Oct 2008
    I need the actual code

  4. #4
    Hacker MeTh0Dz's Avatar
    Join Date
    Oct 2008
    I'm sure you do.

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Anyone who wants to be a kernel programmer, and who needs "actual code" for this simply isn't ready.

    I mean, what are you going to do when your fumbling around in the dark causes a kernel panic and you're once again admiring the BIOS startup logo?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Farncombe, Surrey, England
    I agree with Salem - if you haven't got a good idea of how to do this, you are not a kernel level programmer (yet - there is nothing saying you can't get there).

    What have you done so far?

    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Kernel bug? (attn matsp)
    By brewbuck in forum Linux Programming
    Replies: 7
    Last Post: 04-13-2009, 10:31 AM
  2. C# Printing Problem
    By silverlight001 in forum C# Programming
    Replies: 0
    Last Post: 03-23-2009, 01:13 AM
  3. SOS - Can a monolithic kernel be used in a micro-kernel style OS?
    By sean in forum A Brief History of
    Replies: 7
    Last Post: 11-20-2008, 09:30 AM
  4. need help relating printing?
    By omarlodhi in forum Linux Programming
    Replies: 0
    Last Post: 03-03-2006, 04:46 AM
  5. CreateThread ?!
    By Devil Panther in forum Windows Programming
    Replies: 13
    Last Post: 11-15-2005, 10:55 AM