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;
}
mmp_cmp = fs->mmp_cmp;
+
+ if (!(fs->flags & EXT2_FLAG_IGNORE_CSUM_ERRORS) &&
+ !ext2fs_mmp_csum_verify(fs, mmp_cmp))
+ retval = EXT2_ET_MMP_CSUM_INVALID;
+
#ifdef WORDS_BIGENDIAN
ext2fs_swap_mmp(mmp_cmp);
#endif
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;
ext2fs_swap_mmp(mmp_s);
#endif
+ retval = ext2fs_mmp_csum_set(fs, mmp_s);
+ if (retval)
+ return retval;
+
/* I was tempted to make this use O_DIRECT and the mmp_fd, but
* this caused no end of grief, while leaving it as-is works. */
retval = io_channel_write_blk64(fs->io, mmp_blk, -(int)sizeof(struct mmp_struct), 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
unsigned ext2fs_mmp_new_seq(void)
{
+#ifdef CONFIG_MMP
unsigned new_seq;
struct timeval tv;
} 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)
return retval;
}
+errcode_t ext2fs_mmp_update(ext2_filsys fs)
+{
+ return ext2fs_mmp_update2(fs, 0);
+}
+
errcode_t ext2fs_mmp_clear(ext2_filsys fs)
{
+#ifdef CONFIG_MMP
errcode_t retval = 0;
if (!(fs->flags & EXT2_FLAG_RW))
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;
out:
return retval;
+#else
+ return EXT2_ET_OP_NOT_SUPPORTED;
+#endif
}
/*
*/
errcode_t ext2fs_mmp_start(ext2_filsys fs)
{
+#ifdef CONFIG_MMP
struct mmp_struct *mmp_s;
unsigned seq;
unsigned int mmp_check_interval;
mmp_error:
return retval;
+#else
+ return EXT2_ET_OP_NOT_SUPPORTED;
+#endif
}
/*
*/
errcode_t ext2fs_mmp_stop(ext2_filsys fs)
{
+#ifdef CONFIG_MMP
struct mmp_struct *mmp, *mmp_cmp;
errcode_t retval = 0;
}
return retval;
+#else
+ return EXT2_ET_OP_NOT_SUPPORTED;
+#endif
}
#define EXT2_MIN_MMP_UPDATE_INTERVAL 60
/*
* Update the on-disk mmp buffer, after checking that it hasn't been changed.
*/
-errcode_t ext2fs_mmp_update(ext2_filsys fs)
+errcode_t ext2fs_mmp_update2(ext2_filsys fs, int immediately)
{
+#ifdef CONFIG_MMP
struct mmp_struct *mmp, *mmp_cmp;
struct timeval tv;
errcode_t retval = 0;
return 0;
gettimeofday(&tv, 0);
- if (tv.tv_sec - fs->mmp_last_written < EXT2_MIN_MMP_UPDATE_INTERVAL)
+ if (!immediately &&
+ tv.tv_sec - fs->mmp_last_written < EXT2_MIN_MMP_UPDATE_INTERVAL)
return 0;
retval = ext2fs_mmp_read(fs, fs->super->s_mmp_block, NULL);
mmp_error:
return retval;
+#else
+ return EXT2_ET_OP_NOT_SUPPORTED;
+#endif
}