Whamcloud - gitweb
e2fsck: fix project quota support
[tools/e2fsprogs.git] / lib / ext2fs / mmp.c
index 00f3461..9a771de 100644 (file)
@@ -12,6 +12,9 @@
 #ifndef _GNU_SOURCE
 #define _GNU_SOURCE
 #endif
+#ifndef _DEFAULT_SOURCE
+#define _DEFAULT_SOURCE        /* since glibc 2.20 _SVID_SOURCE is deprecated */
+#endif
 
 #include "config.h"
 
 #define O_DIRECT 0
 #endif
 
+#pragma GCC diagnostic push
+#ifndef CONFIG_MMP
+#pragma GCC diagnostic ignored "-Wunused-parameter"
+#endif
+
 errcode_t ext2fs_mmp_read(ext2_filsys fs, blk64_t mmp_blk, void *buf)
 {
 #ifdef CONFIG_MMP
@@ -38,7 +46,7 @@ errcode_t ext2fs_mmp_read(ext2_filsys fs, blk64_t mmp_blk, void *buf)
        errcode_t retval = 0;
 
        if ((mmp_blk <= fs->super->s_first_data_block) ||
-           (mmp_blk >= fs->super->s_blocks_count))
+           (mmp_blk >= ext2fs_blocks_count(fs->super)))
                return EXT2_ET_MMP_BAD_BLOCK;
 
        /* ext2fs_open() reserves fd0,1,2 to avoid stdio collision, so checking
@@ -144,7 +152,7 @@ errcode_t ext2fs_mmp_write(ext2_filsys fs, blk64_t mmp_blk, void *buf)
 #define rand()         random()
 #endif
 
-unsigned ext2fs_mmp_new_seq()
+unsigned ext2fs_mmp_new_seq(void)
 {
 #ifdef CONFIG_MMP
        unsigned new_seq;
@@ -168,6 +176,7 @@ unsigned ext2fs_mmp_new_seq()
 #endif
 }
 
+#ifdef CONFIG_MMP
 static errcode_t ext2fs_mmp_reset(ext2_filsys fs)
 {
        struct mmp_struct *mmp_s = NULL;
@@ -201,6 +210,7 @@ static errcode_t ext2fs_mmp_reset(ext2_filsys fs)
 out:
        return retval;
 }
+#endif
 
 errcode_t ext2fs_mmp_update(ext2_filsys fs)
 {
@@ -371,7 +381,7 @@ errcode_t ext2fs_mmp_stop(ext2_filsys fs)
        struct mmp_struct *mmp, *mmp_cmp;
        errcode_t retval = 0;
 
-       if (!(fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_MMP) ||
+       if (!ext2fs_has_feature_mmp(fs->super) ||
            !(fs->flags & EXT2_FLAG_RW) || (fs->flags & EXT2_FLAG_SKIP_MMP))
                goto mmp_error;
 
@@ -398,6 +408,10 @@ mmp_error:
 
        return retval;
 #else
+       if (!ext2fs_has_feature_mmp(fs->super) ||
+           !(fs->flags & EXT2_FLAG_RW) || (fs->flags & EXT2_FLAG_SKIP_MMP))
+               return 0;
+
        return EXT2_ET_OP_NOT_SUPPORTED;
 #endif
 }
@@ -414,7 +428,7 @@ errcode_t ext2fs_mmp_update2(ext2_filsys fs, int immediately)
        struct timeval tv;
        errcode_t retval = 0;
 
-       if (!(fs->super->s_feature_incompat & EXT4_FEATURE_INCOMPAT_MMP) ||
+       if (!ext2fs_has_feature_mmp(fs->super) ||
            !(fs->flags & EXT2_FLAG_RW) || (fs->flags & EXT2_FLAG_SKIP_MMP))
                return 0;
 
@@ -440,6 +454,11 @@ errcode_t ext2fs_mmp_update2(ext2_filsys fs, int immediately)
 mmp_error:
        return retval;
 #else
+       if (!ext2fs_has_feature_mmp(fs->super) ||
+           !(fs->flags & EXT2_FLAG_RW) || (fs->flags & EXT2_FLAG_SKIP_MMP))
+               return 0;
+
        return EXT2_ET_OP_NOT_SUPPORTED;
 #endif
 }
+#pragma GCC diagnostic pop