From: "Lukáš Czerner" <lczerner@redhat.com>
To: "Theodore Ts'o" <tytso@mit.edu>
Cc: Ext4 Developers List <linux-ext4@vger.kernel.org>
Subject: Re: [PATCH 1/3] mke2fs: print a message when creating a regular file
Date: Mon, 5 May 2014 15:41:01 +0200 (CEST) [thread overview]
Message-ID: <alpine.LFD.2.00.1405051532280.2223@localhost.localdomain> (raw)
In-Reply-To: <1399295044-24489-1-git-send-email-tytso@mit.edu>
On Mon, 5 May 2014, Theodore Ts'o wrote:
> Date: Mon, 5 May 2014 09:04:02 -0400
> From: Theodore Ts'o <tytso@mit.edu>
> To: Ext4 Developers List <linux-ext4@vger.kernel.org>
> Cc: Theodore Ts'o <tytso@mit.edu>
> Subject: [PATCH 1/3] mke2fs: print a message when creating a regular file
Description is missing.
>
> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
> ---
> misc/mke2fs.c | 6 ++++--
> misc/util.c | 11 +++++++----
> misc/util.h | 1 +
> 3 files changed, 12 insertions(+), 6 deletions(-)
>
> diff --git a/misc/mke2fs.c b/misc/mke2fs.c
> index 2c51999..51532ef 100644
> --- a/misc/mke2fs.c
> +++ b/misc/mke2fs.c
> @@ -103,6 +103,7 @@ static int quotatype = -1; /* Initialize both user and group quotas by default
> static __u64 offset;
> static blk64_t journal_location = ~0LL;
> static int proceed_delay = -1;
> +static blk64_t dev_size;
>
> static struct ext2_super_block fs_param;
> static char *fs_uuid = NULL;
> @@ -1402,7 +1403,6 @@ static void PRS(int argc, char *argv[])
> char * extended_opts = 0;
> char * fs_type = 0;
> char * usage_types = 0;
> - blk64_t dev_size;
> /*
> * NOTE: A few words about fs_blocks_count and blocksize:
> *
> @@ -1768,6 +1768,8 @@ profile_error:
> flags = CREATE_FILE;
> if (isatty(0) && isatty(1))
> flags |= CHECK_FS_EXIST;
> + if (!quiet)
> + flags |= VERBOSE_CREATE;
> if (!check_plausibility(device_name, flags, &is_device) && !force)
> proceed_question(proceed_delay);
>
> @@ -2573,7 +2575,7 @@ int main (int argc, char *argv[])
> journal_blocks = figure_journal_size(journal_size, fs);
>
> /* Can't undo discard ... */
> - if (!noaction && discard && (io_ptr != undo_io_manager)) {
> + if (!noaction && discard && dev_size && (io_ptr != undo_io_manager)) {
I wonder whether it's possible not to have dev_size set at this point ?
> retval = mke2fs_discard_device(fs);
> if (!retval && io_channel_discard_zeroes_data(fs->io)) {
> if (verbose)
> diff --git a/misc/util.c b/misc/util.c
> index be16ebe..15b4ce5 100644
> --- a/misc/util.c
> +++ b/misc/util.c
> @@ -106,7 +106,7 @@ void proceed_question(int delay)
> }
>
> /*
> - * return 1 if the device looks plausible
> + * return 1 if the device looks plausible, creating the file if necessary
> */
> int check_plausibility(const char *device, int flags, int *ret_is_dev)
> {
> @@ -117,10 +117,13 @@ int check_plausibility(const char *device, int flags, int *ret_is_dev)
> char *fs_type = NULL;
> char *fs_label = NULL;
>
> - if (flags & CREATE_FILE)
> - fl |= O_CREAT;
> -
> fd = open(device, fl, 0666);
Ah, so you're building on a previous patches. It's a bit confusing.
> + if ((fd < 0) && (errno == ENOENT) && (flags & CREATE_FILE)) {
> + fl |= O_CREAT;
> + fd = open(device, fl, 0666);
> + if (fd >= 0 && (flags & VERBOSE_CREATE))
Do we have to use VERBOSE_CREATE ? quiet is global variable so we
can as well just test that here, or am I missing something ?
Thanks!
-Lukas
> + printf(_("Creating regular file %s\n"), device);
> + }
> if (fd < 0) {
> fprintf(stderr, _("Could not open %s: %s\n"),
> device, error_message(errno));
> diff --git a/misc/util.h b/misc/util.h
> index 745568e..476164b 100644
> --- a/misc/util.h
> +++ b/misc/util.h
> @@ -21,6 +21,7 @@ extern char *journal_location_string;
> #define CHECK_BLOCK_DEV 0x0001
> #define CREATE_FILE 0x0002
> #define CHECK_FS_EXIST 0x0004
> +#define VERBOSE_CREATE 0x0008
>
> #ifndef HAVE_STRCASECMP
> extern int strcasecmp (char *s1, char *s2);
>
next prev parent reply other threads:[~2014-05-05 13:41 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-05 13:04 [PATCH 1/3] mke2fs: print a message when creating a regular file Theodore Ts'o
2014-05-05 13:04 ` [PATCH 2/3] mke2fs: print extra information about existing ext2/3/4 file systems Theodore Ts'o
2014-05-05 13:45 ` Lukáš Czerner
2014-05-05 14:04 ` Theodore Ts'o
2014-05-05 14:17 ` Lukáš Czerner
2014-05-05 14:28 ` Theodore Ts'o
2014-05-05 14:38 ` Lukáš Czerner
2014-05-05 14:44 ` Theodore Ts'o
2014-05-05 14:51 ` Lukáš Czerner
2014-05-05 14:57 ` Theodore Ts'o
2014-05-05 16:25 ` Andreas Dilger
2014-05-05 17:50 ` Karel Zak
2014-05-05 18:32 ` Theodore Ts'o
2014-05-06 7:44 ` Karel Zak
2014-05-05 16:30 ` Andreas Dilger
2014-05-05 13:04 ` [PATCH 3/3] mke2fs: check for a partition table and warn if present Theodore Ts'o
2014-05-05 13:52 ` Lukáš Czerner
2014-05-05 13:58 ` Theodore Ts'o
2014-05-05 14:11 ` Lukáš Czerner
2014-05-05 14:20 ` Theodore Ts'o
2014-05-06 12:20 ` Karel Zak
2014-05-06 12:52 ` Lukáš Czerner
2014-05-05 13:41 ` Lukáš Czerner [this message]
2014-05-05 13:52 ` [PATCH 1/3] mke2fs: print a message when creating a regular file Theodore Ts'o
2014-05-05 14:04 ` Lukáš Czerner
2014-05-05 14:46 ` Eric Sandeen
2014-05-05 14:49 ` Theodore Ts'o
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=alpine.LFD.2.00.1405051532280.2223@localhost.localdomain \
--to=lczerner@redhat.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.edu \
/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