Re: [Re: __asm__ ]

David Howells (dhowells@redhat.com)
Wed, 23 May 2001 11:50:30 +0100


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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/