Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 03-20-2008, 05:07 AM   #1
Registered: Mar 2008
Posts: 63

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


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, 07:02 AM   #2
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 07:08 AM.
Old 03-20-2008, 08:05 AM   #3
Registered: Mar 2008
Posts: 63

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

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.....


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 11:08 AM
How to read from /proc entry in another kernel module? linux_lover2005 Programming 0 01-14-2005 06:44 AM
writing to proc module dmaxj Linux - General 5 07-02-2003 10:44 AM
structure of /proc files dmaxj Linux - General 6 06-09-2003 07:01 PM
perl - writing a data structure to a file.. is it possible? paavaka Programming 4 07-14-2001 01:04 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:06 AM.

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