current->fs->root vs. current->fs->altroot

current->fs->root vs. current->fs->altroot

Post by Torsten Foertsc » Sat, 22 Mar 2003 12:30:07



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

can someone please explain the difference between a task's root and altroot.

Thanks,
Torsten
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE+euaMwicyCTir8T4RAjaeAJ43cQV+a0RGLXZXQ70W2F7nzPomCACgozD0
+fsb6V7+DFxmTTox2Wxqqus=
=4nR8
-----END PGP SIGNATURE-----
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

 
 
 

current->fs->root vs. current->fs->altroot

Post by Andries Brouwe » Sat, 22 Mar 2003 14:50:07



> can someone please explain the difference between a task's root and altroot.

[below a fragment of some old docs:]

A <tt>struct fs_struct</tt> determines the interpretation
of pathnames referred to by a process (and also, somewhat
illogically, contains the umask). The typical reference
is <tt>current->fs</tt>. The definition lives in <tt>fs_struct.h</tt>:
<tscreen><verb>
struct fs_struct {
        atomic_t count;
        rwlock_t lock;
        int umask;
        struct dentry * root, * pwd, * altroot;
        struct vfsmount * rootmnt, * pwdmnt, * altrootmnt;

Quote:};

</verb></tscreen>

Semantics of <tt>root</tt> and <tt>pwd</tt> are clear.
Remains to discuss <tt>altroot</tt>.

<sect1>altroot<p>
In order to support emulation of different operating systems
like BSD and SunOS and Solaris, a small wart has been added
to the <tt>walk_init_root</tt> code that finds the root directory
for a name lookup.

The <tt>altroot</tt> field of an <tt>fs_struct</tt>
is usually NULL. It is a function of the personality
and the current root, and the <tt>sys_personality</tt>
and <tt>sys_chroot</tt> system calls call <tt>set_fs_altroot()</tt>.

The effect is determined at kernel compile time.
One can define <tt>__emul_prefix()</tt> in <tt>&lt;asm/namei.h&gt;</tt>
as some pathname, say <tt>"usr/gnemul/myOS/"</tt>.
The default is NULL, but some architectures have a
definition depending on <tt>current->personality</tt>.
If this prefix is non-NULL, and the corresponding file is found,
then <tt>set_fs_altroot()</tt> will set the <tt>altroot</tt>
and <tt>altrootmnt</tt> fields of <tt>current->fs</tt>
to dentry and vfsmnt of that file.

A subsequent lookup of a pathname starting with '/' will now
first try to use the altroot. If that fails the usual root is used.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in

More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/