diff options
author | Christian Brauner <christian.brauner@ubuntu.com> | 2018-03-13 12:55:24 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-03-14 08:31:23 -0400 |
commit | 7d71109df186d630a41280670c8d71d0cf9b0da9 (patch) | |
tree | 1d91e78c891889f3385b4bdaae33b6312b2d971c | |
parent | f597fbce38d230af95384f4a04e0a13a1d0ad45d (diff) |
devpts: hoist out check for DEVPTS_SUPER_MAGIC
Hoist the check whether we have already found a suitable devpts filesystem
out of devpts_ptmx_path() in preparation for the devpts bind-mount
resolution patch. This is a non-functional change.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Reviewed-by: "Eric W. Biederman" <ebiederm@xmission.com>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | fs/devpts/inode.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/fs/devpts/inode.c b/fs/devpts/inode.c index e31d6ed3ec32..71b901936113 100644 --- a/fs/devpts/inode.c +++ b/fs/devpts/inode.c | |||
@@ -138,10 +138,6 @@ static int devpts_ptmx_path(struct path *path) | |||
138 | struct super_block *sb; | 138 | struct super_block *sb; |
139 | int err; | 139 | int err; |
140 | 140 | ||
141 | /* Has the devpts filesystem already been found? */ | ||
142 | if (path->mnt->mnt_sb->s_magic == DEVPTS_SUPER_MAGIC) | ||
143 | return 0; | ||
144 | |||
145 | /* Is a devpts filesystem at "pts" in the same directory? */ | 141 | /* Is a devpts filesystem at "pts" in the same directory? */ |
146 | err = path_pts(path); | 142 | err = path_pts(path); |
147 | if (err) | 143 | if (err) |
@@ -159,21 +155,25 @@ static int devpts_ptmx_path(struct path *path) | |||
159 | struct vfsmount *devpts_mntget(struct file *filp, struct pts_fs_info *fsi) | 155 | struct vfsmount *devpts_mntget(struct file *filp, struct pts_fs_info *fsi) |
160 | { | 156 | { |
161 | struct path path; | 157 | struct path path; |
162 | int err; | 158 | int err = 0; |
163 | 159 | ||
164 | path = filp->f_path; | 160 | path = filp->f_path; |
165 | path_get(&path); | 161 | path_get(&path); |
166 | 162 | ||
167 | err = devpts_ptmx_path(&path); | 163 | /* Has the devpts filesystem already been found? */ |
164 | if (path.mnt->mnt_sb->s_magic != DEVPTS_SUPER_MAGIC) | ||
165 | err = devpts_ptmx_path(&path); | ||
168 | dput(path.dentry); | 166 | dput(path.dentry); |
169 | if (err) { | 167 | if (err) { |
170 | mntput(path.mnt); | 168 | mntput(path.mnt); |
171 | return ERR_PTR(err); | 169 | return ERR_PTR(err); |
172 | } | 170 | } |
171 | |||
173 | if (DEVPTS_SB(path.mnt->mnt_sb) != fsi) { | 172 | if (DEVPTS_SB(path.mnt->mnt_sb) != fsi) { |
174 | mntput(path.mnt); | 173 | mntput(path.mnt); |
175 | return ERR_PTR(-ENODEV); | 174 | return ERR_PTR(-ENODEV); |
176 | } | 175 | } |
176 | |||
177 | return path.mnt; | 177 | return path.mnt; |
178 | } | 178 | } |
179 | 179 | ||
@@ -182,15 +182,19 @@ struct pts_fs_info *devpts_acquire(struct file *filp) | |||
182 | struct pts_fs_info *result; | 182 | struct pts_fs_info *result; |
183 | struct path path; | 183 | struct path path; |
184 | struct super_block *sb; | 184 | struct super_block *sb; |
185 | int err; | ||
186 | 185 | ||
187 | path = filp->f_path; | 186 | path = filp->f_path; |
188 | path_get(&path); | 187 | path_get(&path); |
189 | 188 | ||
190 | err = devpts_ptmx_path(&path); | 189 | /* Has the devpts filesystem already been found? */ |
191 | if (err) { | 190 | if (path.mnt->mnt_sb->s_magic != DEVPTS_SUPER_MAGIC) { |
192 | result = ERR_PTR(err); | 191 | int err; |
193 | goto out; | 192 | |
193 | err = devpts_ptmx_path(&path); | ||
194 | if (err) { | ||
195 | result = ERR_PTR(err); | ||
196 | goto out; | ||
197 | } | ||
194 | } | 198 | } |
195 | 199 | ||
196 | /* | 200 | /* |