Hi Dan, The kernel provides methods (via the file_operations structure) for ur kernel module to talk to userspace programs. Now, "write" is a system call. When u call "write"(using the x80 interrupt) in ur program, ur code enters kernel mode and the kernel calls the "wdt_write" function of ur module with, 1. The pointer to the data(char *buf) to be written(U gave this in ur write call) 2. The size of the data u want to write(U gave this in ur write call) 3. The offset of data. 4. The struct file necessary. These are the args that ur kernel module needs to successfully complete the job given by user space prog. So the kernel acts as a broker (a nasty example as the kernel does hell lot of other things) by calling ur function with all these parameters. Try to understand how syscalls are handled and u will get the correct outlook of how and by whom ur function is called. Guys, correct me if iam wrong :) Cheers, Mohan S --- Dan Erickson <coldoneknight@rogers.com> wrote: > > I have asked this question before, but I didnt get > a response from > somebody who understood my question correctly. So.. > I will try showing a > couple more examples. > > Basicly when your writing... how shall I say....?? > *normal code*, you use > your functions in such a manner as follows. > > int foo; > char *bar = "5"; > > foo = atoi(bar); > > now here we give our funtion an argument > > while when you have kernel code, instead of writing > the actual args, you > basicly make up your own function like... > > static ssize_t wdt_write(struct file *file, const > char *buf, size_t count, > loff_t *ppos) > { > /* Can't seek (pwrite) on this device */ > if (ppos != &file->f_pos) > return -ESPIPE; > > if(count) > { > foo(); > return 1; > } > return 0; > } > > > What has me confussed is.... what gives this > function the arguments so it > can function properly. Ie) as bar is the arg to > atoi() earlier. > > Thanks for your help > > -Dan Erickson- > -ColdOneKnight@rogers.com- > > -- > Kernelnewbies: Help each other learn about the Linux > kernel. > Archive: > http://mail.nl.linux.org/kernelnewbies/ > FAQ: http://kernelnewbies.org/faq/ > __________________________________________________ Do You Yahoo!? Yahoo! Games - play chess, backgammon, pool and more http://games.yahoo.com/ -- Kernelnewbies: Help each other learn about the Linux kernel. Archive: http://mail.nl.linux.org/kernelnewbies/ FAQ: http://kernelnewbies.org/faq/