[lkml]   [2001]   [May]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
SubjectRe: [Re: __asm__ ]

"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.

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to
More majordomo info at
Please read the FAQ at

 \ /
  Last update: 2005-03-22 12:53    [W:0.043 / U:0.708 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site