View previous topic :: View next topic |
Author |
Message |
Clansman Tux's lil' helper
Joined: 10 Jan 2004 Posts: 140
|
Posted: Thu Oct 14, 2004 1:20 pm Post subject: kernel module programming question |
|
|
hi everyone,
not sure if i'd post here or in kernel & hardware. can't harm putting it here.
i made a very simple kernel module that creates a /proc file and it counts the number of accesses to itself.
the problem is that the counter gets incremented by steps of 2 or 3 instead of 1.
i mean catting the file once i get counter value=1, then catting it again i get counter value=4 and so on...
stracing the "cat /proc/new/info" results in 1 open of the file and one read. still those are 2 accesses and not 3. to be sure i made a program that just opens and closes the file to see if the counter got updated. it didn't...
what could be happening here?
thanks.
[] |
|
Back to top |
|
|
Athas Guru
Joined: 04 Sep 2003 Posts: 394 Location: Brøndby, Denmark
|
|
Back to top |
|
|
Clansman Tux's lil' helper
Joined: 10 Jan 2004 Posts: 140
|
Posted: Thu Oct 14, 2004 2:39 pm Post subject: |
|
|
feedback
ok, i could post the entire code but that would be big. i'd start by the read_proc function:
Code: |
/*
* read_proc function
*
*/
static int hackalot_proc_info (char *page,char **start,off_t off,int count,int *eof,void *data)
{
int size;
/* just print information */
size=sprintf(page, "%s %d %s\n",HACKALOT_INFO_D1,counter,HACKALOT_INFO_D2);
if(size>0)
++counter;
return(size);
}
|
right now it's a bit different. the counter variable is properly locked via atomic operations and the size>0 check is no longer. it doesn't make a difference.
still the behaviour is not the expected.
thanks. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|