From: Andries Brouwer <aebr@win.tue.nl>
To: Torsten Foertsch <torsten.foertsch@gmx.net>
Cc: linux-kernel@vger.kernel.org
Subject: Re: current->fs->root vs. current->fs->altroot
Date: Fri, 21 Mar 2003 13:42:13 +0100 [thread overview]
Message-ID: <20030321124213.GA9434@win.tue.nl> (raw)
In-Reply-To: <200303211116.44735.torsten.foertsch@gmx.net>
On Fri, Mar 21, 2003 at 11:16:41AM +0100, Torsten Foertsch wrote:
> 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;
};
</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><asm/namei.h></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.
prev parent reply other threads:[~2003-03-21 12:31 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-03-21 10:16 Torsten Foertsch
2003-03-21 12:42 ` Andries Brouwer [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030321124213.GA9434@win.tue.nl \
--to=aebr@win.tue.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=torsten.foertsch@gmx.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®