Skip to contentSkip to conversation

some /proc understandings

DISCUSSION linux lover 1 participant 1 message Mar 2, 2005

lore
Share & tools
lore
#0 lore raw

Hello,
1) I want to know how much can i write to
/proc entry file?? Is there any limitation on file size???
2)Also how can i call /proc entry files
proc_read_myfile function on that file by another kernel module call? What parameters i require to pass and how? Say i have read functions as

struct myfile_data_t {
char value[8];
};
struct proc_dir_entry *myfile_file;
struct myfile_data_t myfile_data;

int proc_read_myfile(char *page, char **start, off_t off, int count, int *eof, void *data)
{
int len;

/* cast the void pointer of data to myfile_data_t*/
struct myfile_data_t *myfile_data=(struct
myfile_data_t *)data;

/* use sprintf to fill the page array with a string */

  len = sprintf(page, "%s", myfile_data->value);
    return len;
}

Then can it possible that i can call proc_read_myfile from another kernel module?? Instead read file from user level call?
3) Also Is following code valid of creating /proc
files with different file name created by passing function cr_proc(fname)?

struct proc_dir_entry *entnew;
int cr_proc(char *fname)
{
if ((entnew1 = create_proc_entry(fname,
S_IRUGO | S_IWUSR, NULL)) == NULL)

        return -EACCES;
       entnew1->proc_fops = &proc_file_operations;
}
static struct file_operations proc_file_operations = {
    open:       proc_open,
    release:    proc_release,
    read:       proc_read,
    write:      proc_write,

};

What will happen if dynamic file names are going
to use same all above 4 functions???
regards,
linux_lover

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com