]> git.ipfire.org Git - thirdparty/e2fsprogs.git/blobdiff - e2fsck/jfs_user.h
Merge branch 'maint' into next
[thirdparty/e2fsprogs.git] / e2fsck / jfs_user.h
index be81f43f103e7800a4069879d66ac504cefaed2f..d30b728d1e8525210964d377f8612ee0abe6348c 100644 (file)
@@ -38,10 +38,10 @@ struct buffer_head {
 #endif
        io_channel      b_io;
        int             b_size;
-       unsigned long long b_blocknr;
-       int             b_dirty;
-       int             b_uptodate;
        int             b_err;
+       unsigned int    b_dirty:1;
+       unsigned int    b_uptodate:1;
+       unsigned long long b_blocknr;
        char            b_data[1024];
 };
 
@@ -137,6 +137,32 @@ _INLINE_ void do_cache_destroy(lkmem_cache_t *cache)
        free(cache);
 }
 
+/* generic hashing taken from the Linux kernel */
+#define GOLDEN_RATIO_32 0x61C88647
+#define GOLDEN_RATIO_64 0x61C8864680B583EBull
+
+_INLINE_ __u32 __hash_32(__u32 val)
+{
+       return val * GOLDEN_RATIO_32;
+}
+
+_INLINE_ __u32 hash_32(__u32 val, unsigned int bits)
+{
+       /* High bits are more random, so use them. */
+       return __hash_32(val) >> (32 - bits);
+}
+
+_INLINE_ __u32 hash_64(__u64 val, unsigned int bits)
+{
+       if (sizeof(long) >= 8) {
+               /* 64x64-bit multiply is efficient on all 64-bit processors */
+               return val * GOLDEN_RATIO_64 >> (64 - bits);
+       } else {
+               /* Hash 64 bits using only 32x32-bit multiply. */
+               return hash_32((__u32)val ^ __hash_32(val >> 32), bits);
+       }
+}
+
 #undef _INLINE_
 #endif
 
@@ -181,6 +207,13 @@ extern e2fsck_t e2fsck_global_ctx;  /* Try your very best not to use this! */
 
 #endif /* DEBUGFS */
 
+#ifndef EFSBADCRC
+#define EFSBADCRC      EXT2_ET_BAD_CRC
+#endif
+#ifndef EFSCORRUPTED
+#define EFSCORRUPTED   EXT2_ET_FILESYSTEM_CORRUPTED
+#endif
+
 /* recovery.c */
 extern int     journal_recover    (journal_t *journal);
 extern int     journal_skip_recovery (journal_t *);