Whamcloud - gitweb
LU-6030 ldiskfs: support pdirop split for RHEL6.5
[fs/lustre-release.git] / lustre / utils / llog_reader.c
index e2cd538..cf84329 100644 (file)
@@ -39,7 +39,9 @@
 #include <stdio.h>
 #include <sys/types.h>
 #include <sys/stat.h>
-#include <endian.h>
+#ifdef HAVE_ENDIAN_H
+# include <endian.h>
+#endif
 #include <unistd.h>
 #include <fcntl.h>
 
@@ -56,7 +58,9 @@ static inline int ext2_test_bit(int nr, const void *addr)
        const unsigned char *tmp = addr;
        return (tmp[nr >> 3] >> (nr & 7)) & 1;
 #else
-       return test_bit(nr, addr);
+       const unsigned long *tmp = addr;
+       return ((1UL << (nr & (BITS_PER_LONG - 1))) &
+               ((tmp)[nr / BITS_PER_LONG])) != 0;
 #endif
 }
 
@@ -198,18 +202,18 @@ int llog_pack_buffer(int fd, struct llog_log_hdr **llog,
 
                cur_rec = (struct llog_rec_hdr *)ptr;
                idx = le32_to_cpu(cur_rec->lrh_index);
-                recs_pr[i] = cur_rec;
-
-                if (ext2_test_bit(idx, (*llog)->llh_bitmap)) {
-                        if (le32_to_cpu(cur_rec->lrh_type) != OBD_CFG_REC)
-                                printf("rec #%d type=%x len=%u\n", idx,
-                                       cur_rec->lrh_type, cur_rec->lrh_len);
-                } else {
-                        printf("Bit %d of %d not set\n", idx, recs_num);
-                        cur_rec->lrh_id = CANCELLED;
-                        /* The header counts only set records */
-                        i--;
-                }
+               recs_pr[i] = cur_rec;
+
+               if (ext2_test_bit(idx, LLOG_HDR_BITMAP(*llog))) {
+                       if (le32_to_cpu(cur_rec->lrh_type) != OBD_CFG_REC)
+                               printf("rec #%d type=%x len=%u\n", idx,
+                                      cur_rec->lrh_type, cur_rec->lrh_len);
+               } else {
+                       printf("Bit %d of %d not set\n", idx, recs_num);
+                       cur_rec->lrh_id = CANCELLED;
+                       /* The header counts only set records */
+                       i--;
+               }
 
                 ptr += le32_to_cpu(cur_rec->lrh_len);
                 if ((ptr - file_buf) > file_size) {