Add a function to return the virtual offset in the virtdir_t tree.

This commit is contained in:
agc 2007-05-19 06:15:38 +00:00
parent 57451082bc
commit c048d63924
2 changed files with 9 additions and 0 deletions

View File

@ -156,6 +156,13 @@ virtdir_find(virtdir_t *tp, const char *name, size_t namelen)
return bsearch(&e, tp->v, tp->c, sizeof(tp->v[0]), compare); return bsearch(&e, tp->v, tp->c, sizeof(tp->v[0]), compare);
} }
/* return the virtual offset in the tree */
int
virtdir_offset(virtdir_t *tp, virt_dirent_t *dp)
{
return (int)((dp - tp->v));
}
/* analogous to opendir(3) - open a directory, save information, and /* analogous to opendir(3) - open a directory, save information, and
* return a pointer to the dynamically allocated structure */ * return a pointer to the dynamically allocated structure */
VIRTDIR * VIRTDIR *

View File

@ -75,4 +75,6 @@ VIRTDIR *openvirtdir(virtdir_t *, const char *);
virt_dirent_t *readvirtdir(VIRTDIR *); virt_dirent_t *readvirtdir(VIRTDIR *);
void closevirtdir(VIRTDIR *); void closevirtdir(VIRTDIR *);
int virtdir_offset(virtdir_t *, virt_dirent_t *);
#endif #endif