Re: 2.4 Q: list of open files per inode?

From: Jan Engelhardt
Date: Sun Jul 22 2007 - 09:08:01 EST



On Jul 22 2007 05:45, Jacob A wrote:
>
>Ah, yes, this was my intention, to keep the state in filp->private_data.
>But then at a timer routine I wanted to go over all the filps associated with the device
>and check/modify the state. That's why I needed the open files list.

No. For each private_data that you allocate, create a linked list
that also has them. In other words:


struct mystuff {
struct list_head list;
int other_fluff;
};

int mydriver_open()
{
struct mystuff *pd = kmalloc(...);
filp->private_data = pd;
list_add(&pd->list);
}

int mydriver_close()
{
struct mystuff *pd = filp->private_data;
list_del(&pd->list);
free(pd);
}

Simple as that. *Of course* this requires that the file descriptor remains
open. But that should not be a problem, would it?


Jan
--



>

Jan
--



>

Jan
--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/