From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Jan Tulak <jtulak@redhat.com>
Cc: linux-xfs@vger.kernel.org, sandeen@sandeen.net
Subject: Re: [PATCH 2/2] mkfs: move 'mounted' check before 'existing fs' check
Date: Wed, 19 Sep 2018 07:48:53 -0700 [thread overview]
Message-ID: <20180919144853.GI20086@magnolia> (raw)
In-Reply-To: <20180919125617.28048-2-jtulak@redhat.com>
On Wed, Sep 19, 2018 at 02:56:17PM +0200, Jan Tulak wrote:
> Check if a device is mounted (and issue an error about that) before
> asking for -f flag.
>
> Example of the old behaviour I'm changing:
> $ mkfs.xfs /dev/sda1
> mkfs.xfs: /dev/sda1 appears to contain an existing filesystem (xfs).
> mkfs.xfs: Use the -f option to force overwrite.
>
> $ mkfs.xfs -f /dev/sda1
> mkfs.xfs: /dev/sda1 contains a mounted filesystem
I'm confused by the commit message -- what is the new behavior?
Is it this?
$ mkfs.xfs /dev/sda1
mkfs.xfs: /dev/sda1 contains a mounted filesystem
$ mkfs.xfs -f /dev/sda1
mkfs.xfs: /dev/sda1 contains a mounted filesystem
--D
> Signed-off-by: Jan Tulak <jtulak@redhat.com>
> ---
> mkfs/xfs_mkfs.c | 32 ++++++++++++++++++--------------
> 1 file changed, 18 insertions(+), 14 deletions(-)
>
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index 81d9859a..97e78647 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -1012,7 +1012,6 @@ check_device_type(
> bool no_size,
> bool no_name,
> int *create,
> - bool force_overwrite,
> const char *optname)
> {
> struct stat statbuf;
> @@ -1043,13 +1042,6 @@ check_device_type(
> return;
> }
>
> - if (!force_overwrite && check_overwrite(name)) {
> - fprintf(stderr,
> - _("%s: Use the -f option to force overwrite.\n"),
> - progname);
> - exit(1);
> - }
> -
> /*
> * We only want to completely truncate and recreate an existing file if
> * we were specifically told it was a file. Set the create flag only in
> @@ -1079,6 +1071,20 @@ check_device_type(
> usage();
> }
>
> +static void
> +validate_overwrite(
> + const char *name,
> + bool force_overwrite)
> +{
> + if (!force_overwrite && check_overwrite(name)) {
> + fprintf(stderr,
> + _("%s: Use the -f option to force overwrite.\n"),
> + progname);
> + exit(1);
> + }
> +
> +}
> +
> static void
> validate_ag_geometry(
> int blocklog,
> @@ -1731,18 +1737,15 @@ validate_sectorsize(
> * files or block devices and set the control parameters correctly.
> */
> check_device_type(dfile, &cli->xi->disfile, !cli->dsize, !dfile,
> - dry_run ? NULL : &cli->xi->dcreat,
> - force_overwrite, "d");
> + dry_run ? NULL : &cli->xi->dcreat, "d");
> if (!cli->loginternal)
> check_device_type(cli->xi->logname, &cli->xi->lisfile,
> !cli->logsize, !cli->xi->logname,
> - dry_run ? NULL : &cli->xi->lcreat,
> - force_overwrite, "l");
> + dry_run ? NULL : &cli->xi->lcreat, "l");
> if (cli->xi->rtname)
> check_device_type(cli->xi->rtname, &cli->xi->risfile,
> !cli->rtsize, !cli->xi->rtname,
> - dry_run ? NULL : &cli->xi->rcreat,
> - force_overwrite, "r");
> + dry_run ? NULL : &cli->xi->rcreat, "r");
>
> /*
> * Explicitly disable direct IO for image files so we don't error out on
> @@ -3909,6 +3912,7 @@ main(
> * Open and validate the device configurations
> */
> open_devices(&cfg, &xi);
> + validate_overwrite(dfile, force_overwrite);
> validate_datadev(&cfg, &cli);
> validate_logdev(&cfg, &cli, &logfile);
> validate_rtdev(&cfg, &cli, &rtfile);
> --
> 2.18.0
next prev parent reply other threads:[~2018-09-19 20:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-19 12:56 [PATCH 1/2] mkfs: discard only after all validations Jan Tulak
2018-09-19 12:56 ` [PATCH 2/2] mkfs: move 'mounted' check before 'existing fs' check Jan Tulak
2018-09-19 14:48 ` Darrick J. Wong [this message]
2018-09-19 15:05 ` Jan Tulak
2018-09-20 20:03 ` Darrick J. Wong
2018-09-19 14:44 ` [PATCH 1/2] mkfs: discard only after all validations Darrick J. Wong
2018-09-19 15:11 ` Jan Tulak
2018-09-20 3:16 ` Dave Chinner
2018-09-20 9:20 ` [PATCH 1/2 v2] " Jan Tulak
2018-09-20 20:03 ` Darrick J. Wong
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=20180919144853.GI20086@magnolia \
--to=darrick.wong@oracle.com \
--cc=jtulak@redhat.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@sandeen.net \
/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).