LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-20-2008, 04:07 AM   #1
linuxdoniv
Member
 
Registered: Mar 2008
Posts: 63

Rep: Reputation: 15
Unhappy writing a structure to the a entry in /proc


Hi,

I am trying to create an entry in /proc. create_proc_entry is the function I am using for that. struct proc_dir_entry * ptr has ptr->read_proc as one function which has to fill the entry with data. I want to create and write one type of structure elements to the entry in a loop.

But since it is a module, I can't use fwrite. I dont want to write it as series of characters i.e string for efficiency reasons.

I am wondering how to go about it. Thanks for any help in this regard.....
 
Old 03-20-2008, 06:02 AM   #2
digvijay.gahlot
Member
 
Registered: Mar 2008
Posts: 53

Rep: Reputation: 15
Tell your problem in detail.
There is a struct page pointer in the read function's parameter. And all sorts of write are to be done on it.
while writing to page we generally try something like


int length = 0;
length += sprintf(page_ptr + length," The data i wish to write %d",counter);

Sorry if you already know.

Last edited by digvijay.gahlot; 03-20-2008 at 06:08 AM.
 
Old 03-20-2008, 07:05 AM   #3
linuxdoniv
Member
 
Registered: Mar 2008
Posts: 63

Original Poster
Rep: Reputation: 15
Say I have
struct stat
{ char a;
int b;
}elem;

This structure has to be written to an entry that I am creating in proc i.e /proc/new_file.I must be able to use fread(&elem,sizeof(elem),1,new_file_ptr) in another user level application.

How do I go about it. Thanks.....
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Strange entry in `df` (df: `/var/named/chroot/proc': Permission denied) BWebb Linux - General 1 09-14-2006 10:08 AM
How to read from /proc entry in another kernel module? linux_lover2005 Programming 0 01-14-2005 05:44 AM
writing to proc module dmaxj Linux - General 5 07-02-2003 09:44 AM
structure of /proc files dmaxj Linux - General 6 06-09-2003 06:01 PM
perl - writing a data structure to a file.. is it possible? paavaka Programming 4 07-14-2001 12:04 AM


All times are GMT -5. The time now is 05:35 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration