linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: demiobenour@gmail.com
To: Alexander Viro <viro@zeniv.linux.org.uk>,
	Jeff Layton <jlayton@kernel.org>,
	"J. Bruce Fields" <bfields@fieldses.org>,
	linux-fsdevel@vger.kernel.org (open list:FILESYSTEMS (VFS and
	infrastructure)), linux-kernel@vger.kernel.org (open list)
Cc: "Demi M. Obenour" <demiobenour@gmail.com>
Subject: [PATCH 3/4] Add AT_PATHSTATIC to linkat()
Date: Tue, 12 Feb 2019 09:54:46 -0500	[thread overview]
Message-ID: <20190212145450.2200-3-demiobenour@gmail.com> (raw)
In-Reply-To: <20190212145450.2200-1-demiobenour@gmail.com>

From: "Demi M. Obenour" <demiobenour@gmail.com>

This has the same meaning as O_PATHSTATIC does in openat(), and has the
same uses.
---
 fs/namei.c                 | 8 +++++++-
 include/uapi/linux/fcntl.h | 1 +
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/fs/namei.c b/fs/namei.c
index 4c90f265c103..b47f89af00f2 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -4291,8 +4291,14 @@ int do_linkat(int olddfd, const char __user *oldname, int newdfd,
 		how = LOOKUP_EMPTY;
 	}
 
-	if (flags & AT_SYMLINK_FOLLOW)
+	if (flags & AT_SYMLINK_FOLLOW) {
+		if (flags & AT_PATHSTATIC)
+			return -EINVAL;
 		how |= LOOKUP_FOLLOW;
+	}
+
+	if (flags & AT_PATHSTATIC)
+		how |= LOOKUP_NEVER_FOLLOW;
 retry:
 	error = user_path_at(olddfd, oldname, how, &old_path);
 	if (error)
diff --git a/include/uapi/linux/fcntl.h b/include/uapi/linux/fcntl.h
index 6448cdd9a350..a2f65635c8fc 100644
--- a/include/uapi/linux/fcntl.h
+++ b/include/uapi/linux/fcntl.h
@@ -89,6 +89,7 @@
 #define AT_STATX_SYNC_AS_STAT	0x0000	/* - Do whatever stat() does */
 #define AT_STATX_FORCE_SYNC	0x2000	/* - Force the attributes to be sync'd with the server */
 #define AT_STATX_DONT_SYNC	0x4000	/* - Don't sync attributes with the server */
+#define AT_PATHSTATIC		0x8000	/* Do not follow symbolic links anywhere. */
 
 
 #endif /* _UAPI_LINUX_FCNTL_H */
-- 
2.20.1


  parent reply	other threads:[~2019-02-12 14:55 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-12 14:54 [PATCH 1/4] Add path resolution flag LOOKUP_NEVER_FOLLOW demiobenour
2019-02-12 14:54 ` [PATCH 2/4] Expose O_PATHSTATIC to userspace demiobenour
2019-02-12 20:18   ` Andreas Dilger
2019-02-12 22:41     ` Demi M. Obenour
2019-02-12 14:54 ` demiobenour [this message]
2019-02-12 14:54 ` [PATCH 4/4] Return -EINVAL if userspace passes bogus flags to open() demiobenour
2019-02-12 20:38   ` Al Viro
2019-02-12 23:00     ` Demi M. Obenour

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=20190212145450.2200-3-demiobenour@gmail.com \
    --to=demiobenour@gmail.com \
    --cc=bfields@fieldses.org \
    --cc=jlayton@kernel.org \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@zeniv.linux.org.uk \
    /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;
as well as URLs for NNTP newsgroup(s).