Make Multi Mount Protection (MMP) optional at configure time.

Add --{en,dis}able-mmp options for configure, default to enabled.
Also make tools fail gracefully in the event of encoutering a filesystem
with MMP enabled when the tools were compiled with --disable-mmp

Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
pu
Tony Breeds 2012-06-26 11:42:15 +10:00 committed by Theodore Ts'o
parent 119f1ad8c9
commit d6a4bcb517
7 changed files with 652 additions and 513 deletions

1095
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -746,6 +746,23 @@ AC_MSG_RESULT([Building uuidd by default])
)
AC_SUBST(UUIDD_CMT)
dnl
dnl handle --disable-mmp
dnl
AH_TEMPLATE([CONFIG_MMP], [Define to 1 to enable mmp support])
AC_ARG_ENABLE([mmp],
[ --disable-mmp disable support mmp, Multi Mount Protection],
if test "$enableval" = "no"
then
AC_MSG_RESULT([Disabling mmp support])
else
AC_MSG_RESULT([Enabling mmp support])
AC_DEFINE(CONFIG_MMP, 1)
fi
,
AC_MSG_RESULT([Enabling mmp support by default])
AC_DEFINE(CONFIG_MMP, 1)
)
dnl
dnl
dnl
MAKEFILE_LIBRARY=$srcdir/lib/Makefile.library

View File

@ -2194,6 +2194,7 @@ void do_punch(int argc, char *argv[])
void do_dump_mmp(int argc EXT2FS_ATTR((unused)), char *argv[])
{
#if CONFIG_MMP
struct ext2_super_block *sb;
struct mmp_struct *mmp_s;
time_t t;
@ -2237,6 +2238,10 @@ void do_dump_mmp(int argc EXT2FS_ATTR((unused)), char *argv[])
fprintf(stdout, "node_name: %s\n", mmp_s->mmp_nodename);
fprintf(stdout, "device_name: %s\n", mmp_s->mmp_bdevname);
fprintf(stdout, "magic: 0x%x\n", mmp_s->mmp_magic);
#else
fprintf(stdout, "MMP is unsupported, please recompile with "
"--enable-mmp\n");
#endif
}
static int source_file(const char *cmd_file, int sci_idx)

View File

@ -765,6 +765,7 @@ static errcode_t parse_mmp_clear(struct field_set_info *info,
void do_set_mmp_value(int argc, char *argv[])
{
#ifdef CONFIG_MMP
const char *usage = "<field> <value>\n"
"\t\"set_mmp_value -l\" will list the names of "
"MMP fields\n\twhich can be set.";
@ -819,5 +820,9 @@ void do_set_mmp_value(int argc, char *argv[])
&set_mmp);
*mmp_s = set_mmp;
}
#else
fprintf(stdout, "MMP is unsupported, please recompile with "
"--enable-mmp\n");
#endif
}

View File

@ -12,6 +12,9 @@
/* Define to 1 if debugging ext3/4 journal code */
#undef CONFIG_JBD_DEBUG
/* Define to 1 to enable mmp support */
#undef CONFIG_MMP
/* Define to 1 to enable quota support */
#undef CONFIG_QUOTA

View File

@ -559,6 +559,12 @@ typedef struct ext2_icount *ext2_icount_t;
#define EXT2_LIB_INCOMPAT_COMPRESSION (0)
#endif
#ifdef CONFIG_MMP
#define EXT4_LIB_INCOMPAT_MMP EXT4_FEATURE_INCOMPAT_MMP
#else
#define EXT4_LIB_INCOMPAT_MMP (0)
#endif
#define EXT2_LIB_FEATURE_INCOMPAT_SUPP (EXT2_FEATURE_INCOMPAT_FILETYPE|\
EXT2_LIB_INCOMPAT_COMPRESSION|\
EXT3_FEATURE_INCOMPAT_JOURNAL_DEV|\
@ -566,7 +572,7 @@ typedef struct ext2_icount *ext2_icount_t;
EXT3_FEATURE_INCOMPAT_RECOVER|\
EXT3_FEATURE_INCOMPAT_EXTENTS|\
EXT4_FEATURE_INCOMPAT_FLEX_BG|\
EXT4_FEATURE_INCOMPAT_MMP|\
EXT4_LIB_INCOMPAT_MMP|\
EXT4_FEATURE_INCOMPAT_64BIT)
#ifdef CONFIG_QUOTA
#define EXT2_LIB_FEATURE_RO_COMPAT_SUPP (EXT2_FEATURE_RO_COMPAT_SPARSE_SUPER|\

View File

@ -33,6 +33,7 @@
errcode_t ext2fs_mmp_read(ext2_filsys fs, blk64_t mmp_blk, void *buf)
{
#ifdef CONFIG_MMP
struct mmp_struct *mmp_cmp;
errcode_t retval = 0;
@ -88,10 +89,14 @@ errcode_t ext2fs_mmp_read(ext2_filsys fs, blk64_t mmp_blk, void *buf)
out:
return retval;
#else
return EXT2_ET_OP_NOT_SUPPORTED;
#endif
}
errcode_t ext2fs_mmp_write(ext2_filsys fs, blk64_t mmp_blk, void *buf)
{
#ifdef CONFIG_MMP
struct mmp_struct *mmp_s = buf;
struct timeval tv;
errcode_t retval = 0;
@ -119,6 +124,9 @@ errcode_t ext2fs_mmp_write(ext2_filsys fs, blk64_t mmp_blk, void *buf)
/* Make sure the block gets to disk quickly */
io_channel_flush(fs->io);
return retval;
#else
return EXT2_ET_OP_NOT_SUPPORTED;
#endif
}
#ifdef HAVE_SRANDOM
@ -128,6 +136,7 @@ errcode_t ext2fs_mmp_write(ext2_filsys fs, blk64_t mmp_blk, void *buf)
unsigned ext2fs_mmp_new_seq()
{
#ifdef CONFIG_MMP
unsigned new_seq;
struct timeval tv;
@ -144,6 +153,9 @@ unsigned ext2fs_mmp_new_seq()
} while (new_seq > EXT4_MMP_SEQ_MAX);
return new_seq;
#else
return EXT2_ET_OP_NOT_SUPPORTED;
#endif
}
static errcode_t ext2fs_mmp_reset(ext2_filsys fs)
@ -182,6 +194,7 @@ out:
errcode_t ext2fs_mmp_clear(ext2_filsys fs)
{
#ifdef CONFIG_MMP
errcode_t retval = 0;
if (!(fs->flags & EXT2_FLAG_RW))
@ -190,10 +203,14 @@ errcode_t ext2fs_mmp_clear(ext2_filsys fs)
retval = ext2fs_mmp_reset(fs);
return retval;
#else
return EXT2_ET_OP_NOT_SUPPORTED;
#endif
}
errcode_t ext2fs_mmp_init(ext2_filsys fs)
{
#ifdef CONFIG_MMP
struct ext2_super_block *sb = fs->super;
blk64_t mmp_block;
errcode_t retval;
@ -222,6 +239,9 @@ errcode_t ext2fs_mmp_init(ext2_filsys fs)
out:
return retval;
#else
return EXT2_ET_OP_NOT_SUPPORTED;
#endif
}
/*
@ -229,6 +249,7 @@ out:
*/
errcode_t ext2fs_mmp_start(ext2_filsys fs)
{
#ifdef CONFIG_MMP
struct mmp_struct *mmp_s;
unsigned seq;
unsigned int mmp_check_interval;
@ -318,6 +339,9 @@ clean_seq:
mmp_error:
return retval;
#else
return EXT2_ET_OP_NOT_SUPPORTED;
#endif
}
/*
@ -328,6 +352,7 @@ mmp_error:
*/
errcode_t ext2fs_mmp_stop(ext2_filsys fs)
{
#ifdef CONFIG_MMP
struct mmp_struct *mmp, *mmp_cmp;
errcode_t retval = 0;
@ -357,6 +382,9 @@ mmp_error:
}
return retval;
#else
return EXT2_ET_OP_NOT_SUPPORTED;
#endif
}
#define EXT2_MIN_MMP_UPDATE_INTERVAL 60
@ -366,6 +394,7 @@ mmp_error:
*/
errcode_t ext2fs_mmp_update(ext2_filsys fs)
{
#ifdef CONFIG_MMP
struct mmp_struct *mmp, *mmp_cmp;
struct timeval tv;
errcode_t retval = 0;
@ -394,4 +423,7 @@ errcode_t ext2fs_mmp_update(ext2_filsys fs)
mmp_error:
return retval;
#else
return EXT2_ET_OP_NOT_SUPPORTED;
#endif
}