From: Zorro Lang <zlang@redhat.com>
To: Omar Sandoval <osandov@osandov.com>
Cc: linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [RFC PATCH xfsprogs] xfs_io: add support for linkat() AT_LINK_REPLACE
Date: Thu, 30 Jan 2020 12:42:51 +0800 [thread overview]
Message-ID: <20200130044251.GL14282@dhcp-12-102.nay.redhat.com> (raw)
In-Reply-To: <ff4b873f356ed8ff63ee582bc57c4babea947159.1580253398.git.osandov@fb.com>
On Wed, Jan 29, 2020 at 12:58:29AM -0800, Omar Sandoval wrote:
> From: Omar Sandoval <osandov@fb.com>
>
> Signed-off-by: Omar Sandoval <osandov@fb.com>
> ---
And this patch would be better to send to/cc linux-xfs@vger.kernel.org to get
xfsprogs maintainers/developers review.
> io/link.c | 24 ++++++++++++++++++++----
> man/man8/xfs_io.8 | 9 ++++++++-
> 2 files changed, 28 insertions(+), 5 deletions(-)
>
> diff --git a/io/link.c b/io/link.c
> index f4f4b139..3fc3e24d 100644
> --- a/io/link.c
> +++ b/io/link.c
> @@ -12,6 +12,9 @@
> #ifndef AT_EMPTY_PATH
> #define AT_EMPTY_PATH 0x1000
> #endif
> +#ifndef AT_LINK_REPLACE
> +#define AT_LINK_REPLACE 0x10000
> +#endif
>
> static cmdinfo_t flink_cmd;
>
> @@ -22,6 +25,7 @@ flink_help(void)
> "\n"
> "link the open file descriptor to the supplied filename\n"
> "\n"
> +" -f -- overwrite the target filename if it exists (AT_LINK_REPLACE)\n"
> "\n"));
> }
>
> @@ -30,10 +34,22 @@ flink_f(
> int argc,
> char **argv)
> {
> - if (argc != 2)
> + int flags = AT_EMPTY_PATH;
> + int c;
> +
> + while ((c = getopt(argc, argv, "f")) != EOF) {
> + switch (c) {
> + case 'f':
> + flags |= AT_LINK_REPLACE;
> + break;
> + default:
> + return command_usage(&flink_cmd);
> + }
> + }
> + if (optind != argc - 1)
> return command_usage(&flink_cmd);
>
> - if (linkat(file->fd, "", AT_FDCWD, argv[1], AT_EMPTY_PATH) < 0) {
> + if (linkat(file->fd, "", AT_FDCWD, argv[optind], flags) < 0) {
> perror("flink");
> return 0;
> }
> @@ -46,9 +62,9 @@ flink_init(void)
> flink_cmd.name = "flink";
> flink_cmd.cfunc = flink_f;
> flink_cmd.argmin = 1;
> - flink_cmd.argmax = 1;
> + flink_cmd.argmax = -1;
> flink_cmd.flags = CMD_NOMAP_OK | CMD_FOREIGN_OK | CMD_FLAG_ONESHOT;
> - flink_cmd.args = _("filename");
> + flink_cmd.args = _("[-f] filename");
> flink_cmd.oneline =
> _("link the open file descriptor to the supplied filename");
> flink_cmd.help = flink_help;
> diff --git a/man/man8/xfs_io.8 b/man/man8/xfs_io.8
> index c69b295d..f79b3a59 100644
> --- a/man/man8/xfs_io.8
> +++ b/man/man8/xfs_io.8
> @@ -807,8 +807,15 @@ for the full list) is available via the
> .B help
> command.
> .TP
> -.BI "flink " path
> +.BI "flink [ \-f ]" " path"
> Link the currently open file descriptor into the filesystem namespace.
> +.RS 1.0i
> +.PD 0
> +.TP 0.4i
> +.B \-f
> +overwrite the target path if it exists (AT_LINK_REPLACE).
> +.PD
> +.RE
> .TP
> .BR stat " [ " \-v "|" \-r " ]"
> Selected statistics from
> --
> 2.25.0
>
next prev parent reply other threads:[~2020-01-30 4:33 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-28 23:18 [RFC PATCH v4 0/4] fs: add flag to linkat() for replacing destination Omar Sandoval
2020-01-29 8:58 ` Omar Sandoval
2020-01-28 23:18 ` [RFC PATCH xfstests] generic: add smoke test for AT_LINK_REPLACE Omar Sandoval
2020-01-29 8:58 ` Omar Sandoval
2020-01-29 7:02 ` Zorro Lang
2020-02-23 14:46 ` Eryu Guan
2020-01-28 23:18 ` [RFC PATCH man-pages] link.2: Document new AT_LINK_REPLACE flag Omar Sandoval
2020-01-29 8:58 ` Omar Sandoval
2020-01-28 23:18 ` [RFC PATCH xfsprogs] xfs_io: add support for linkat() AT_LINK_REPLACE Omar Sandoval
2020-01-29 8:58 ` Omar Sandoval
2020-01-30 4:42 ` Zorro Lang [this message]
2020-01-28 23:19 ` [RFC PATCH v4 1/4] fs: add flags argument to i_op->link() Omar Sandoval
2020-01-29 8:58 ` Omar Sandoval
2020-01-28 23:19 ` [RFC PATCH v4 2/4] fs: add AT_LINK_REPLACE flag for linkat() which replaces the target Omar Sandoval
2020-01-29 8:58 ` Omar Sandoval
2020-01-28 23:19 ` [RFC PATCH v4 3/4] Btrfs: fix inode reference count leak in btrfs_link() error path Omar Sandoval
2020-01-29 8:58 ` Omar Sandoval
2020-01-28 23:19 ` [RFC PATCH v4 4/4] Btrfs: add support for linkat() AT_REPLACE Omar Sandoval
2020-01-29 8:58 ` Omar Sandoval
2020-01-29 8:58 ` [RFC PATCH xfstests] generic: add smoke test for AT_LINK_REPLACE Omar Sandoval
[not found] ` <cover.1580251857.git.osandov-b10kYP2dOMg@public.gmane.org>
2020-01-29 8:58 ` Omar Sandoval
2020-01-29 8:58 ` [RFC PATCH man-pages] link.2: Document new AT_LINK_REPLACE flag Omar Sandoval
2020-01-29 8:58 ` [RFC PATCH xfsprogs] xfs_io: add support for linkat() AT_LINK_REPLACE Omar Sandoval
2020-01-29 8:58 ` [RFC PATCH v4 0/4] fs: add flag to linkat() for replacing destination Omar Sandoval
2020-01-29 8:58 ` [RFC PATCH v4 1/4] fs: add flags argument to i_op->link() Omar Sandoval
2020-01-29 8:58 ` [RFC PATCH v4 2/4] fs: add AT_LINK_REPLACE flag for linkat() which replaces the target Omar Sandoval
2020-01-29 8:58 ` [RFC PATCH v4 3/4] Btrfs: fix inode reference count leak in btrfs_link() error path Omar Sandoval
2020-01-29 8:58 ` [RFC PATCH v4 4/4] Btrfs: add support for linkat() AT_REPLACE Omar Sandoval
2020-01-31 13:48 ` [RFC PATCH v4 1/4] fs: add flags argument to i_op->link() David Howells
2020-01-31 20:24 ` Omar Sandoval
2020-01-31 20:24 ` Omar Sandoval
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=20200130044251.GL14282@dhcp-12-102.nay.redhat.com \
--to=zlang@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=osandov@osandov.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.