~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/fs/sysfs/mount.c

Version: ~ [ linux-5.19-rc3 ] ~ [ linux-5.18.5 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.48 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.123 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.199 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.248 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.284 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.319 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.302 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  * fs/sysfs/symlink.c - operations for initializing and mounting sysfs
  3  *
  4  * Copyright (c) 2001-3 Patrick Mochel
  5  * Copyright (c) 2007 SUSE Linux Products GmbH
  6  * Copyright (c) 2007 Tejun Heo <teheo@suse.de>
  7  *
  8  * This file is released under the GPLv2.
  9  *
 10  * Please see Documentation/filesystems/sysfs.txt for more information.
 11  */
 12 
 13 #define DEBUG
 14 
 15 #include <linux/fs.h>
 16 #include <linux/magic.h>
 17 #include <linux/mount.h>
 18 #include <linux/init.h>
 19 #include <linux/user_namespace.h>
 20 
 21 #include "sysfs.h"
 22 
 23 static struct kernfs_root *sysfs_root;
 24 struct kernfs_node *sysfs_root_kn;
 25 
 26 static struct dentry *sysfs_mount(struct file_system_type *fs_type,
 27         int flags, const char *dev_name, void *data)
 28 {
 29         struct dentry *root;
 30         void *ns;
 31         bool new_sb;
 32 
 33         if (!(flags & MS_KERNMOUNT)) {
 34                 if (!kobj_ns_current_may_mount(KOBJ_NS_TYPE_NET))
 35                         return ERR_PTR(-EPERM);
 36         }
 37 
 38         ns = kobj_ns_grab_current(KOBJ_NS_TYPE_NET);
 39         root = kernfs_mount_ns(fs_type, flags, sysfs_root,
 40                                 SYSFS_MAGIC, &new_sb, ns);
 41         if (IS_ERR(root) || !new_sb)
 42                 kobj_ns_drop(KOBJ_NS_TYPE_NET, ns);
 43         else if (new_sb)
 44                 root->d_sb->s_iflags |= SB_I_USERNS_VISIBLE;
 45 
 46         return root;
 47 }
 48 
 49 static void sysfs_kill_sb(struct super_block *sb)
 50 {
 51         void *ns = (void *)kernfs_super_ns(sb);
 52 
 53         kernfs_kill_sb(sb);
 54         kobj_ns_drop(KOBJ_NS_TYPE_NET, ns);
 55 }
 56 
 57 static struct file_system_type sysfs_fs_type = {
 58         .name           = "sysfs",
 59         .mount          = sysfs_mount,
 60         .kill_sb        = sysfs_kill_sb,
 61         .fs_flags       = FS_USERNS_MOUNT,
 62 };
 63 
 64 int __init sysfs_init(void)
 65 {
 66         int err;
 67 
 68         sysfs_root = kernfs_create_root(NULL, KERNFS_ROOT_EXTRA_OPEN_PERM_CHECK,
 69                                         NULL);
 70         if (IS_ERR(sysfs_root))
 71                 return PTR_ERR(sysfs_root);
 72 
 73         sysfs_root_kn = sysfs_root->kn;
 74 
 75         err = register_filesystem(&sysfs_fs_type);
 76         if (err) {
 77                 kernfs_destroy_root(sysfs_root);
 78                 return err;
 79         }
 80 
 81         return 0;
 82 }
 83 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp