Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id ; Fri, 21 Mar 2003 07:31:14 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id ; Fri, 21 Mar 2003 07:31:13 -0500 Received: from mailhost.tue.nl ([131.155.2.7]:31763 "EHLO mailhost.tue.nl") by vger.kernel.org with ESMTP id ; Fri, 21 Mar 2003 07:31:12 -0500 Date: Fri, 21 Mar 2003 13:42:13 +0100 From: Andries Brouwer To: Torsten Foertsch Cc: linux-kernel@vger.kernel.org Subject: Re: current->fs->root vs. current->fs->altroot Message-ID: <20030321124213.GA9434@win.tue.nl> References: <200303211116.44735.torsten.foertsch@gmx.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <200303211116.44735.torsten.foertsch@gmx.net> User-Agent: Mutt/1.3.25i Sender: linux-kernel-owner@vger.kernel.org X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2075 Lines: 52 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 struct fs_struct determines the interpretation of pathnames referred to by a process (and also, somewhat illogically, contains the umask). The typical reference is current->fs. The definition lives in fs_struct.h: struct fs_struct { atomic_t count; rwlock_t lock; int umask; struct dentry * root, * pwd, * altroot; struct vfsmount * rootmnt, * pwdmnt, * altrootmnt; }; Semantics of root and pwd are clear. Remains to discuss altroot. altroot

In order to support emulation of different operating systems like BSD and SunOS and Solaris, a small wart has been added to the walk_init_root code that finds the root directory for a name lookup. The altroot field of an fs_struct is usually NULL. It is a function of the personality and the current root, and the sys_personality and sys_chroot system calls call set_fs_altroot(). The effect is determined at kernel compile time. One can define __emul_prefix() in <asm/namei.h> as some pathname, say "usr/gnemul/myOS/". The default is NULL, but some architectures have a definition depending on current->personality. If this prefix is non-NULL, and the corresponding file is found, then set_fs_altroot() will set the altroot and altrootmnt fields of current->fs 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 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/