* Re: [Re: __asm__ ]
@ 2001-05-23 9:00 Blesson Paul
2001-05-23 10:50 ` David Howells
0 siblings, 1 reply; 3+ messages in thread
From: Blesson Paul @ 2001-05-23 9:00 UTC (permalink / raw)
To: David Howells, linux-kernel
Hi David
Thanks for the reply. I am sorry that I misspelled the
line(__asm__(....)). It is from the get_current() function in
asm-i386/current.h. But I am not clear what is the whole meaning of that
line(__asm__(..)) in get_current(). I am doing a project in Linux related to
VFS. From VFS. this function is called to get the base of the file system. I
am not getting how this function will gave the base of the file system.
get_current() is called from lookup_dentry function.
base=dget(current->fs->root)
Thanks in advance
by
Blesson
____________________________________________________________________
Get free email and a permanent address at http://www.netaddress.com/?N=1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Re: __asm__ ]
@ 2001-05-23 9:33 ÀÌÈ£
0 siblings, 0 replies; 3+ messages in thread
From: ÀÌÈ£ @ 2001-05-23 9:33 UTC (permalink / raw)
To: Blesson Paul, linux-kernel
Blesson Paul Wrote:
> Thanks for the reply. I am sorry that I misspelled the
> line(__asm__(....)). It is from the get_current() function in
> asm-i386/current.h. But I am not clear what is the whole meaning of that
> line(__asm__(..)) in get_current(). I am doing a project in Linux related to
> VFS. From VFS. this function is called to get the base of the file system. I
> am not getting how this function will gave the base of the file system.
> get_current() is called from lookup_dentry function.
> base=dget(current->fs->root)
get_current() returns the pointer to process descriptor
(struct task_struct). Kernel allocates 8KB per each process,
which is used for the process descriptor of process, and
process kernel stack. So masking out 13 LSB of stack
poiniter yields the pointer to process descriptor.
You can find more explanation in the Chapter 3 of
<Understanding the Linux Kernel>
fs field in the process descriptor describes the root directory
and the current working directory of the process. so
current->fs->root is the pointer to the directory entry of
process' root directory.
*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
Lee, Ho. Software Engineer, Embedded Linux Dep, LinuxOne
ICQ : #52017992, Mail : flyduck@linuxone.co.kr, i@flyduck.com
Homepage : http://flyduck.com, http://linuxkernel.to
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Re: __asm__ ]
2001-05-23 9:00 [Re: __asm__ ] Blesson Paul
@ 2001-05-23 10:50 ` David Howells
0 siblings, 0 replies; 3+ messages in thread
From: David Howells @ 2001-05-23 10:50 UTC (permalink / raw)
To: Blesson Paul; +Cc: linux-kernel
Okay,
"current" is a macro on i386 that expands to "get_current()". This gets the
task_struct for the task currently running on the CPU executing the code.
It does this by masking out the bottom bits of its kernel stack pointer.
For example, assuming that some running process has the following task record
stored in an 8KB-aligned 8KB block.
0xD520BFFF +---------------+
| |
| kernel stack |
| |
0xD520B498 +---- TOS ------+ <-- stack pointer: %esp
| |
| empty space |
| |
+---------------+
| |
| task_struct |
| |
0xD520A000 +---------------+ <-- get_current()
get_current() can work out where the base of this block is because the kernel
(1) stack pointer is always within it, (2) it's aligned in memory with respect
to its size:
get_current() { return %esp & ~8191; }
get_current() { return 0xD520B498 & 0xFFFFE000; }
get_current() = 0xD520A000
So "current->fs" is a structure that holds the current task's idea of its root
filesystem (chroot), current working directory (chdir) and current umask.
And so "current->fs->root" is the task's filesystem root dentry.
David
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2001-05-23 10:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-05-23 9:00 [Re: __asm__ ] Blesson Paul
2001-05-23 10:50 ` David Howells
-- strict thread matches above, loose matches on Subject: below --
2001-05-23 9:33 ÀÌÈ£
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox