From: Christian Brauner <christian.brauner-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
To: viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org,
torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org
Cc: containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org,
Christian Brauner
<christian.brauner-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
Subject: [PATCH 1/4 v5 RESEND] devpts: hoist out check for DEVPTS_SUPER_MAGIC
Date: Tue, 13 Mar 2018 17:55:24 +0100 [thread overview]
Message-ID: <20180313165527.24038-2-christian.brauner@ubuntu.com> (raw)
In-Reply-To: <20180313165527.24038-1-christian.brauner-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
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-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
---
ChangeLog v4->v5:
* dput() dentry
ChangeLog v3->v4:
* patch unchanged
ChangeLog v2->v3:
* patch unchanged
ChangeLog v1->v2:
* patch added
ChangeLog v0->v1:
* patch not present
---
fs/devpts/inode.c | 26 +++++++++++++++-----------
1 file 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)
struct super_block *sb;
int err;
- /* Has the devpts filesystem already been found? */
- if (path->mnt->mnt_sb->s_magic == DEVPTS_SUPER_MAGIC)
- return 0;
-
/* Is a devpts filesystem at "pts" in the same directory? */
err = path_pts(path);
if (err)
@@ -159,21 +155,25 @@ static int devpts_ptmx_path(struct path *path)
struct vfsmount *devpts_mntget(struct file *filp, struct pts_fs_info *fsi)
{
struct path path;
- int err;
+ int err = 0;
path = filp->f_path;
path_get(&path);
- err = devpts_ptmx_path(&path);
+ /* Has the devpts filesystem already been found? */
+ if (path.mnt->mnt_sb->s_magic != DEVPTS_SUPER_MAGIC)
+ err = devpts_ptmx_path(&path);
dput(path.dentry);
if (err) {
mntput(path.mnt);
return ERR_PTR(err);
}
+
if (DEVPTS_SB(path.mnt->mnt_sb) != fsi) {
mntput(path.mnt);
return ERR_PTR(-ENODEV);
}
+
return path.mnt;
}
@@ -182,15 +182,19 @@ struct pts_fs_info *devpts_acquire(struct file *filp)
struct pts_fs_info *result;
struct path path;
struct super_block *sb;
- int err;
path = filp->f_path;
path_get(&path);
- err = devpts_ptmx_path(&path);
- if (err) {
- result = ERR_PTR(err);
- goto out;
+ /* Has the devpts filesystem already been found? */
+ if (path.mnt->mnt_sb->s_magic != DEVPTS_SUPER_MAGIC) {
+ int err;
+
+ err = devpts_ptmx_path(&path);
+ if (err) {
+ result = ERR_PTR(err);
+ goto out;
+ }
}
/*
--
2.15.1
next parent reply other threads:[~2018-03-13 16:55 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20180313165527.24038-1-christian.brauner@ubuntu.com>
[not found] ` <20180313165527.24038-1-christian.brauner-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
2018-03-13 16:55 ` Christian Brauner [this message]
2018-03-13 16:55 ` [PATCH 2/4 v5 RESEND] devpts: resolve devpts bind-mounts Christian Brauner
2018-03-13 16:55 ` [PATCH 3/4 v5 RESEND] devpts: comment devpts_mntget() Christian Brauner
2018-03-13 16:55 ` [PATCH 4/4 v5 RESEND] selftests: add devpts selftests Christian Brauner
2018-03-13 17:32 ` [PATCH 0/4 v5 RESEND] devpts: handle bind-mounts correctly Eric W. Biederman
[not found] ` <87o9jr285m.fsf-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
2018-03-13 17:40 ` Greg KH
2018-03-13 18:02 ` Linus Torvalds
[not found] ` <20180313165527.24038-5-christian.brauner@ubuntu.com>
[not found] ` <20180313165527.24038-5-christian.brauner-GeWIH/nMZzLQT0dZR+AlfA@public.gmane.org>
2018-04-10 6:20 ` [PATCH 4/4 v5 RESEND] selftests: add devpts selftests Michael Ellerman
[not found] ` <87efjnbn0j.fsf@concordia.ellerman.id.au>
[not found] ` <87efjnbn0j.fsf-W0DJWXSxmBNbyGPkN3NxC2scP1bn1w/D@public.gmane.org>
2018-04-10 8:42 ` Christian Brauner
[not found] ` <20180410084208.GA14520@mailbox.org>
[not found] ` <20180410084208.GA14520-cl+VPiYnx/1AfugRpC6u6w@public.gmane.org>
2018-04-10 9:34 ` Michael Ellerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180313165527.24038-2-christian.brauner@ubuntu.com \
--to=christian.brauner-gewih/nmzzlqt0dzr+alfa@public.gmane.org \
--cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org \
--cc=gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=torvalds-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox