From: Christoph Hellwig <hch@infradead.org>
To: xfs@oss.sgi.com
Subject: Re: [PATCH] xfs_io: add support for flink
Date: Thu, 20 Feb 2014 16:49:33 -0800 [thread overview]
Message-ID: <20140221004933.GA9445@infradead.org> (raw)
In-Reply-To: <20140220220000.GA17541@infradead.org>
Signed-off-by: Christoph Hellwig <hch@lst.de>
diff --git a/io/Makefile b/io/Makefile
index eaeb5b2..c16af87 100644
--- a/io/Makefile
+++ b/io/Makefile
@@ -9,8 +9,8 @@ LTCOMMAND = xfs_io
LSRCFILES = xfs_bmap.sh xfs_freeze.sh xfs_mkfile.sh
HFILES = init.h io.h
CFILES = init.c \
- attr.c bmap.c file.c freeze.c fsync.c getrusage.c imap.c mmap.c \
- open.c parent.c pread.c prealloc.c pwrite.c seek.c shutdown.c \
+ attr.c bmap.c file.c freeze.c fsync.c getrusage.c imap.c link.c \
+ mmap.c open.c parent.c pread.c prealloc.c pwrite.c seek.c shutdown.c \
truncate.c
LLDLIBS = $(LIBXCMD) $(LIBHANDLE)
diff --git a/io/init.c b/io/init.c
index fd1a52f..7d7bb89 100644
--- a/io/init.c
+++ b/io/init.c
@@ -58,6 +58,7 @@ init_commands(void)
bmap_init();
fadvise_init();
file_init();
+ flink_init();
freeze_init();
fsync_init();
getrusage_init();
diff --git a/io/io.h b/io/io.h
index 0d2d768..1b3bca1 100644
--- a/io/io.h
+++ b/io/io.h
@@ -93,6 +93,7 @@ extern void dump_buffer(off64_t, ssize_t);
extern void attr_init(void);
extern void bmap_init(void);
extern void file_init(void);
+extern void flink_init(void);
extern void freeze_init(void);
extern void fsync_init(void);
extern void getrusage_init(void);
diff --git a/io/link.c b/io/link.c
new file mode 100644
index 0000000..49ca6a5
--- /dev/null
+++ b/io/link.c
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2014 Christoph Hellwig.
+ * All Rights Reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <xfs/xfs.h>
+#include <xfs/command.h>
+#include <xfs/input.h>
+#include "init.h"
+#include "io.h"
+
+#ifndef AT_EMPTY_PATH
+#define AT_EMPTY_PATH 0x1000
+#endif
+
+static cmdinfo_t flink_cmd;
+
+static void
+flink_help(void)
+{
+ printf(_(
+"\n"
+"link the open file descriptor into the filesystem\n"
+"\n"
+"\n"));
+}
+
+static int
+flink_f(
+ int argc,
+ char **argv)
+{
+ if (argc != 2)
+ return command_usage(&flink_cmd);
+
+ if (linkat(file->fd, "", AT_FDCWD, argv[1], AT_EMPTY_PATH) < 0) {
+ perror("flink");
+ return 0;
+ }
+ return 0;
+}
+
+void
+flink_init(void)
+{
+ flink_cmd.name = "flink";
+ flink_cmd.cfunc = flink_f;
+ flink_cmd.argmin = 1;
+ flink_cmd.argmax = 1;
+ flink_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK;
+ flink_cmd.args = _("filename");
+ flink_cmd.oneline =
+ _("link the open file descriptor into the filesystem");
+ flink_cmd.help = flink_help;
+
+ add_command(&flink_cmd);
+}
diff --git a/man/man8/xfs_io.8 b/man/man8/xfs_io.8
index 7a92ff6..7d0c792 100644
--- a/man/man8/xfs_io.8
+++ b/man/man8/xfs_io.8
@@ -638,6 +638,9 @@ Only available in expert mode and requires privileges.
Undo the effects of a filesystem freeze operation.
Only available in expert mode and requires privileges.
.TP
+.B flink
+Link the currently open file descriptor into the filesystem namespace.
+.TP
.BI "inject [ " tag " ]"
Inject errors into a filesystem to observe filesystem behavior at
specific points under adverse conditions. Without the
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2014-02-21 0:49 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-20 22:00 [PATCH] xfs_io: add support for O_TMPFILE opens Christoph Hellwig
2014-02-20 22:15 ` Dave Chinner
2014-02-20 22:40 ` Christoph Hellwig
2014-02-21 0:16 ` Shaun Gosse
2014-02-21 0:20 ` Christoph Hellwig
2014-02-21 0:30 ` [PATCH v2] " Christoph Hellwig
2014-02-23 21:01 ` Dave Chinner
2014-02-21 0:49 ` Christoph Hellwig [this message]
2014-02-23 21:06 ` [PATCH] xfs_io: add support for flink Dave Chinner
2014-02-25 19:52 ` [PATCH v2] " Christoph Hellwig
2014-02-25 23:35 ` Dave Chinner
2014-03-13 10:09 ` Christoph Hellwig
2014-03-13 10:21 ` Dave Chinner
2014-03-13 10:42 ` Dave Chinner
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=20140221004933.GA9445@infradead.org \
--to=hch@infradead.org \
--cc=xfs@oss.sgi.com \
/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