summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2014-04-26 12:16:44 -0400
committerTheodore Ts'o <tytso@mit.edu>2014-04-26 13:12:39 -0400
commit83c469bc33e94dc680cacde3e7b12bbdb3b085af (patch)
treeca7aa852055b692aca01aeb73466e091efa464fc
parent6f6f567fac3e4c504b8ac5408465ebb7f7395554 (diff)
downloade2fsprogs-83c469bc33e94dc680cacde3e7b12bbdb3b085af.tar.gz
mke2fs: don't ask the proceed question using a regular file
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>
-rw-r--r--misc/mke2fs.c5
-rw-r--r--misc/tune2fs.c2
-rw-r--r--misc/util.c16
-rw-r--r--misc/util.h8
4 files changed, 21 insertions, 10 deletions
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index 176dc401..637ace2a 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 3359c4aa..d61dbfb8 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 92ab79f0..0c3787c1 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 11604d01..470556a8 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);