* FS Structs
@ 2001-05-03 21:29 Anders Karlsson
2001-05-04 14:07 ` Anton Altaparmakov
0 siblings, 1 reply; 2+ messages in thread
From: Anders Karlsson @ 2001-05-03 21:29 UTC (permalink / raw)
To: LKML
Hello,
Many thanks for a very good and solid piece of software in the Linux
kernel. It has been very useful to me for several years now.
I am not subscribed to the list, so if I could be CC'd on eventual
replies I would be grateful.
I have a question regarding some of the parts of the overall
filesystem structure in the 2.4 kernel. (Kernel 2.4.[34].)
In the file fs/super.c the structure `sb' is used, that is the
superblock. As a part of that structure (reference include/linux/fs.h)
is `struct list_head s_locked_inodes;'.
The thing I can not understand at the moment is the `struct list_head'
(reference include/linux/list.h) which looks very odd. How can I find
which inodes are in the `s_locked_inodes' list?? All I want to do is
to loop through the list and see each open inode in turn, is there any
documentation for this, or is there any helpful soul out there that
could give me any pointers?
Many thanks in advance,
--
Anders Karlsson
e-mail: anders.karlsson@meansolutions.com
*** PGP Encrypted E-Mail Is Prefered - PGP Key On Request ***
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: FS Structs
2001-05-03 21:29 FS Structs Anders Karlsson
@ 2001-05-04 14:07 ` Anton Altaparmakov
0 siblings, 0 replies; 2+ messages in thread
From: Anton Altaparmakov @ 2001-05-04 14:07 UTC (permalink / raw)
To: Anders Karlsson; +Cc: LKML
At 22:29 03/05/01, Anders Karlsson wrote:
>I am not subscribed to the list, so if I could be CC'd on eventual
>replies I would be grateful.
Sure.
>I have a question regarding some of the parts of the overall
>filesystem structure in the 2.4 kernel. (Kernel 2.4.[34].)
>In the file fs/super.c the structure `sb' is used, that is the
>superblock. As a part of that structure (reference include/linux/fs.h)
>is `struct list_head s_locked_inodes;'.
>
>The thing I can not understand at the moment is the `struct list_head'
>(reference include/linux/list.h) which looks very odd. How can I find
>which inodes are in the `s_locked_inodes' list?? All I want to do is
>to loop through the list and see each open inode in turn, is there any
>documentation for this, or is there any helpful soul out there that
>could give me any pointers?
This is how Linux kernel implements generic, circular, doubly-linked lists.
The struct list_head is used both as the beginning of the list - i.e. for
example sb->s_dirty is the beginning of the list of dirty inodes - and also
as the anchor into the list of each dirty inode - i.e. looking at the
struct inode it contains a field struct list_head i_list. This is the
anchor into the list.
To walk the list you usually use list_for_each(). In the above example you
would use:
struct list_head *tmp;
struct inode *ino;
list_for_each(tmp, &sb->s_dirty) {
ino = list_entry(tmp, struct inode, i_list);
/* do what you want with the inode */
}
If that wasn't clear enough you should consider reading up on this subject.
For example "Linux Kernel Internals" contains a chapter on the Linux kernel
linked list implementation. The URL for the online version
is: http://www.moses.uklinux.net/patches/lki.html
Hope this helps,
Anton
--
Anton Altaparmakov <aia21 at cam.ac.uk> (replace at with @)
Linux NTFS Maintainer / WWW: http://sourceforge.net/projects/linux-ntfs/
ICQ: 8561279 / WWW: http://www-stu.christs.cam.ac.uk/~aia21/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-05-04 14:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-03 21:29 FS Structs Anders Karlsson
2001-05-04 14:07 ` Anton Altaparmakov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®