btrfs-progs: check: move reada_walk_down to check/common.c
[platform/upstream/btrfs-progs.git] / check / common.h
index 8d93ddb..34b2f8a 100644 (file)
@@ -20,6 +20,8 @@
  */
 #ifndef __BTRFS_CHECK_COMMON_H__
 #define __BTRFS_CHECK_COMMON_H__
+
+#include <sys/stat.h>
 #include "ctree.h"
 
 /*
@@ -53,4 +55,43 @@ extern struct btrfs_fs_info *global_info;
 extern struct task_ctx ctx;
 extern struct cache_tree *roots_info_cache;
 
+static inline u8 imode_to_type(u32 imode)
+{
+#define S_SHIFT 12
+       static unsigned char btrfs_type_by_mode[S_IFMT >> S_SHIFT] = {
+               [S_IFREG >> S_SHIFT]    = BTRFS_FT_REG_FILE,
+               [S_IFDIR >> S_SHIFT]    = BTRFS_FT_DIR,
+               [S_IFCHR >> S_SHIFT]    = BTRFS_FT_CHRDEV,
+               [S_IFBLK >> S_SHIFT]    = BTRFS_FT_BLKDEV,
+               [S_IFIFO >> S_SHIFT]    = BTRFS_FT_FIFO,
+               [S_IFSOCK >> S_SHIFT]   = BTRFS_FT_SOCK,
+               [S_IFLNK >> S_SHIFT]    = BTRFS_FT_SYMLINK,
+       };
+
+       return btrfs_type_by_mode[(imode & S_IFMT) >> S_SHIFT];
+#undef S_SHIFT
+}
+
+static inline int fs_root_objectid(u64 objectid)
+{
+       if (objectid == BTRFS_TREE_RELOC_OBJECTID ||
+           objectid == BTRFS_DATA_RELOC_TREE_OBJECTID)
+               return 1;
+       return is_fstree(objectid);
+}
+
+int count_csum_range(struct btrfs_fs_info *fs_info, u64 start,
+                    u64 len, u64 *found);
+int insert_inode_item(struct btrfs_trans_handle *trans,
+                     struct btrfs_root *root, u64 ino, u64 size,
+                     u64 nbytes, u64 nlink, u32 mode);
+int link_inode_to_lostfound(struct btrfs_trans_handle *trans,
+                           struct btrfs_root *root,
+                           struct btrfs_path *path,
+                           u64 ino, char *namebuf, u32 name_len,
+                           u8 filetype, u64 *ref_count);
+void check_dev_size_alignment(u64 devid, u64 total_bytes, u32 sectorsize);
+void reada_walk_down(struct btrfs_root *root, struct extent_buffer *node,
+                    int slot);
+
 #endif