lkml.org 
[lkml]   [2007]   [Sep]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Subject[PATCH 01/22] sysfs: make sysfs_root a pointer
    Date
    From
    In the upcoming new sysfs interface, sysfs_root will be exported.  To
    ease usage and make dummy declaration easier, make sysfs_root a
    pointer.

    Signed-off-by: Tejun Heo <htejun@gmail.com>
    ---
    fs/sysfs/dir.c | 4 ++--
    fs/sysfs/mount.c | 8 +++++---
    fs/sysfs/symlink.c | 2 +-
    fs/sysfs/sysfs.h | 2 +-
    4 files changed, 9 insertions(+), 7 deletions(-)

    diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
    index fe8270c..ba631eb 100644
    --- a/fs/sysfs/dir.c
    +++ b/fs/sysfs/dir.c
    @@ -651,7 +651,7 @@ int sysfs_create_dir(struct kobject * kobj)
    if (kobj->parent)
    parent_sd = kobj->parent->sd;
    else
    - parent_sd = &sysfs_root;
    + parent_sd = sysfs_root;

    error = create_dir(kobj, parent_sd, kobject_name(kobj), &sd);
    if (!error)
    @@ -832,7 +832,7 @@ int sysfs_move_dir(struct kobject *kobj, struct kobject *new_parent_kobj)

    mutex_lock(&sysfs_rename_mutex);
    BUG_ON(!sd->s_parent);
    - new_parent_sd = new_parent_kobj->sd ? new_parent_kobj->sd : &sysfs_root;
    + new_parent_sd = new_parent_kobj->sd ? new_parent_kobj->sd : sysfs_root;

    error = 0;
    if (sd->s_parent == new_parent_sd)
    diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
    index 465902c..d00d4b9 100644
    --- a/fs/sysfs/mount.c
    +++ b/fs/sysfs/mount.c
    @@ -23,7 +23,7 @@ static const struct super_operations sysfs_ops = {
    .drop_inode = generic_delete_inode,
    };

    -struct sysfs_dirent sysfs_root = {
    +static struct sysfs_dirent sysfs_root_storage = {
    .s_name = "",
    .s_count = ATOMIC_INIT(1),
    .s_flags = SYSFS_DIR,
    @@ -31,6 +31,8 @@ struct sysfs_dirent sysfs_root = {
    .s_ino = 1,
    };

    +struct sysfs_dirent * const sysfs_root = &sysfs_root_storage;
    +
    static int sysfs_fill_super(struct super_block *sb, void *data, int silent)
    {
    struct inode *inode;
    @@ -44,7 +46,7 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent)
    sysfs_sb = sb;

    /* get root inode, initialize and unlock it */
    - inode = sysfs_get_inode(&sysfs_root);
    + inode = sysfs_get_inode(sysfs_root);
    if (!inode) {
    pr_debug("sysfs: could not get root inode\n");
    return -ENOMEM;
    @@ -57,7 +59,7 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent)
    iput(inode);
    return -ENOMEM;
    }
    - root->d_fsdata = &sysfs_root;
    + root->d_fsdata = sysfs_root;
    sb->s_root = root;
    return 0;
    }
    diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
    index ffa82e9..6b3358e 100644
    --- a/fs/sysfs/symlink.c
    +++ b/fs/sysfs/symlink.c
    @@ -61,7 +61,7 @@ int sysfs_create_link(struct kobject * kobj, struct kobject * target, const char
    BUG_ON(!name);

    if (!kobj)
    - parent_sd = &sysfs_root;
    + parent_sd = sysfs_root;
    else
    parent_sd = kobj->sd;

    diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
    index 58f517b..9180e2c 100644
    --- a/fs/sysfs/sysfs.h
    +++ b/fs/sysfs/sysfs.h
    @@ -78,7 +78,7 @@ struct sysfs_addrm_cxt {
    /*
    * mount.c
    */
    -extern struct sysfs_dirent sysfs_root;
    +extern struct sysfs_dirent * const sysfs_root;
    extern struct super_block *sysfs_sb;
    extern struct kmem_cache *sysfs_dir_cachep;

    --
    1.5.0.3

    -
    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/

    \
     
     \ /
      Last update: 2007-09-20 10:11    [W:0.035 / U:63.172 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site