linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: linux-xfs@vger.kernel.org
Subject: [PATCH 1/2] xfs_io: add the ability to do an O_PATH open
Date: Wed, 16 May 2018 09:27:37 -0400	[thread overview]
Message-ID: <20180516132738.27776-1-jlayton@kernel.org> (raw)

From: Jeff Layton <jlayton@redhat.com>

Signed-off-by: Jeff Layton <jlayton@redhat.com>
---
 io/file.c         | 3 ++-
 io/init.c         | 5 ++++-
 io/io.h           | 1 +
 io/open.c         | 7 ++++++-
 io/stat.c         | 4 +++-
 man/man8/xfs_io.8 | 3 +++
 6 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/io/file.c b/io/file.c
index 349b19cdc420..ff80652b183b 100644
--- a/io/file.c
+++ b/io/file.c
@@ -44,7 +44,8 @@ print_fileio(
 		file->flags & IO_REALTIME ? _(",real-time") : "",
 		file->flags & IO_APPEND ? _(",append-only") : "",
 		file->flags & IO_NONBLOCK ? _(",non-block") : "",
-		file->flags & IO_TMPFILE ? _(",tmpfile") : "");
+		file->flags & IO_TMPFILE ? _(",tmpfile") : "",
+		file->flags & IO_PATH ? _(",path") : "");
 }
 
 int
diff --git a/io/init.c b/io/init.c
index 0336c9623beb..d4e84e82a77e 100644
--- a/io/init.c
+++ b/io/init.c
@@ -154,7 +154,7 @@ init(
 	gettimeofday(&stopwatch, NULL);
 
 	fs_table_initialise(0, NULL, 0, NULL);
-	while ((c = getopt(argc, argv, "ac:C:dFfim:p:nrRstTVx")) != EOF) {
+	while ((c = getopt(argc, argv, "ac:C:dFfim:Pp:nrRstTVx")) != EOF) {
 		switch (c) {
 		case 'a':
 			flags |= IO_APPEND;
@@ -200,6 +200,9 @@ init(
 		case 't':
 			flags |= IO_TRUNC;
 			break;
+		case 'P':
+			flags |= IO_PATH;
+			break;
 		case 'R':
 			flags |= IO_REALTIME;
 			break;
diff --git a/io/io.h b/io/io.h
index a26763610877..0acc332b5dbb 100644
--- a/io/io.h
+++ b/io/io.h
@@ -40,6 +40,7 @@
 #define IO_FOREIGN	(1<<7)
 #define IO_NONBLOCK	(1<<8)
 #define IO_TMPFILE	(1<<9)
+#define IO_PATH		(1<<10)
 
 /*
  * Regular file I/O control
diff --git a/io/open.c b/io/open.c
index 2cce0455263a..ba73f1d0361f 100644
--- a/io/open.c
+++ b/io/open.c
@@ -74,6 +74,8 @@ openfile(
 		oflags |= O_NONBLOCK;
 	if (flags & IO_TMPFILE)
 		oflags |= O_TMPFILE;
+	if (flags & IO_PATH)
+		oflags |= O_PATH;
 
 	fd = open(path, oflags, mode);
 	if (fd < 0) {
@@ -216,7 +218,7 @@ open_f(
 		return 0;
 	}
 
-	while ((c = getopt(argc, argv, "FRTacdfm:nrstx")) != EOF) {
+	while ((c = getopt(argc, argv, "FRTacdfm:nPrstx")) != EOF) {
 		switch (c) {
 		case 'F':
 			/* Ignored / deprecated now, handled automatically */
@@ -250,6 +252,9 @@ open_f(
 		case 't':
 			flags |= IO_TRUNC;
 			break;
+		case 'P':
+			flags |= IO_PATH;
+			break;
 		case 'R':
 		case 'x':	/* backwards compatibility */
 			flags |= IO_REALTIME;
diff --git a/io/stat.c b/io/stat.c
index 41d421525791..2db2736359e0 100644
--- a/io/stat.c
+++ b/io/stat.c
@@ -100,7 +100,9 @@ void print_file_info(void)
 		file->flags & IO_REALTIME ? _(",real-time") : "",
 		file->flags & IO_APPEND ? _(",append-only") : "",
 		file->flags & IO_NONBLOCK ? _(",non-block") : "",
-		file->flags & IO_TMPFILE ? _(",tmpfile") : "");
+		file->flags & IO_TMPFILE ? _(",tmpfile") : "",
+		file->flags & IO_PATH ? _(",path") : "");
+
 }
 
 void print_xfs_info(int verbose)
diff --git a/man/man8/xfs_io.8 b/man/man8/xfs_io.8
index c3ab532da03f..89e8e4be460e 100644
--- a/man/man8/xfs_io.8
+++ b/man/man8/xfs_io.8
@@ -153,6 +153,9 @@ truncates on open (O_TRUNC).
 .B \-n
 opens in non-blocking mode if possible (O_NONBLOCK).
 .TP
+.B \-P
+opens the file for location only (O_PATH).
+.TP
 .B \-T
 create a temporary file not linked into the filesystem namespace
 (O_TMPFILE).  The pathname passed must refer to a directory which
-- 
2.17.0


             reply	other threads:[~2018-05-16 13:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-16 13:27 Jeff Layton [this message]
2018-05-16 13:27 ` [PATCH 2/2] xfs_io: syncfs can fail Jeff Layton
2018-05-16 14:26   ` Eric Sandeen
2018-05-16 17:17   ` [PATCH v2] " Jeff Layton
2018-05-23 21:37     ` Eric Sandeen
2018-05-16 14:32 ` [PATCH 1/2] xfs_io: add the ability to do an O_PATH open Eric Sandeen
2018-05-16 17:14 ` [PATCH v3] xfs_io: Allow -P and -L to be given to open for O_PATH and O_NOFOLLOW Jeff Layton
2018-05-23 21:51   ` Eric Sandeen
2018-05-23 22:03     ` Eric Sandeen

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=20180516132738.27776-1-jlayton@kernel.org \
    --to=jlayton@kernel.org \
    --cc=linux-xfs@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).