Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am trying to load a char device driver written by myself. To achieve this I use a modified bash script published on this site: http://www.makelinux.net/ldd3/chp-3-sect-2. Here is my version of the script:

#!/bin/sh

device="ki32"
module="ki32"
mode="664"

if [ $2 = "start" ]; then

    /sbin/insmod $1/$module.ko || exit 1

    rm -f /dev/${device}
    major=`cat /proc/devices | grep "$module" | sed 's/\([0-9]*\)\( [a-zA-Z]*\)/\1/'`
    mknod /dev/${device} c $major 0
    chmod $mode /dev/${device}
elif [ $2 = "stop" ]; then

    /sbin/rmmod $module.ko
    rm -f /dev/${device}
fi

However the script fails showing a message similar to this:

# mknod: `/dev/ki32': Invalid argument

The same thing happens when I execute the command outside the script, still logged as root of course.

Your help is greatly appreciated.

share|improve this question
2  
are you sure major is being set correctly? Run the command manually to check what it returns. –  lynxlynxlynx Jul 1 '12 at 15:52
    
Thanks, I have figured it out too, however I couldn't answer to my own question because I haven't got enough points on my account. And yes, there is a problem particularly with extracting the major number which is additionally (wrongfully) concatenated with 32 number (which is a part of module's name). Thanks for your time anyway. –  krzysiekb Jul 1 '12 at 18:04

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.