Re: finding 'struct vfsmount' by given 'struct super_block'

From: Tigran Aivazian (tigran@veritas.com)
Date: Mon May 08 2000 - 07:42:04 EST


On Mon, 8 May 2000, Andries Brouwer wrote:

> On Mon, May 08, 2000 at 11:47:37AM +0100, Tigran Aivazian wrote:
> > mnt = list_entry(&sb->s_mounts, struct vfsmount, mnt_list);
> >
> > and
> >
> > mnt = list_entry(&sb->s_mounts, struct vfsmount, mnt_instances);
> >
> > and they both point to garbage. I think ->mnt_list is expected to be wrong
> > as it is headed by vfsmntlist.prev and not by &sb->s_mounts but
> > ->mnt_instances should work (judging from add_vfsmnt()), no?
>
> Look at the definition of list_entry in list.h.
> If ptr points to the member field of a struct of type type,
> then list_entry(ptr, type, member) points at the struct itself.
>
> Now &sb->s_mounts points to the s_mounts field of a struct superblock
> and list_entry(&sb->s_mounts, struct superblock, s_mounts)
> would give you sb back again.
>
> But if you delete the & then the second version looks better.

if I do what you suggested, i.e.:

 mnt = list_entry(sb->s_mounts, struct vfsmount, mnt_instances);

then it won't compile because of "cannot convert to a pointer type" error.

Regards,
Tigran

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



This archive was generated by hypermail 2b29 : Mon May 15 2000 - 21:00:11 EST