Skip to content

Commit 7d71109

Browse files
Christian Braunergregkh
authored andcommitted
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 <[email protected]> Reviewed-by: "Eric W. Biederman" <[email protected]> Acked-by: Linus Torvalds <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent f597fbc commit 7d71109

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

fs/devpts/inode.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,6 @@ static int devpts_ptmx_path(struct path *path)
138138
struct super_block *sb;
139139
int err;
140140

141-
/* Has the devpts filesystem already been found? */
142-
if (path->mnt->mnt_sb->s_magic == DEVPTS_SUPER_MAGIC)
143-
return 0;
144-
145141
/* Is a devpts filesystem at "pts" in the same directory? */
146142
err = path_pts(path);
147143
if (err)
@@ -159,21 +155,25 @@ static int devpts_ptmx_path(struct path *path)
159155
struct vfsmount *devpts_mntget(struct file *filp, struct pts_fs_info *fsi)
160156
{
161157
struct path path;
162-
int err;
158+
int err = 0;
163159

164160
path = filp->f_path;
165161
path_get(&path);
166162

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);
168166
dput(path.dentry);
169167
if (err) {
170168
mntput(path.mnt);
171169
return ERR_PTR(err);
172170
}
171+
173172
if (DEVPTS_SB(path.mnt->mnt_sb) != fsi) {
174173
mntput(path.mnt);
175174
return ERR_PTR(-ENODEV);
176175
}
176+
177177
return path.mnt;
178178
}
179179

@@ -182,15 +182,19 @@ struct pts_fs_info *devpts_acquire(struct file *filp)
182182
struct pts_fs_info *result;
183183
struct path path;
184184
struct super_block *sb;
185-
int err;
186185

187186
path = filp->f_path;
188187
path_get(&path);
189188

190-
err = devpts_ptmx_path(&path);
191-
if (err) {
192-
result = ERR_PTR(err);
193-
goto out;
189+
/* Has the devpts filesystem already been found? */
190+
if (path.mnt->mnt_sb->s_magic != DEVPTS_SUPER_MAGIC) {
191+
int err;
192+
193+
err = devpts_ptmx_path(&path);
194+
if (err) {
195+
result = ERR_PTR(err);
196+
goto out;
197+
}
194198
}
195199

196200
/*

0 commit comments

Comments
 (0)