Find the answer to your Linux question:
Results 1 to 7 of 7
I wonder about how can i take input from user write to a file then pass file content to /proc file. For example my device file is DFILE under /dev, ...
  1. #1
    Just Joined!
    Join Date
    Dec 2005
    Posts
    6

    Exclamation How can i pass content of a file to /proc/

    I wonder about how can i take input from user write to a file then pass file content to /proc file.

    For example my device file is DFILE under /dev,
    user will enter
    echo "this is my try" > /dev/DFILE
    After that user will enter
    cat /proc/NEWD
    Then user should saw what we write.

    Any idea?
    Last edited by gandil; 01-05-2008 at 09:58 AM. Reason: bad writing

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    That's not really what the /proc directory is for. For details on what it's for, go here.

    What is it you ultimately want to do?
    --
    Bill

    Old age and treachery will overcome youth and skill.

  3. #3
    Linux Enthusiast
    Join Date
    Aug 2006
    Posts
    631
    You have to learn how to program a device driver, this is a useful link to a free book in pdf:

    http://tldp.org/LDP/lkmpg/2.6/lkmpg.pdf

    Chapter 5.2 discusses how to read and write to a proc file.

    Regards

  4. #4
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    Franklin52, I had no idea. This is quite interesting. (I'm not a device driver kinda guy, not yet anyway.)

    Thanks! :)
    --
    Bill

    Old age and treachery will overcome youth and skill.

  5. #5
    Just Joined!
    Join Date
    Dec 2005
    Posts
    6
    so how can i pass /dev/MYDEV information to /proc/MYDEVICE ?

  6. #6
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    The PDF that Franklin listed contains information on setting up a /dev entry and a /proc entry. Combine the two. This way, when the dev entry is written to, you store that into a buffer, and when the proc entry is read from, you output that buffer.

    Easy peasy.
    DISTRO=Arch
    Registered Linux User #388732

  7. #7
    Just Joined!
    Join Date
    Dec 2005
    Posts
    6

    thank you

    thank you.

Posting Permissions

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