All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/7] mke2fs: don't ask the proceed question using a regular file
@ 2014-04-27  0:00 Theodore Ts'o
  2014-04-27  0:00 ` [PATCH 2/7] mke2fs, tune2fs: call proceed_question() from check_plausibility()'s caller Theodore Ts'o
                   ` (6 more replies)
  0 siblings, 7 replies; 27+ messages in thread
From: Theodore Ts'o @ 2014-04-27  0:00 UTC (permalink / raw)
  To: Ext4 Developers List; +Cc: Theodore Ts'o

Very often people are creating file systems using regular files, so we
shouldn't ask the user to confirm using the proceed question.
Otherwise it encourages users to use the -F flag, which is a bad
thing.

We do need to continue to check if the external journal device is a
block device.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---
 misc/mke2fs.c  |  5 +++--
 misc/tune2fs.c |  2 +-
 misc/util.c    | 16 ++++++++++------
 misc/util.h    |  8 +++++++-
 4 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 176dc40..637ace2 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -1750,7 +1750,7 @@ profile_error:
 		usage();
 
 	if (!force)
-		check_plausibility(device_name);
+		check_plausibility(device_name, 0, NULL);
 	check_mount(device_name, force, _("filesystem"));
 
 	/* Determine the size of the device (if possible) */
@@ -2782,7 +2782,8 @@ int main (int argc, char *argv[])
 		ext2_filsys	jfs;
 
 		if (!force)
-			check_plausibility(journal_device);
+			check_plausibility(journal_device, CHECK_BLOCK_DEV,
+					   NULL);
 		check_mount(journal_device, force, _("journal"));
 
 		retval = ext2fs_open(journal_device, EXT2_FLAG_RW|
diff --git a/misc/tune2fs.c b/misc/tune2fs.c
index 3359c4a..d61dbfb 100644
--- a/misc/tune2fs.c
+++ b/misc/tune2fs.c
@@ -673,7 +673,7 @@ static int add_journal(ext2_filsys fs)
 		goto err;
 	}
 	if (journal_device) {
-		check_plausibility(journal_device);
+		check_plausibility(journal_device, CHECK_BLOCK_DEV, NULL);
 		check_mount(journal_device, 0, _("journal"));
 #ifdef CONFIG_TESTIO_DEBUG
 		if (getenv("TEST_IO_FLAGS") || getenv("TEST_IO_BLOCK")) {
diff --git a/misc/util.c b/misc/util.c
index 92ab79f..0c3787c 100644
--- a/misc/util.c
+++ b/misc/util.c
@@ -80,9 +80,9 @@ void proceed_question(void)
 		exit(1);
 }
 
-void check_plausibility(const char *device)
+void check_plausibility(const char *device, int flags, int *ret_is_dev)
 {
-	int val;
+	int val, is_dev = 0;
 	ext2fs_struct_stat s;
 
 	val = ext2fs_stat(device, &s);
@@ -95,13 +95,17 @@ void check_plausibility(const char *device)
 				"did you specify it correctly?\n"), stderr);
 		exit(1);
 	}
+	if (S_ISBLK(s.st_mode))
+		is_dev = 1;
 #if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
 	/* On FreeBSD, all disk devices are character specials */
-	if (!S_ISBLK(s.st_mode) && !S_ISCHR(s.st_mode))
-#else
-	if (!S_ISBLK(s.st_mode))
+	if (S_ISCHR(s.st_mode))
+		is_dev = 1;
 #endif
-	{
+	if (ret_is_dev)
+		*ret_is_dev = is_dev;
+
+	if ((flags & CHECK_BLOCK_DEV) && !is_dev) {
 		printf(_("%s is not a block special device.\n"), device);
 		proceed_question();
 		return;
diff --git a/misc/util.h b/misc/util.h
index 11604d0..470556a 100644
--- a/misc/util.h
+++ b/misc/util.h
@@ -15,12 +15,18 @@ extern int	 journal_flags;
 extern char	*journal_device;
 extern char	*journal_location_string;
 
+/*
+ * Flags for check_plausibility()
+ */
+#define CHECK_BLOCK_DEV	0x0001
+
 #ifndef HAVE_STRCASECMP
 extern int strcasecmp (char *s1, char *s2);
 #endif
 extern char *get_progname(char *argv_zero);
 extern void proceed_question(void);
-extern void check_plausibility(const char *device);
+extern void check_plausibility(const char *device, int flags,
+			       int *ret_is_dev);
 extern void parse_journal_opts(const char *opts);
 extern void check_mount(const char *device, int force, const char *type);
 extern unsigned int figure_journal_size(int size, ext2_filsys fs);
-- 
1.9.0


^ permalink raw reply related	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2014-05-05 15:17 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-27  0:00 [PATCH 1/7] mke2fs: don't ask the proceed question using a regular file Theodore Ts'o
2014-04-27  0:00 ` [PATCH 2/7] mke2fs, tune2fs: call proceed_question() from check_plausibility()'s caller Theodore Ts'o
2014-04-27  0:00 ` [PATCH 3/7] mke2fs: don't complain if the regular file is too small Theodore Ts'o
2014-04-28 15:26   ` Eric Sandeen
2014-04-27  0:00 ` [PATCH 4/7] mke2fs: create a regular file if necessary Theodore Ts'o
2014-04-30 12:21   ` Lukáš Czerner
2014-04-30 14:06     ` Theodore Ts'o
2014-04-30 14:14       ` Lukáš Czerner
2014-04-30 14:18         ` Theodore Ts'o
2014-04-30 14:35           ` Lukáš Czerner
2014-04-30 15:26             ` Theodore Ts'o
2014-05-05 15:17   ` Eric Sandeen
2014-04-27  0:00 ` [PATCH 5/7] mke2fs: proceed if the user doesn't type anything after 5 seconds Theodore Ts'o
2014-04-28 15:33   ` Eric Sandeen
2014-04-28 15:36     ` Eric Sandeen
2014-04-28 23:26     ` Theodore Ts'o
2014-04-29  0:32       ` Eric Sandeen
2014-04-30  6:53         ` Lukáš Czerner
2014-04-27  0:00 ` [PATCH 6/7] mke2fs: check for pre-existing file system Theodore Ts'o
2014-04-30 11:50   ` Lukáš Czerner
2014-04-30 13:44     ` Lukáš Czerner
2014-04-30 14:10     ` Theodore Ts'o
2014-04-27  0:00 ` [PATCH 7/7] mke2fs: only print the low-level file system stats in verbose mode Theodore Ts'o
2014-04-30 11:22   ` Lukáš Czerner
2014-04-30 14:01     ` Theodore Ts'o
2014-04-30 14:25       ` Lukáš Czerner
2014-04-28 15:24 ` [PATCH 1/7] mke2fs: don't ask the proceed question using a regular file Eric Sandeen

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.