Commit 7f2da1e7d0330395e5e9e350b879b98a1ea495df

Authored by Al Viro
1 parent 8bb79224b8

[PATCH] kill altroot

long overdue...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Showing 31 changed files with 5 additions and 466 deletions Side-by-side Diff

... ... @@ -31,7 +31,6 @@
31 31 #include <linux/file.h>
32 32 #include <linux/fcntl.h>
33 33 #include <linux/device_cgroup.h>
34   -#include <asm/namei.h>
35 34 #include <asm/uaccess.h>
36 35  
37 36 #define ACC_MODE(x) ("\000\004\002\006"[(x)&O_ACCMODE])
38 37  
39 38  
40 39  
... ... @@ -562,27 +561,16 @@
562 561 return result;
563 562 }
564 563  
565   -static int __emul_lookup_dentry(const char *, struct nameidata *);
566   -
567 564 /* SMP-safe */
568   -static __always_inline int
  565 +static __always_inline void
569 566 walk_init_root(const char *name, struct nameidata *nd)
570 567 {
571 568 struct fs_struct *fs = current->fs;
572 569  
573 570 read_lock(&fs->lock);
574   - if (fs->altroot.dentry && !(nd->flags & LOOKUP_NOALT)) {
575   - nd->path = fs->altroot;
576   - path_get(&fs->altroot);
577   - read_unlock(&fs->lock);
578   - if (__emul_lookup_dentry(name,nd))
579   - return 0;
580   - read_lock(&fs->lock);
581   - }
582 571 nd->path = fs->root;
583 572 path_get(&fs->root);
584 573 read_unlock(&fs->lock);
585   - return 1;
586 574 }
587 575  
588 576 /*
589 577  
... ... @@ -623,12 +611,9 @@
623 611  
624 612 if (*link == '/') {
625 613 path_put(&nd->path);
626   - if (!walk_init_root(link, nd))
627   - /* weird __emul_prefix() stuff did it */
628   - goto out;
  614 + walk_init_root(link, nd);
629 615 }
630 616 res = link_path_walk(link, nd);
631   -out:
632 617 if (nd->depth || res || nd->last_type!=LAST_NORM)
633 618 return res;
634 619 /*
... ... @@ -1077,67 +1062,6 @@
1077 1062 return link_path_walk(name, nd);
1078 1063 }
1079 1064  
1080   -/*
1081   - * SMP-safe: Returns 1 and nd will have valid dentry and mnt, if
1082   - * everything is done. Returns 0 and drops input nd, if lookup failed;
1083   - */
1084   -static int __emul_lookup_dentry(const char *name, struct nameidata *nd)
1085   -{
1086   - if (path_walk(name, nd))
1087   - return 0; /* something went wrong... */
1088   -
1089   - if (!nd->path.dentry->d_inode ||
1090   - S_ISDIR(nd->path.dentry->d_inode->i_mode)) {
1091   - struct path old_path = nd->path;
1092   - struct qstr last = nd->last;
1093   - int last_type = nd->last_type;
1094   - struct fs_struct *fs = current->fs;
1095   -
1096   - /*
1097   - * NAME was not found in alternate root or it's a directory.
1098   - * Try to find it in the normal root:
1099   - */
1100   - nd->last_type = LAST_ROOT;
1101   - read_lock(&fs->lock);
1102   - nd->path = fs->root;
1103   - path_get(&fs->root);
1104   - read_unlock(&fs->lock);
1105   - if (path_walk(name, nd) == 0) {
1106   - if (nd->path.dentry->d_inode) {
1107   - path_put(&old_path);
1108   - return 1;
1109   - }
1110   - path_put(&nd->path);
1111   - }
1112   - nd->path = old_path;
1113   - nd->last = last;
1114   - nd->last_type = last_type;
1115   - }
1116   - return 1;
1117   -}
1118   -
1119   -void set_fs_altroot(void)
1120   -{
1121   - char *emul = __emul_prefix();
1122   - struct nameidata nd;
1123   - struct path path = {}, old_path;
1124   - int err;
1125   - struct fs_struct *fs = current->fs;
1126   -
1127   - if (!emul)
1128   - goto set_it;
1129   - err = path_lookup(emul, LOOKUP_FOLLOW|LOOKUP_DIRECTORY|LOOKUP_NOALT, &nd);
1130   - if (!err)
1131   - path = nd.path;
1132   -set_it:
1133   - write_lock(&fs->lock);
1134   - old_path = fs->altroot;
1135   - fs->altroot = path;
1136   - write_unlock(&fs->lock);
1137   - if (old_path.dentry)
1138   - path_put(&old_path);
1139   -}
1140   -
1141 1065 /* Returns 0 and nd will be valid on success; Retuns error, otherwise. */
1142 1066 static int do_path_lookup(int dfd, const char *name,
1143 1067 unsigned int flags, struct nameidata *nd)
... ... @@ -1153,14 +1077,6 @@
1153 1077  
1154 1078 if (*name=='/') {
1155 1079 read_lock(&fs->lock);
1156   - if (fs->altroot.dentry && !(nd->flags & LOOKUP_NOALT)) {
1157   - nd->path = fs->altroot;
1158   - path_get(&fs->altroot);
1159   - read_unlock(&fs->lock);
1160   - if (__emul_lookup_dentry(name,nd))
1161   - goto out; /* found in altroot */
1162   - read_lock(&fs->lock);
1163   - }
1164 1080 nd->path = fs->root;
1165 1081 path_get(&fs->root);
1166 1082 read_unlock(&fs->lock);
... ... @@ -1194,7 +1110,6 @@
1194 1110 }
1195 1111  
1196 1112 retval = path_walk(name, nd);
1197   -out:
1198 1113 if (unlikely(!retval && !audit_dummy_context() && nd->path.dentry &&
1199 1114 nd->path.dentry->d_inode))
1200 1115 audit_inode(name, nd->path.dentry);
... ... @@ -1972,7 +1972,7 @@
1972 1972 struct fs_struct *fs)
1973 1973 {
1974 1974 struct mnt_namespace *new_ns;
1975   - struct vfsmount *rootmnt = NULL, *pwdmnt = NULL, *altrootmnt = NULL;
  1975 + struct vfsmount *rootmnt = NULL, *pwdmnt = NULL;
1976 1976 struct vfsmount *p, *q;
1977 1977  
1978 1978 new_ns = kmalloc(sizeof(struct mnt_namespace), GFP_KERNEL);
... ... @@ -2015,10 +2015,6 @@
2015 2015 pwdmnt = p;
2016 2016 fs->pwd.mnt = mntget(q);
2017 2017 }
2018   - if (p == fs->altroot.mnt) {
2019   - altrootmnt = p;
2020   - fs->altroot.mnt = mntget(q);
2021   - }
2022 2018 }
2023 2019 p = next_mnt(p, mnt_ns->root);
2024 2020 q = next_mnt(q, new_ns->root);
... ... @@ -2029,8 +2025,6 @@
2029 2025 mntput(rootmnt);
2030 2026 if (pwdmnt)
2031 2027 mntput(pwdmnt);
2032   - if (altrootmnt)
2033   - mntput(altrootmnt);
2034 2028  
2035 2029 return new_ns;
2036 2030 }
... ... @@ -548,7 +548,7 @@
548 548 struct nameidata nd;
549 549 int error;
550 550  
551   - error = __user_walk(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY | LOOKUP_NOALT, &nd);
  551 + error = __user_walk(filename, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, &nd);
552 552 if (error)
553 553 goto out;
554 554  
... ... @@ -561,7 +561,6 @@
561 561 goto dput_and_out;
562 562  
563 563 set_fs_root(current->fs, &nd.path);
564   - set_fs_altroot();
565 564 error = 0;
566 565 dput_and_out:
567 566 path_put(&nd.path);
include/asm-alpha/namei.h
1   -/* $Id: namei.h,v 1.1 1996/12/13 14:48:21 jj Exp $
2   - * linux/include/asm-alpha/namei.h
3   - *
4   - * Included from linux/fs/namei.c
5   - */
6   -
7   -#ifndef __ALPHA_NAMEI_H
8   -#define __ALPHA_NAMEI_H
9   -
10   -/* This dummy routine maybe changed to something useful
11   - * for /usr/gnemul/ emulation stuff.
12   - * Look at asm-sparc/namei.h for details.
13   - */
14   -
15   -#define __emul_prefix() NULL
16   -
17   -#endif /* __ALPHA_NAMEI_H */
include/asm-arm/namei.h
1   -/*
2   - * linux/include/asm-arm/namei.h
3   - *
4   - * Routines to handle famous /usr/gnemul
5   - * Derived from the Sparc version of this file
6   - *
7   - * Included from linux/fs/namei.c
8   - */
9   -
10   -#ifndef __ASMARM_NAMEI_H
11   -#define __ASMARM_NAMEI_H
12   -
13   -#define ARM_BSD_EMUL "usr/gnemul/bsd/"
14   -
15   -static inline char *__emul_prefix(void)
16   -{
17   - switch (current->personality) {
18   - case PER_BSD:
19   - return ARM_BSD_EMUL;
20   - default:
21   - return NULL;
22   - }
23   -}
24   -
25   -#endif /* __ASMARM_NAMEI_H */
include/asm-avr32/namei.h
1   -#ifndef __ASM_AVR32_NAMEI_H
2   -#define __ASM_AVR32_NAMEI_H
3   -
4   -/* This dummy routine may be changed to something useful */
5   -#define __emul_prefix() NULL
6   -
7   -#endif /* __ASM_AVR32_NAMEI_H */
include/asm-blackfin/namei.h
1   -/*
2   - * linux/include/asm/namei.h
3   - *
4   - * Included from linux/fs/namei.c
5   - *
6   - * Changes made by Lineo Inc. May 2001
7   - */
8   -
9   -#ifndef __BFIN_NAMEI_H
10   -#define __BFIN_NAMEI_H
11   -
12   -/* This dummy routine maybe changed to something useful
13   - * for /usr/gnemul/ emulation stuff.
14   - * Look at asm-sparc/namei.h for details.
15   - */
16   -
17   -#define __emul_prefix() NULL
18   -
19   -#endif
include/asm-cris/namei.h
1   -/* $Id: namei.h,v 1.1 2000/07/10 16:32:31 bjornw Exp $
2   - * linux/include/asm-cris/namei.h
3   - *
4   - * Included from linux/fs/namei.c
5   - */
6   -
7   -#ifndef __CRIS_NAMEI_H
8   -#define __CRIS_NAMEI_H
9   -
10   -/* used to find file-system prefixes for doing emulations
11   - * see for example asm-sparc/namei.h
12   - * we don't use it...
13   - */
14   -
15   -#define __emul_prefix() NULL
16   -
17   -#endif /* __CRIS_NAMEI_H */
include/asm-frv/namei.h
1   -/*
2   - * include/asm-frv/namei.h
3   - *
4   - * Included from linux/fs/namei.c
5   - */
6   -
7   -#ifndef __ASM_NAMEI_H
8   -#define __ASM_NAMEI_H
9   -
10   -/* This dummy routine maybe changed to something useful
11   - * for /usr/gnemul/ emulation stuff.
12   - * Look at asm-sparc/namei.h for details.
13   - */
14   -
15   -#define __emul_prefix() NULL
16   -
17   -#endif
include/asm-h8300/namei.h
1   -/*
2   - * linux/include/asm-h8300/namei.h
3   - *
4   - * Included from linux/fs/namei.c
5   - */
6   -
7   -#ifndef __H8300_NAMEI_H
8   -#define __H8300_NAMEI_H
9   -
10   -/* This dummy routine maybe changed to something useful
11   - * for /usr/gnemul/ emulation stuff.
12   - * Look at asm-sparc/namei.h for details.
13   - */
14   -
15   -#define __emul_prefix() NULL
16   -
17   -#endif
include/asm-ia64/namei.h
1   -#ifndef _ASM_IA64_NAMEI_H
2   -#define _ASM_IA64_NAMEI_H
3   -
4   -/*
5   - * Modified 1998, 1999, 2001
6   - * David Mosberger-Tang <davidm@hpl.hp.com>, Hewlett-Packard Co
7   - */
8   -
9   -#include <asm/ptrace.h>
10   -#include <asm/system.h>
11   -
12   -#define EMUL_PREFIX_LINUX_IA32 "/emul/ia32-linux/"
13   -
14   -static inline char *
15   -__emul_prefix (void)
16   -{
17   - switch (current->personality) {
18   - case PER_LINUX32:
19   - return EMUL_PREFIX_LINUX_IA32;
20   - default:
21   - return NULL;
22   - }
23   -}
24   -
25   -#endif /* _ASM_IA64_NAMEI_H */
include/asm-m32r/namei.h
1   -#ifndef _ASM_M32R_NAMEI_H
2   -#define _ASM_M32R_NAMEI_H
3   -
4   -/*
5   - * linux/include/asm-m32r/namei.h
6   - *
7   - * Included from linux/fs/namei.c
8   - */
9   -
10   -/* This dummy routine maybe changed to something useful
11   - * for /usr/gnemul/ emulation stuff.
12   - * Look at asm-sparc/namei.h for details.
13   - */
14   -
15   -#define __emul_prefix() NULL
16   -
17   -#endif /* _ASM_M32R_NAMEI_H */
include/asm-m68k/namei.h
1   -/*
2   - * linux/include/asm-m68k/namei.h
3   - *
4   - * Included from linux/fs/namei.c
5   - */
6   -
7   -#ifndef __M68K_NAMEI_H
8   -#define __M68K_NAMEI_H
9   -
10   -/* This dummy routine maybe changed to something useful
11   - * for /usr/gnemul/ emulation stuff.
12   - * Look at asm-sparc/namei.h for details.
13   - */
14   -
15   -#define __emul_prefix() NULL
16   -
17   -#endif
include/asm-m68knommu/namei.h
1   -#include <asm-m68k/namei.h>
include/asm-mips/namei.h
1   -#ifndef _ASM_NAMEI_H
2   -#define _ASM_NAMEI_H
3   -
4   -/*
5   - * This dummy routine maybe changed to something useful
6   - * for /usr/gnemul/ emulation stuff.
7   - */
8   -
9   -#define __emul_prefix() NULL
10   -
11   -#endif /* _ASM_NAMEI_H */
include/asm-mn10300/namei.h
1   -/* Emulation stuff
2   - *
3   - * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4   - * Written by David Howells (dhowells@redhat.com)
5   - *
6   - * This program is free software; you can redistribute it and/or
7   - * modify it under the terms of the GNU General Public Licence
8   - * as published by the Free Software Foundation; either version
9   - * 2 of the Licence, or (at your option) any later version.
10   - */
11   -
12   -#ifndef _ASM_NAMEI_H
13   -#define _ASM_NAMEI_H
14   -
15   -/* This dummy routine maybe changed to something useful
16   - * for /usr/gnemul/ emulation stuff.
17   - * Look at asm-sparc/namei.h for details.
18   - */
19   -
20   -#define __emul_prefix() NULL
21   -
22   -#endif /* _ASM_NAMEI_H */
include/asm-parisc/namei.h
1   -/* $Id: namei.h,v 1.1 1996/12/13 14:48:21 jj Exp $
2   - * linux/include/asm-parisc/namei.h
3   - *
4   - * Included from linux/fs/namei.c
5   - */
6   -
7   -#ifndef __PARISC_NAMEI_H
8   -#define __PARISC_NAMEI_H
9   -
10   -/* This dummy routine maybe changed to something useful
11   - * for /usr/gnemul/ emulation stuff.
12   - * Look at asm-sparc/namei.h for details.
13   - */
14   -
15   -#define __emul_prefix() NULL
16   -
17   -#endif /* __PARISC_NAMEI_H */
include/asm-powerpc/namei.h
1   -#ifndef _ASM_POWERPC_NAMEI_H
2   -#define _ASM_POWERPC_NAMEI_H
3   -
4   -#ifdef __KERNEL__
5   -
6   -/*
7   - * Adapted from include/asm-alpha/namei.h
8   - *
9   - * Included from fs/namei.c
10   - */
11   -
12   -/* This dummy routine maybe changed to something useful
13   - * for /usr/gnemul/ emulation stuff.
14   - * Look at asm-sparc/namei.h for details.
15   - */
16   -
17   -#define __emul_prefix() NULL
18   -
19   -#endif /* __KERNEL__ */
20   -#endif /* _ASM_POWERPC_NAMEI_H */
include/asm-s390/namei.h
1   -/*
2   - * include/asm-s390/namei.h
3   - *
4   - * S390 version
5   - *
6   - * Derived from "include/asm-i386/namei.h"
7   - *
8   - * Included from linux/fs/namei.c
9   - */
10   -
11   -#ifndef __S390_NAMEI_H
12   -#define __S390_NAMEI_H
13   -
14   -/* This dummy routine maybe changed to something useful
15   - * for /usr/gnemul/ emulation stuff.
16   - * Look at asm-sparc/namei.h for details.
17   - */
18   -
19   -#define __emul_prefix() NULL
20   -
21   -#endif /* __S390_NAMEI_H */
include/asm-sh/namei.h
1   -/* $Id: namei.h,v 1.3 2000/07/04 06:24:49 gniibe Exp $
2   - * linux/include/asm-sh/namei.h
3   - *
4   - * Included from linux/fs/namei.c
5   - */
6   -
7   -#ifndef __ASM_SH_NAMEI_H
8   -#define __ASM_SH_NAMEI_H
9   -
10   -/* This dummy routine maybe changed to something useful
11   - * for /usr/gnemul/ emulation stuff.
12   - * Look at asm-sparc/namei.h for details.
13   - */
14   -
15   -#define __emul_prefix() NULL
16   -
17   -#endif /* __ASM_SH_NAMEI_H */
include/asm-sparc/namei.h
1   -#ifndef ___ASM_SPARC_NAMEI_H
2   -#define ___ASM_SPARC_NAMEI_H
3   -#if defined(__sparc__) && defined(__arch64__)
4   -#include <asm-sparc/namei_64.h>
5   -#else
6   -#include <asm-sparc/namei_32.h>
7   -#endif
8   -#endif
include/asm-sparc64/namei.h
1   -#include <asm-sparc/namei.h>
include/asm-um/namei.h
1   -#ifndef __UM_NAMEI_H
2   -#define __UM_NAMEI_H
3   -
4   -#include "asm/arch/namei.h"
5   -
6   -#endif
include/asm-v850/namei.h
1   -/*
2   - * linux/include/asm-v850/namei.h
3   - *
4   - * Included from linux/fs/namei.c
5   - */
6   -
7   -#ifndef __V850_NAMEI_H__
8   -#define __V850_NAMEI_H__
9   -
10   -/* This dummy routine maybe changed to something useful
11   - * for /usr/gnemul/ emulation stuff.
12   - * Look at asm-sparc/namei.h for details.
13   - */
14   -
15   -#define __emul_prefix() NULL
16   -
17   -#endif /* __V850_NAMEI_H__ */
include/asm-x86/namei.h
1   -#ifndef _ASM_X86_NAMEI_H
2   -#define _ASM_X86_NAMEI_H
3   -
4   -/* This dummy routine maybe changed to something useful
5   - * for /usr/gnemul/ emulation stuff.
6   - * Look at asm-sparc/namei.h for details.
7   - */
8   -
9   -#define __emul_prefix() NULL
10   -
11   -#endif /* _ASM_X86_NAMEI_H */
include/asm-xtensa/namei.h
1   -/*
2   - * include/asm-xtensa/namei.h
3   - *
4   - * Included from linux/fs/namei.c
5   - *
6   - * This file is subject to the terms and conditions of the GNU General Public
7   - * License. See the file "COPYING" in the main directory of this archive
8   - * for more details.
9   - *
10   - * Copyright (C) 2001 - 2005 Tensilica Inc.
11   - */
12   -
13   -#ifndef _XTENSA_NAMEI_H
14   -#define _XTENSA_NAMEI_H
15   -
16   -#ifdef __KERNEL__
17   -
18   -/* This dummy routine maybe changed to something useful
19   - * for /usr/gnemul/ emulation stuff.
20   - * Look at asm-sparc/namei.h for details.
21   - */
22   -
23   -#define __emul_prefix() NULL
24   -
25   -#endif /* __KERNEL__ */
26   -#endif /* _XTENSA_NAMEI_H */
include/linux/fs_struct.h
... ... @@ -7,7 +7,7 @@
7 7 atomic_t count;
8 8 rwlock_t lock;
9 9 int umask;
10   - struct path root, pwd, altroot;
  10 + struct path root, pwd;
11 11 };
12 12  
13 13 #define INIT_FS { \
... ... @@ -19,7 +19,6 @@
19 19 extern struct kmem_cache *fs_cachep;
20 20  
21 21 extern void exit_fs(struct task_struct *);
22   -extern void set_fs_altroot(void);
23 22 extern void set_fs_root(struct fs_struct *, struct path *);
24 23 extern void set_fs_pwd(struct fs_struct *, struct path *);
25 24 extern struct fs_struct *copy_fs_struct(struct fs_struct *);
include/linux/namei.h
... ... @@ -47,7 +47,6 @@
47 47 #define LOOKUP_DIRECTORY 2
48 48 #define LOOKUP_CONTINUE 4
49 49 #define LOOKUP_PARENT 16
50   -#define LOOKUP_NOALT 32
51 50 #define LOOKUP_REVAL 64
52 51 /*
53 52 * Intent data
kernel/exec_domain.c
... ... @@ -168,7 +168,6 @@
168 168 current->personality = personality;
169 169 oep = current_thread_info()->exec_domain;
170 170 current_thread_info()->exec_domain = ep;
171   - set_fs_altroot();
172 171  
173 172 module_put(oep->module);
174 173 return 0;
... ... @@ -565,8 +565,6 @@
565 565 if (atomic_dec_and_test(&fs->count)) {
566 566 path_put(&fs->root);
567 567 path_put(&fs->pwd);
568   - if (fs->altroot.dentry)
569   - path_put(&fs->altroot);
570 568 kmem_cache_free(fs_cachep, fs);
571 569 }
572 570 }
... ... @@ -657,13 +657,6 @@
657 657 path_get(&old->root);
658 658 fs->pwd = old->pwd;
659 659 path_get(&old->pwd);
660   - if (old->altroot.dentry) {
661   - fs->altroot = old->altroot;
662   - path_get(&old->altroot);
663   - } else {
664   - fs->altroot.mnt = NULL;
665   - fs->altroot.dentry = NULL;
666   - }
667 660 read_unlock(&old->lock);
668 661 }
669 662 return fs;