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) */
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|
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")) {
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);
"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;
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);