Re: How does the kernel maintains the cwd for the processes ??

From: Urban Widmark (urban@svenskatest.se)
Date: Sun Jul 30 2000 - 06:09:39 EST


On Sat, 29 Jul 2000, Rahul Shrivastava wrote:

> hi all,
> I am a newcomer to the world of linux. I have few queries which i guess u
> could explain.
>
> 1) how does the kernel maintain the cwd for a process ?
> 2) how is the 'cd' command implemented in the kernel?
> 3) which are the related files ?

cd is a built-in shell command. The syscall used to change directory is
chdir (fchdir). You can find sys_chdir in fs/open.c.

This bit sets the cwd (pwd) to the 'dentry' corresponding to the filename
given as argument to sys_chdir.

        /* exchange dentries */
        tmp = current->fs->pwd;
        current->fs->pwd = dentry;
        dentry = tmp;

current is a 'struct task_struct' and you can find it in
include/linux/sched.h

Links to various documents on the kernel:
    http://jungla.dit.upm.es/~jmseyas/linux/kernel/hackers-docs.html

What is a dentry? you ask. Try
    http://www.atnf.csiro.au/~rgooch/linux/vfs.txt

And you may also want to check out
    http://www.kernelnewbies.org/

/Urban

-
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 Jul 31 2000 - 21:00:31 EST