@@ -35,12 +35,12 @@ static DEFINE_IDA(sysfs_ino_ida);
3535
3636/**
3737 * sysfs_name_hash
38- * @ns: Namespace tag to hash
3938 * @name: Null terminated string to hash
39+ * @ns: Namespace tag to hash
4040 *
4141 * Returns 31 bit hash of ns + name (so it fits in an off_t )
4242 */
43- static unsigned int sysfs_name_hash (const void * ns , const char * name )
43+ static unsigned int sysfs_name_hash (const char * name , const void * ns )
4444{
4545 unsigned long hash = init_name_hash ();
4646 unsigned int len = strlen (name );
@@ -56,8 +56,8 @@ static unsigned int sysfs_name_hash(const void *ns, const char *name)
5656 return hash ;
5757}
5858
59- static int sysfs_name_compare (unsigned int hash , const void * ns ,
60- const char * name , const struct sysfs_dirent * sd )
59+ static int sysfs_name_compare (unsigned int hash , const char * name ,
60+ const void * ns , const struct sysfs_dirent * sd )
6161{
6262 if (hash != sd -> s_hash )
6363 return hash - sd -> s_hash ;
@@ -69,7 +69,7 @@ static int sysfs_name_compare(unsigned int hash, const void *ns,
6969static int sysfs_sd_compare (const struct sysfs_dirent * left ,
7070 const struct sysfs_dirent * right )
7171{
72- return sysfs_name_compare (left -> s_hash , left -> s_ns , left -> s_name ,
72+ return sysfs_name_compare (left -> s_hash , left -> s_name , left -> s_ns ,
7373 right );
7474}
7575
@@ -451,7 +451,7 @@ int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd)
451451 struct sysfs_inode_attrs * ps_iattr ;
452452 int ret ;
453453
454- sd -> s_hash = sysfs_name_hash (sd -> s_ns , sd -> s_name );
454+ sd -> s_hash = sysfs_name_hash (sd -> s_name , sd -> s_ns );
455455 sd -> s_parent = sysfs_get (acxt -> parent_sd );
456456
457457 ret = sysfs_link_sibling (sd );
@@ -596,6 +596,7 @@ void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt)
596596 * sysfs_find_dirent - find sysfs_dirent with the given name
597597 * @parent_sd: sysfs_dirent to search under
598598 * @name: name to look for
599+ * @ns: the namespace tag to use
599600 *
600601 * Look for sysfs_dirent with name @name under @parent_sd.
601602 *
@@ -606,19 +607,19 @@ void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt)
606607 * Pointer to sysfs_dirent if found, NULL if not.
607608 */
608609struct sysfs_dirent * sysfs_find_dirent (struct sysfs_dirent * parent_sd ,
609- const void * ns ,
610- const unsigned char * name )
610+ const unsigned char * name ,
611+ const void * ns )
611612{
612613 struct rb_node * node = parent_sd -> s_dir .children .rb_node ;
613614 unsigned int hash ;
614615
615- hash = sysfs_name_hash (ns , name );
616+ hash = sysfs_name_hash (name , ns );
616617 while (node ) {
617618 struct sysfs_dirent * sd ;
618619 int result ;
619620
620621 sd = to_sysfs_dirent (node );
621- result = sysfs_name_compare (hash , ns , name , sd );
622+ result = sysfs_name_compare (hash , name , ns , sd );
622623 if (result < 0 )
623624 node = node -> rb_left ;
624625 else if (result > 0 )
@@ -651,7 +652,7 @@ struct sysfs_dirent *sysfs_get_dirent_ns(struct sysfs_dirent *parent_sd,
651652 struct sysfs_dirent * sd ;
652653
653654 mutex_lock (& sysfs_mutex );
654- sd = sysfs_find_dirent (parent_sd , ns , name );
655+ sd = sysfs_find_dirent (parent_sd , name , ns );
655656 sysfs_get (sd );
656657 mutex_unlock (& sysfs_mutex );
657658
@@ -660,7 +661,8 @@ struct sysfs_dirent *sysfs_get_dirent_ns(struct sysfs_dirent *parent_sd,
660661EXPORT_SYMBOL_GPL (sysfs_get_dirent_ns );
661662
662663static int create_dir (struct kobject * kobj , struct sysfs_dirent * parent_sd ,
663- const void * ns , const char * name , struct sysfs_dirent * * p_sd )
664+ const char * name , const void * ns ,
665+ struct sysfs_dirent * * p_sd )
664666{
665667 umode_t mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO ;
666668 struct sysfs_addrm_cxt acxt ;
@@ -691,7 +693,7 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
691693int sysfs_create_subdir (struct kobject * kobj , const char * name ,
692694 struct sysfs_dirent * * p_sd )
693695{
694- return create_dir (kobj , kobj -> sd , NULL , name , p_sd );
696+ return create_dir (kobj , kobj -> sd , name , NULL , p_sd );
695697}
696698
697699/**
@@ -714,7 +716,7 @@ int sysfs_create_dir_ns(struct kobject *kobj, const void *ns)
714716 if (!parent_sd )
715717 return - ENOENT ;
716718
717- error = create_dir (kobj , parent_sd , ns , kobject_name (kobj ), & sd );
719+ error = create_dir (kobj , parent_sd , kobject_name (kobj ), ns , & sd );
718720 if (!error )
719721 kobj -> sd = sd ;
720722 return error ;
@@ -735,7 +737,7 @@ static struct dentry *sysfs_lookup(struct inode *dir, struct dentry *dentry,
735737 if (parent_sd -> s_flags & SYSFS_FLAG_HAS_NS )
736738 ns = sysfs_info (dir -> i_sb )-> ns ;
737739
738- sd = sysfs_find_dirent (parent_sd , ns , dentry -> d_name .name );
740+ sd = sysfs_find_dirent (parent_sd , dentry -> d_name .name , ns );
739741
740742 /* no such entry */
741743 if (!sd ) {
@@ -823,9 +825,8 @@ void sysfs_remove_dir(struct kobject *kobj)
823825 __sysfs_remove_dir (sd );
824826}
825827
826- int sysfs_rename (struct sysfs_dirent * sd ,
827- struct sysfs_dirent * new_parent_sd , const void * new_ns ,
828- const char * new_name )
828+ int sysfs_rename (struct sysfs_dirent * sd , struct sysfs_dirent * new_parent_sd ,
829+ const char * new_name , const void * new_ns )
829830{
830831 int error ;
831832
@@ -837,7 +838,7 @@ int sysfs_rename(struct sysfs_dirent *sd,
837838 goto out ; /* nothing to rename */
838839
839840 error = - EEXIST ;
840- if (sysfs_find_dirent (new_parent_sd , new_ns , new_name ))
841+ if (sysfs_find_dirent (new_parent_sd , new_name , new_ns ))
841842 goto out ;
842843
843844 /* rename sysfs_dirent */
@@ -858,7 +859,7 @@ int sysfs_rename(struct sysfs_dirent *sd,
858859 sysfs_get (new_parent_sd );
859860 sysfs_put (sd -> s_parent );
860861 sd -> s_ns = new_ns ;
861- sd -> s_hash = sysfs_name_hash (sd -> s_ns , sd -> s_name );
862+ sd -> s_hash = sysfs_name_hash (sd -> s_name , sd -> s_ns );
862863 sd -> s_parent = new_parent_sd ;
863864 sysfs_link_sibling (sd );
864865
@@ -873,7 +874,7 @@ int sysfs_rename_dir_ns(struct kobject *kobj, const char *new_name,
873874{
874875 struct sysfs_dirent * parent_sd = kobj -> sd -> s_parent ;
875876
876- return sysfs_rename (kobj -> sd , parent_sd , new_ns , new_name );
877+ return sysfs_rename (kobj -> sd , parent_sd , new_name , new_ns );
877878}
878879
879880int sysfs_move_dir_ns (struct kobject * kobj , struct kobject * new_parent_kobj ,
@@ -886,7 +887,7 @@ int sysfs_move_dir_ns(struct kobject *kobj, struct kobject *new_parent_kobj,
886887 new_parent_sd = new_parent_kobj && new_parent_kobj -> sd ?
887888 new_parent_kobj -> sd : & sysfs_root ;
888889
889- return sysfs_rename (sd , new_parent_sd , new_ns , sd -> s_name );
890+ return sysfs_rename (sd , new_parent_sd , sd -> s_name , new_ns );
890891}
891892
892893/* Relationship between s_mode and the DT_xxx types */
0 commit comments