Handling a directory search
Hi folks.
I'm tweaking the readdir handling for YAFFS and need to be able to manage a "directory search context" structure where I can stash the context.
ie.
/* user prog and corresponding YAFFS operation */
opendir(..); /* YAFFS needs to create a search context */
readdir(...); /* YAFFS needs to use the search context */
closedir(...); /* YAFFS needs to release the search context */
I am unsure as to how to hook the opendir and closedir to create/release the directory search context.
Any pointers?
First prize: Any examples?
Thanx
-- Charles
Quoted 13 lines · Charles Manning
Hi folks.
I'm tweaking the readdir handling for YAFFS and need to be able to manage a "directory search context" structure where I can stash the context.
ie.
/* user prog and corresponding YAFFS operation */
opendir(..); /* YAFFS needs to create a search context */
readdir(...); /* YAFFS needs to use the search context */
Quoted 9 lines
closedir(...); /* YAFFS needs to release the search context */
I am unsure as to how to hook the opendir and closedir to create/release the directory search context.
Any pointers?
First prize: Any examples?
I think I have found the answer, I'd like anyone to verify that I've got this straight.
The dir operations .open will be called during opendir, allowing me to hang a context off filp->private_data.
The dir operations .release will be called during the closedir allowing me to release the context.
Is that safe?
Are there any hungry wolves out there going to bite me if I work to the above?
Thanx
-- Charles
Hi,
Quoted 2 lines
The dir operations .open will be called during opendir, allowing me to hang a context off
filp->private_data.
If I am not wrong, e.g. EXT3 does it in readdir. It checks whether filp->private_data == NULL and so decides if it is called for the first time (because it is deallocated only in the .release)
We do the same in our fs.
Tomas