Find the answer to your Linux question:
Results 1 to 2 of 2
hello friends, i am a fresher in kernel programming and i am trying to implement a linked list in kernel space using the file <linux/list.h>,but it not success ,actually i ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2007
    Posts
    16

    linked list implimentation in kernel memory


    hello friends,
    i am a fresher in kernel programming and i am trying to implement a linked list in kernel space using the file <linux/list.h>,but it not success ,actually i dont get an idea to how to use the functions in list.h file. If anyone have the code or good documents about it
    pleaser help me ...........
    thank you
    shabeer

  2. #2
    Linux Newbie dilbert's Avatar
    Join Date
    Sep 2006
    Location
    Yorkshire, GB
    Posts
    237
    I don't know actually some kernel source files that would serve as a good example for linked lists nor a special tutorial.

    Tutorials must be quite a many on the Web, depends maybe on what you already know about linked lists.

    You could lookup the kernel source by doing a search with one of the function names from list.h.

    This is often tedious because often the examples you are looking for are mixed together with other stuff and it's often difficult to extract the code you are looking for from the rest.

    Also, sometimes you encounter bad examples in the kernel source and you become aware of that only after some time.

    But I post here a small script that I am using with the kernel source to do a pattern search. It surely runs alone without SlickEdit that I'm not using anymore.

    Code:
    #! /bin/sh
    # MUST run in a subshell (any one) to run it in the SlickEdit output window
    #
    # filename: gr
    # usage:    gr arg1 [arg2 arg3]
    # example:  gr pattern h w
    #
    # function: script to call in the output window of SlickEdit Version 6.0
    #           to abbreviate standard searches with grep
    #
    # examples to call: gr "spin_lock_bh(&q->lock)"
    #                   gr "switch.*ethcmd"
    #                   gr "ip6q_destroy_queue(ip6q_queue_t \*q)"
    #                      using a backslash before a meta-character
    #                      like * in "ip6q_destroy_queue(ip6q_queue_t *q)"
    #                   gr nf_unregister_queue_handler
    #
    
    # set found pattern in output to colour blue (32:green, 30-49: .. )
    export GREP_COLOR="1;34"
    # colours from this script don't work in my SlickEdit output window
    
    if [[ -z $1 ]]; then
        echo "usage: gr pattern optional_file_extension optional_additional_grep_arguments"
        exit 0
    fi
    
    # set arguments used for grep
    ARGS="-nrs --color "
    PATTERN=$1
    
    # set file globs
    if [[ -z $2 ]]; then
        # no second parameter: use default value
        FILES="*.[ch]"
    else
        FILES="*.[$2]"
    fi
    
    # if there are additional arguments, add another hyphen and concatenate them
    if [[ -n $3 ]]; then
        ARGS=$ARGS-$3
    fi
    
    # we are grepping only file names starting with "./" to suppress double file
    # names when inside a directory with those files, e.g. "modem.c" and "./modem.c"
    GR_FILES="^\.\/"$FILES
    
    # the last grep command (i.e the rightmost) has been added to suppress double
    # file names when inside a directory with those files, e.g. "modem.c" and "./modem.c"
    find . -name "$FILES" | xargs grep $ARGS -e "$PATTERN" $GR_FILES 
    
    echo "matches found: `find . -name "$FILES" | xargs grep $ARGS -e "$PATTERN" $GR_FILES | wc -l`"
    Bus Error: Passengers dumped. Hech gap yo'q.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •