LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 01-05-2008, 05:02 AM   #1
gandil
LQ Newbie
 
Registered: Dec 2005
Posts: 7

Rep: Reputation: 0
How can i pass content of a file to /proc/


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

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

Any idea?
 
Old 01-05-2008, 05:40 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

Looks like you are looking for (named) pipes/fifo's.

Here's an example and here another example.

Hope this helps.
 
Old 01-08-2008, 03:35 AM   #3
ashok449
Member
 
Registered: Sep 2007
Location: noida
Distribution: suse
Posts: 63

Rep: Reputation: 16
For this your driver itself needs to create file in /proc directory like

Code:
proc_entry = create_proc_entry( "NEWD", 0644, NULL );

create /proc files in ur driver with the hep of

Code:
#include <linux/proc_fs.h>

static struct proc_dir_entry *proc_entry;

All the best
 
Old 01-11-2008, 07:41 PM   #4
gandil
LQ Newbie
 
Registered: Dec 2005
Posts: 7

Original Poster
Rep: Reputation: 0
so my question is still unanswered. How can i pass information from /dev/mydev to /proc/mydevice ?
 
Old 01-13-2008, 11:43 PM   #5
ashok449
Member
 
Registered: Sep 2007
Location: noida
Distribution: suse
Posts: 63

Rep: Reputation: 16
I mean the driver it self having both Dev node and /proc fs node like

creating /DEV/DFILE node
Code:
devfs_handle=devfs_register(NULL, DFILE , DEVFS_FL_AUTO_DEVNUM,
				    0,0,
				    S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, 
				    &ticfg_fops, &ticfg_dev);

in the same module create /Proc/NEWD node
Code:
proc_entry = create_proc_entry( "NEWD", 0644, NULL );

both these have seperate fileoperations ,

proc file operations
Code:
   proc_entry->read_proc = newd_read;
      proc_entry->write_proc = newd_write;
just use that file (file structure) to communicate in both ways.




Ashok Athukuri
 
Old 01-15-2008, 07:54 AM   #6
gandil
LQ Newbie
 
Registered: Dec 2005
Posts: 7

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by ashok449 View Post
I mean the driver it self having both Dev node and /proc fs node like

creating /DEV/DFILE node
Code:
devfs_handle=devfs_register(NULL, DFILE , DEVFS_FL_AUTO_DEVNUM,
				    0,0,
				    S_IFCHR | S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP, 
				    &ticfg_fops, &ticfg_dev);

in the same module create /Proc/NEWD node
Code:
proc_entry = create_proc_entry( "NEWD", 0644, NULL );

both these have seperate fileoperations ,

proc file operations
Code:
   proc_entry->read_proc = newd_read;
      proc_entry->write_proc = newd_write;
just use that file (file structure) to communicate in both ways.




Ashok Athukuri

Thank you. now it is clear
 
Old 01-27-2008, 03:44 PM   #7
gandil
LQ Newbie
 
Registered: Dec 2005
Posts: 7

Original Poster
Rep: Reputation: 0
Thumbs up thank

thanks for all messages
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to create a new file including content from reading another file !? silverhand Programming 2 10-06-2007 04:33 PM
Boot hang after 'proc on /proc type proc (rw)' Hagoromo Slackware 13 10-05-2007 05:03 PM
Show file Content on File Select HTML stranger_6_7 Linux - General 4 09-24-2007 11:52 PM
changing the content of file in spec file dsubbarao Linux - Newbie 7 01-30-2007 06:41 AM
What /proc proc file do I need? GoboFraggle Programming 1 02-04-2003 11:52 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 08:29 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration