Whamcloud - gitweb
e2fsck: clear clang warnings for missing field initializers in structs
[tools/e2fsprogs.git] / e2fsck / jfs_user.h
index adb8ae9..8289795 100644 (file)
@@ -12,6 +12,8 @@
 #define _JFS_USER_H
 
 #ifdef DEBUGFS
+#include <stdio.h>
+#include <stdlib.h>
 #if EXT2_FLAT_INCLUDES
 #include "ext2_fs.h"
 #include "ext2fs.h"
 #include "e2fsck.h"
 #endif
 
+#if __STDC_VERSION__ < 199901L
+# if __GNUC__ >= 2 || _MSC_VER >= 1300
+#  define __func__ __FUNCTION__
+# else
+#  define __func__ "<unknown>"
+# endif
+#endif
+
 struct buffer_head {
 #ifdef DEBUGFS
        ext2_filsys     b_fs;
@@ -36,10 +46,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];
 };
 
@@ -65,8 +75,6 @@ struct kdev_s {
 #define K_DEV_FS       1
 #define K_DEV_JOURNAL  2
 
-typedef struct kdev_s *kdev_t;
-
 #define lock_buffer(bh) do {} while (0)
 #define unlock_buffer(bh) do {} while (0)
 #define buffer_req(bh) 1
@@ -85,9 +93,6 @@ typedef struct {
 
 #define cond_resched() do { } while (0)
 
-typedef unsigned int __be32;
-typedef __u64 __be64;
-
 #define __init
 
 /*
@@ -103,6 +108,9 @@ typedef __u64 __be64;
 extern lkmem_cache_t *do_cache_create(int len);
 extern void do_cache_destroy(lkmem_cache_t *cache);
 extern size_t journal_tag_bytes(journal_t *journal);
+extern __u32 __hash_32(__u32 val);
+extern __u32 hash_32(__u32 val, unsigned int bits);
+extern __u32 hash_64(__u64 val, unsigned int bits);
 #endif
 
 #if (defined(E2FSCK_INCLUDE_INLINE_FUNCS) || !defined(NO_INLINE_FUNCS))
@@ -124,7 +132,6 @@ extern size_t journal_tag_bytes(journal_t *journal);
 #endif /* __STDC_VERSION__ >= 199901L */
 #endif /* E2FSCK_INCLUDE_INLINE_FUNCS */
 
-
 _INLINE_ lkmem_cache_t *do_cache_create(int len)
 {
        lkmem_cache_t *new_cache;
@@ -140,6 +147,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
 
@@ -170,23 +203,6 @@ void wait_on_buffer(struct buffer_head *bh);
 #define JSB_HAS_INCOMPAT_FEATURE(jsb, mask)                            \
        ((jsb)->s_header.h_blocktype == ext2fs_cpu_to_be32(JFS_SUPERBLOCK_V2) &&        \
         ((jsb)->s_feature_incompat & ext2fs_cpu_to_be32((mask))))
-static inline size_t journal_super_tag_bytes(journal_superblock_t *jsb)
-{
-       size_t sz;
-
-       if (JSB_HAS_INCOMPAT_FEATURE(jsb, JFS_FEATURE_INCOMPAT_CSUM_V3))
-               return sizeof(journal_block_tag3_t);
-
-       sz = sizeof(journal_block_tag_t);
-
-       if (JSB_HAS_INCOMPAT_FEATURE(jsb, JFS_FEATURE_INCOMPAT_CSUM_V2))
-               sz += sizeof(__u16);
-
-       if (JSB_HAS_INCOMPAT_FEATURE(jsb, JFS_FEATURE_INCOMPAT_64BIT))
-               return sz;
-
-       return sz - sizeof(__u32);
-}
 #else  /* !DEBUGFS */
 
 extern e2fsck_t e2fsck_global_ctx;  /* Try your very best not to use this! */
@@ -195,10 +211,31 @@ extern e2fsck_t e2fsck_global_ctx;  /* Try your very best not to use this! */
        do { if (!(assert)) {                                           \
                printf ("Assertion failure in %s() at %s line %d: "     \
                        "\"%s\"\n",                                     \
-                       __FUNCTION__, __FILE__, __LINE__, # assert);    \
+                       __func__, __FILE__, __LINE__, # assert);        \
                fatal_error(e2fsck_global_ctx, 0);                      \
        } } while (0)
 
 #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 *);
+
+/* revoke.c */
+extern int     journal_init_revoke(journal_t *, int);
+extern void    journal_destroy_revoke(journal_t *);
+extern void    journal_destroy_revoke_caches(void);
+extern int     journal_init_revoke_caches(void);
+
+extern int     journal_set_revoke(journal_t *, unsigned long long, tid_t);
+extern int     journal_test_revoke(journal_t *, unsigned long long, tid_t);
+extern void    journal_clear_revoke(journal_t *);
+
 #endif /* _JFS_USER_H */