aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysfs/symlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/sysfs/symlink.c')
-rw-r--r--fs/sysfs/symlink.c27
1 files changed, 6 insertions, 21 deletions
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
index 12d58ada3e6d..7d981ce2e87f 100644
--- a/fs/sysfs/symlink.c
+++ b/fs/sysfs/symlink.c
@@ -28,7 +28,6 @@ static int sysfs_do_create_link_sd(struct sysfs_dirent *parent_sd,
28 struct sysfs_dirent *target_sd = NULL; 28 struct sysfs_dirent *target_sd = NULL;
29 struct sysfs_dirent *sd = NULL; 29 struct sysfs_dirent *sd = NULL;
30 struct sysfs_addrm_cxt acxt; 30 struct sysfs_addrm_cxt acxt;
31 enum kobj_ns_type ns_type;
32 int error; 31 int error;
33 32
34 BUG_ON(!name || !parent_sd); 33 BUG_ON(!name || !parent_sd);
@@ -50,29 +49,15 @@ static int sysfs_do_create_link_sd(struct sysfs_dirent *parent_sd,
50 if (!sd) 49 if (!sd)
51 goto out_put; 50 goto out_put;
52 51
53 ns_type = sysfs_ns_type(parent_sd); 52 sd->s_ns = target_sd->s_ns;
54 if (ns_type)
55 sd->s_ns = target_sd->s_ns;
56 sd->s_symlink.target_sd = target_sd; 53 sd->s_symlink.target_sd = target_sd;
57 target_sd = NULL; /* reference is now owned by the symlink */ 54 target_sd = NULL; /* reference is now owned by the symlink */
58 55
59 sysfs_addrm_start(&acxt, parent_sd); 56 sysfs_addrm_start(&acxt, parent_sd);
60 /* Symlinks must be between directories with the same ns_type */ 57 if (warn)
61 if (!ns_type || 58 error = sysfs_add_one(&acxt, sd);
62 (ns_type == sysfs_ns_type(sd->s_symlink.target_sd->s_parent))) { 59 else
63 if (warn) 60 error = __sysfs_add_one(&acxt, sd);
64 error = sysfs_add_one(&acxt, sd);
65 else
66 error = __sysfs_add_one(&acxt, sd);
67 } else {
68 error = -EINVAL;
69 WARN(1, KERN_WARNING
70 "sysfs: symlink across ns_types %s/%s -> %s/%s\n",
71 parent_sd->s_name,
72 sd->s_name,
73 sd->s_symlink.target_sd->s_parent->s_name,
74 sd->s_symlink.target_sd->s_name);
75 }
76 sysfs_addrm_finish(&acxt); 61 sysfs_addrm_finish(&acxt);
77 62
78 if (error) 63 if (error)
@@ -156,7 +141,7 @@ void sysfs_delete_link(struct kobject *kobj, struct kobject *targ,
156{ 141{
157 const void *ns = NULL; 142 const void *ns = NULL;
158 spin_lock(&sysfs_assoc_lock); 143 spin_lock(&sysfs_assoc_lock);
159 if (targ->sd && sysfs_ns_type(kobj->sd)) 144 if (targ->sd)
160 ns = targ->sd->s_ns; 145 ns = targ->sd->s_ns;
161 spin_unlock(&sysfs_assoc_lock); 146 spin_unlock(&sysfs_assoc_lock);
162 sysfs_hash_and_remove(kobj->sd, ns, name); 147 sysfs_hash_and_remove(kobj->sd, ns, name);