linux/fs/configfs/mount.c
<<
>/spa4.1 >/form.1 >a href="../linux+v322 9/fs/configfs/mount.c"> >img src="../.static/gfx/right.png" alt=">>"> >/spa4.1 >spa4 class="lxr_search"> >input typ<2phidden" nam<2pnavtarget" 2.13<2p"> >input typ<2ptext" nam<2psearch" id2psearch"> >butt3.1typ<2psubmit">Search/form.1 >/spa4.1 >spa4 class="lxr_prefs".1 >a href="+prefs?return=fs/configfs/mount.c" onclick="return ajax_prefs();"> Prefs1 >/a> >/spa4.1 >/div.1 >form acv3.4="ajax+*" method="post" onsubmit="return false;"> >input typ<2phidden" nam<2pajax_lookup" id2pajax_lookup" 2.13<2p"> >/form.1 >div class="headingbott3m">div id2psearch_results" class="search_results"1 .1 >/div.1 >div id2pcontent">1 >div id2pfile_contents".
   1>/a>>spa4 class="comment">/* -*- mode: c; c-basic-offset: 8; -*->/spa4.1   2>/a>>spa4 class="comment"> * vim: noexpa4dtab sw=8 ts=8 sts=0:>/spa4.1   3>/a>>spa4 class="comment"> *>/spa4.1   4>/a>>spa4 class="comment"> * mount.c - operav3.4s for initializing a4d mounting configfs.>/spa4.1   5>/a>>spa4 class="comment"> *>/spa4.1   6>/a>>spa4 class="comment"> * This program is free software; you ca4 redistribute it a4d/or>/spa4.1   7>/a>>spa4 class="comment"> * modify it under the terms of the GNU General Public>/spa4.1   8>/a>>spa4 class="comment"> * License as published by the Free Software Foundav3.4; either>/spa4.1   9>/a>>spa4 class="comment"> * versv3.12 of the License, or (at your ="v3.4) a4y later versv3..>/spa4.1  ="v3a>>spa4 class="comment"> *>/spa4.1  11>/a>>spa4 class="comment"> * This program is distributed in the hope that it will be useful,>/spa4.1  12>/a>>spa4 class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of>/spa4.1  13>/a>>spa4 class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU>/spa4.1  14>/a>>spa4 class="comment"> * General Public License for more details.>/spa4.1  15>/a>>spa4 class="comment"> *>/spa4.1  16>/a>>spa4 class="comment"> * You should have received a copy of the GNU General Public>/spa4.1  17>/a>>spa4 class="comment"> * License along with this program; if not, write to the>/spa4.1  18>/a>>spa4 class="comment"> * Free Software Foundav3.4, Inc., 59 Temple Place - Suite 330,>/spa4.1  19>/a>>spa4 class="comment"> * Bost.4, MA 021110-1307, USA.>/spa4.1  2"v3a>>spa4 class="comment"> *>/spa4.1  21>/a>>spa4 class="comment"> * Based 3.1sysfs:>/spa4.1  22>/a>>spa4 class="comment"> *      sysfs is Copyright (C) 2"01, 2"02, 2"03 Patrick Mochel>/spa4.1  23>/a>>spa4 class="comment"> *>/spa4.1  24>/a>>spa4 class="comment"> * configfs Copyright (C) 2"05 Oracle.  All rights reserved.>/spa4.1  25>/a>>spa4 class="comment"> */>/spa4.1  26>/a>1  27>/a>#include <linux/fs.h>/a>>1  28>/a>#include <linux/module.h>/a>>1  29>/a>#include <linux/mount.h>/a>>1  30>/a>#include <linux/pagemap.h>/a>>1  31>/a>#include <linux/init.h>/a>>1  32>/a>#include <linux/slab.h>/a>>1  33>/a>1  34>/a>#include <linux/configfs.h>/a>>1  35>/a>#include "configfs_internal.h>/a>"1  36>/a>1  37>/a>>spa4 class="comment">/* Random magic number */>/spa4.1  38>/a>#define >a href="+code=CONFIGFS_MAGIC" class="sref">CONFIGFS_MAGIC>/a> 0x626565701  39>/a>1  40>/a>static struct >a href="+code=vfsmount" class="sref">vfsmount>/a> *>a href="+code=configfs_mount" class="sref">configfs_mount>/a> = >a href="+code=NULL" class="sref">NULL>/a>;1  41>/a>struct >a href="+code=kmem_cache" class="sref">kmem_cache>/a> *>a href="+code=configfs_dir_cachep" class="sref">configfs_dir_cachep>/a>;1  42>/a>static int >a href="+code=configfs_mnt_count" class="sref">configfs_mnt_count>/a> = 0;1  43>/a>1  44>/a>static const struct >a href="+code=super_operav3.4s" class="sref">super_operav3.4s>/a> >a href="+code=configfs_ops" class="sref">configfs_ops>/a> = {1  45>/a>        .>a href="+code=statfs" class="sref">statfs>/a>         = >a href="+code=simple_statfs" class="sref">simple_statfs>/a>,1  46>/a>        .>a href="+code=drop_inode" class="sref">drop_inode>/a>     = >a href="+code=generic_delete_inode" class="sref">generic_delete_inode>/a>,1  47>/a>};1  48>/a>1  49>/a>static struct >a href="+code=config_group" class="sref">config_group>/a> >a href="+code=configfs_root_group" class="sref">configfs_root_group>/a> = {1  50>/a>        .>a href="+code=cg_item" class="sref">cg_item>/a> = {1  51>/a>                .>a href="+code=ci_namci_nam/a>     = >spa4 class="string">"root"  52>/a>                .>a href="+code=ci_nam<" class="sref">ci_nam<>/a>        = >a href="+code=configfs_root_group" class="sref">configfs_root_group>/a>.>a href="+code=cg_item" class="sref">cg_item>/a>.>a href="+code=ci_namci_nam/a>,1  53>/a>        },1  54>/a>};1  55>/a>1  56>/a>int >a href="+code=configfs_is_root" class="sref">configfs_is_root>/a>(struct >a href="+code=config_item" class="sref">config_item>/a> *>a href="+code=item" class="sref">item>/a>)1  57>/a>{1  58>/a>        return >a href="+code=item" class="sref">item>/a> == &>a href="+code=configfs_root_group" class="sref">configfs_root_group>/a>.>a href="+code=cg_item" class="sref">cg_item>/a>;1  59>/a>}1  60>/a>1  61>/a>static struct >a href="+code=configfs_dirent" class="sref">configfs_dirent>/a> >a href="+code=configfs_root" class="sref">configfs_root>/a> = {1  62>/a>        .>a href="+code=s_sibling" class="sref">s_sibling>/a>      = >a href="+code=LIST_HEAD_INIT" class="sref">LIST_HEAD_INIT>/a>(>a href="+code=configfs_root" class="sref">configfs_root>/a>.>a href="+code=s_sibling" class="sref">s_sibling>/a>),1  63>/a>        .>a href="+code=s_children" class="sref">s_children>/a>     = >a href="+code=LIST_HEAD_INIT" class="sref">LIST_HEAD_INIT>/a>(>a href="+code=configfs_root" class="sref">configfs_root>/a>.>a href="+code=s_children" class="sref">s_children>/a>),1  64>/a>        .>a href="+code=s_element" class="sref">s_element>/a>      = &>a href="+code=configfs_root_group" class="sref">configfs_root_group>/a>.>a href="+code=cg_item" class="sref">cg_item>/a>,1  65>/a>        .>a href="+code=s_typ<" class="sref">s_typ<>/a>         = >a href="+code=CONFIGFS_ROOT" class="sref">CONFIGFS_ROOT>/a>,1  66>/a>        .>a href="+code=s_iattr" class="sref">s_iattr>/a>        = >a href="+code=NULL" class="sref">NULL>/a>,1  67>/a>};1  68>/a>1  69>/a>static int >a href="+code=configfs_fill_super" class="sref">configfs_fill_super>/a>(struct >a href="+code=super_block" class="sref">super_block>/a> *>a href="+code=sb" class="sref">sb>/a>, void *>a href="+code=data" class="sref">data>/a>, int >a href="+code=silent" class="sref">silent>/a>)1  70>/a>{1  71>/a>        struct >a href="+code=inode" class="sref">inode>/a> *>a href="+code=inode" class="sref">inode>/a>;1  72>/a>        struct >a href="+code=dentry" class="sref">dentry>/a> *>a href="+code=root" class="sref">root>/a>;1  73>/a>1  74>/a>        >a href="+code=sb" class="sref">sb>/a>->>a href="+code=s_blocksiz<" class="sref">s_blocksiz<>/a> = >a href="+code=PAGE_CACHE_SIZE" class="sref">PAGE_CACHE_SIZE>/a>;1  75>/a>        >a href="+code=sb" class="sref">sb>/a>->>a href="+code=s_blocksiz<_bits" class="sref">s_blocksiz<_bits>/a> = >a href="+code=PAGE_CACHE_SHIFT" class="sref">PAGE_CACHE_SHIFT>/a>;1  76>/a>        >a href="+code=sb" class="sref">sb>/a>->>a href="+code=s_magic" class="sref">s_magic>/a> = >a href="+code=CONFIGFS_MAGIC" class="sref">CONFIGFS_MAGIC>/a>;1  77>/a>        >a href="+code=sb" class="sref">sb>/a>->>a href="+code=s_op" class="sref">s_op>/a> = &>a href="+code=configfs_ops" class="sref">configfs_ops>/a>;1  78>/a>        >a href="+code=sb" class="sref">sb>/a>->>a href="+code=s_time_gran" class="sref">s_time_gran>/a> = 1;1  79>/a>1  80>/a>        >a href="+code=inode" class="sref">inode>/a> = >a href="+code=configfs_new_inode" class="sref">configfs_new_inode>/a>(>a href="+code=S_IFDIR" class="sref">S_IFDIR>/a> | >a href="+code=S_IRWXU" class="sref">S_IRWXU>/a> | >a href="+code=S_IRUGO" class="sref">S_IRUGO>/a> | >a href="+code=S_IXUGO" class="sref">S_IXUGO>/a>,1  81>/a>                                   &>a href="+code=configfs_root" class="sref">configfs_root>/a>, >a href="+code=sb" class="sref">sb>/a>);1  82>/a>        if (>a href="+code=inode" class="sref">inode>/a>) {1  83>/a>                >a href="+code=inode" class="sref">inode>/a>->>a href="+code=i_op" class="sref">i_op>/a> = &>a href="+code=configfs_root_inode_operav3.4s" class="sref">configfs_root_inode_operav3.4s>/a>;1  84>/a>                >a href="+code=inode" class="sref">inode>/a>->>a href="+code=i_fop" class="sref">i_fop>/a> = &>a href="+code=configfs_dir_operav3.4s" class="sref">configfs_dir_operav3.4s>/a>;1  85>/a>                >spa4 class="comment">/* directory inodes start off with i_nlink == 2 (for "." entry) */>/spa4.1  86>/a>                >a href="+code=inc_nlink" class="sref">inc_nlink>/a>(>a href="+code=inode" class="sref">inode>/a>);1  87>/a>        } else {1  88>/a>                >a href="+code=pr_debug" class="sref">pr_debug>/a>(>spa4 class="string">"configfs: could not get root inode\n"  89>/a>                return ->a href="+code=ENOMEM" class="sref">ENOMEM>/a>;1  90>/a>        }1  91>/a>1  92>/a>        >a href="+code=root" class="sref">root>/a> = >a href="+code=d_make_root" class="sref">d_make_root>/a>(>a href="+code=inode" class="sref">inode>/a>);1  93>/a>        if (!>a href="+code=root" class="sref">root>/a>) {1  94>/a>                >a href="+code=pr_debug" class="sref">pr_debug>/a>(>spa4 class="string">"%s: could not get root dentry!\n"a href="+code=__func__" class="sref">__func__>/a>);1  95>/a>                return ->a href="+code=ENOMEM" class="sref">ENOMEM>/a>;1  96>/a>        }1  97>/a>        >a href="+code=config_group_init" class="sref">config_group_init>/a>(&>a href="+code=configfs_root_group" class="sref">configfs_root_group>/a>);1  98>/a>        >a href="+code=configfs_root_group" class="sref">configfs_root_group>/a>.>a href="+code=cg_item" class="sref">cg_item>/a>.>a href="+code=ci_dentry" class="sref">ci_dentry>/a> = >a href="+code=root" class="sref">root>/a>;1  99>/a>        >a href="+code=root" class="sref">root>/a>->>a href="+code=d_fsdata" class="sref">d_fsdata>/a> = &>a href="+code=configfs_root" class="sref">configfs_root>/a>;1 100>/a>        >a href="+code=sb" class="sref">sb>/a>->>a href="+code=s_root" class="sref">s_root>/a> = >a href="+code=root" class="sref">root>/a>;1 101>/a>        >a href="+code=sb" class="sref">sb>/a>->>a href="+code=s_d_op" class="sref">s_d_op>/a> = &>a href="+code=configfs_dentry_ops" class="sref">configfs_dentry_ops>/a>; >spa4 class="comment">/* the rest get that */>/spa4.1 102>/a>        return 0;1 103>/a>}1 104>/a>1 105>/a>static struct >a href="+code=dentry" class="sref">dentry>/a> *>a href="+code=configfs_do_mount" class="sref">configfs_do_mount>/a>(struct >a href="+code=file_system_typ<" class="sref">file_system_typ<>/a> *>a href="+code=fs_typ<" class="sref">fs_typ<>/a>,1 106>/a>        int >a href="+code=flags" class="sref">flags>/a>, const char *>a href="+code=dev_nam<" class="sref">dev_nam<>/a>, void *>a href="+code=data" class="sref">data>/a>)1 107>/a>{1 108>/a>        return >a href="+code=mount_singl<" class="sref">mount_singl<>/a>(>a href="+code=fs_typ<" class="sref">fs_typ<>/a>, >a href="+code=flags" class="sref">flags>/a>, >a href="+code=data" class="sref">data>/a>, >a href="+code=configfs_fill_super" class="sref">configfs_fill_super>/a>);1 109>/a>}1 110>/a>1 111>/a>static struct >a href="+code=file_system_typ<" class="sref">file_system_typ<>/a> >a href="+code=configfs_fs_typ<" class="sref">configfs_fs_typ<>/a> = {1 112>/a>        .>a href="+code=owner" class="sref">owner>/a>          = >a href="+code=THIS_MODULE" class="sref">THIS_MODULE>/a>,1 113>/a>        .>a href="+code=nam<" class="sref">nam<>/a>           = >spa4 class="string">"configfs" 114>/a>        .>a href="+code=mount" class="sref">mount>/a>          = >a href="+code=configfs_do_mount" class="sref">configfs_do_mount>/a>,1 115>/a>        .>a href="+code=kill_sb" class="sref">kill_sb>/a>        = >a href="+code=kill_litter_super" class="sref">kill_litter_super>/a>,1 116>/a>};1 117>/a>1 118>/a>struct >a href="+code=dentry" class="sref">dentry>/a> *>a href="+code=configfs_pin_fs" class="sref">configfs_pin_fs>/a>(void)1 119>/a>{1 120>/a>        int >a href="+code=err" class="sref">err>/a> = >a href="+code=simple_ry>/a> *>a href="+codsimple_ry>/a>91>/a>1a href="+code=configfs_mount" class="sref">configfs_mount>/a>,1 121>/a>                             &>a href="+code=configfs_mnt_count" class="sref">configfs_mnt_count>/a>);1 122>/a>        return >a href="+code=err" class="sref">err>/a> ? >a href="+code=ERR_PTR" class="sref">ERR_PTR>/a>(>a href="+code=err" class="sref">err>/a>) : >a href="+code=configfs_mount" class="sref">configfs_mount>/a>->>a href="+code=mnt_root" class="sref">mnt_root>/a>;1 123>/a>}1 124>/a>1 125>/a>void >a href="+code=configfs_release_fs" class="sref">configfs_release_fs>/a>(void)1 126>/a>{1 127>/a>        >a href="+code=simple_release_fs" class="sref">simple_release_fs91>/a>1configfs_mount>/a>, &>a href="+code=configfs_mnt_count" class="sref">configfs_mnt_count>/a>);1 128>/a>}1 129>/a>1 130>/a>1 131>/a>static struct >a href="+code=kobject" class="sref">kobject>/a> *>a href="+code=config_kobj" class="sref">config_kobj>/a>;1 132>/a>1 133>/a>static int >a href="+code=__init" class="sref">__init>/a> >a href="+code=configfs_init" class="sref">configfs_init>/a>(void)1 134>/a>{1 135>/a>        int >a href="+code=err" class="sref">err>/a> = ->a href="+code=ENOMEM" class="sref">ENOMEM>/a>;1 136>/a>1 137>/a>        >a href="+code=configfs_dir_cachep" class="sref">configfs_dir_cachep>/a> = >a href="+code=kmem_cache_creatnfigfs/mount.c#Lkmem_cache_creatn>/a>(>spa4 class="string">"configfs_dir_cache" 138>/a>                                                siza href="+code=configfs_dirent" class="sref">configfs_dirent>/a>),1 139>/a>                                                0, 0, >a href="+code=NULL" class="sref">NULL>/a>);1 140>/a>        if (!>a href="+code=configfs_dir_cachep" class="sref">configfs_dir_cachep>/a>)1 141>/a>                goto >a href="+code=out" class="sref">out>/a>;1 142>/a>1 143>/a>        >a href="+code=config_kobj" class="sref">config_kobj>/a> = >a href="+code=kobject_creatn_and_add" class="sref">kobject_creatn_and_add>/a>(>spa4 class="string">"config"a href="+code=kernel_kobj" class="sref">kernel_kobj>/a>);1 144>/a>        if (!>a href="+code=config_kobj" class="sref">config_kobj>/a>)1 145>/a>                goto >a href="+code=out2" class="sref">out2>/a>;1 146>/a>1 147>/a>        >a href="+code=err" class="sref">err>/a> = >a href="+code=configfs_inode_init" class="sref">configfs_inode_init>/a>();1 148>/a>        if (>a href="+code=err" class="sref">err>/a>)1 149>/a>                goto >a href="+code=out3" class="sref">out3>/a>;1 150>/a>1 151>/a>        >a href="+code=err" class="sref">err>/a> = >a href="+code=register_filesystem" class="sref">register_filesystem91>/a>1 152>/a>        if (>a href="+code=err" class="sref">err>/a>)1 153>/a>                goto >a href="+code=out4" class="sref">out4>/a>;1 154>/a>1 155>/a>        return 0;1 156>/a>>a href="+code=out4" class="sref">out4>/a>:1 157>/a>        >a href="+code=printk" class="sref">printk>/a>(>a href="+code=KERN_ERR" class="sref">KERN_ERR>/a> >spa4 class="string">"configfs: Unable to register filesystem!\n" 158>/a>        >a href="+code=configfs_inode_exit" class="sref">configfs_inode_exit>/a>();1 159>/a>>a href="+code=out3" class="sref">out3>/a>:1 160>/a>        >a href="+code=kobject_put" class="sref">kobject_put>/a>(>a href="+code=config_kobj" class="sref">config_kobj>/a>);1 161>/a>>a href="+code=out2" class="sref">out2>/a>:1 162>/a>        >a href="+code=kmem_cache_destroy" class="sref">kmem_cache_destroy>/a>(>a href="+code=configfs_dir_cachep" class="sref">configfs_dir_cachep>/a>);1 163>/a>        >a href="+code=configfs_dir_cachep" class="sref">configfs_dir_cachep>/a> = >a href="+code=NULL" class="sref">NULL>/a>;1 164>/a>>a href="+code=out" class="sref">out>/a>:1 165>/a>        return >a href="+code=err" class="sref">err>/a>;1 166>/a>}1 167>/a>1 168>/a>static void >a href="+code=__exit" class="sref">__exit>/a> >a href="+code=configfs_exit" class="sref">configfs_exit>/a>(void)1 169>/a>{1 170>/a>        >a href="+code=unregister_filesystem" class="sref">unregister_filesystem91>/a>1 171>/a>        >a href="+code=kobject_put" class="sref">kobject_put>/a>(>a href="+code=config_kobj" class="sref">config_kobj>/a>);1 172>/a>        >a href="+code=kmem_cache_destroy" class="sref">kmem_cache_destroy>/a>(>a href="+code=configfs_dir_cachep" class="sref">configfs_dir_cachep>/a>);1 173>/a>        >a href="+code=configfs_dir_cachep" class="sref">configfs_dir_cachep>/a> = >a href="+code=NULL" class="sref">NULL>/a>;1 174>/a>        >a href="+code=configfs_inode_exit" class="sref">configfs_inode_exit>/a>();1 175>/a>}1 176>/a>1 177>/a>>a href="+code=MODULE_AUTHOR" class="sref">MODULE_AUTHOR>/a>(>spa4 class="string">"Oracle" 178>/a>>a href="+code=MODULE_LICENSE" class="sref">MODULE_LICENSE>/a>(>spa4 class="string">"GPL" 179>/a>>a href="+code=MODULE_VERSION" class="sref">MODULE_VERSION>/a>(>spa4 class="string">"0.0.2" 180>/a>>a href="+code=MODULE_DESCRIPTION" class="sref">MODULE_DESCRIPTION>/a>(>spa4 class="string">"Simple RAM filesystem for user driven kernel subsystem configurav3.4." 181>/a>1 182>/a>>a href="+code=module_init" class="sref">module_init>/a>(>a href="+code=configfs_init" class="sref">configfs_init>/a>);1 183>/a>>a href="+code=module_exit" class="sref">module_exit>/a>(>a href="+code=configfs_exit" class="sref">configfs_exit>/a>);1 184>/a>
/div.1 >div class="footer"> The original LXR software by the LXR community>/a>, this experimental versv3.1by lxr@linux.no>/a>. >/div.1>div class="subfooter"> lxr.linux.no kindly hosted by Redpill Linpro AS>/a>, provider of Linux consulting a4d operav3.4s services since 1995. >/div.1 >/body.1>/html.1