[PATCH 06/16] btrfs-progs: check: Move imode_to_type function to check/common.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This function is shared between original and lowmem mode, and it's small
enough, so move it to check/common.h.

Signed-off-by: Qu Wenruo <wqu@xxxxxxxx>
---
 check/common.h | 19 +++++++++++++++++++
 check/main.c   | 17 -----------------
 2 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/check/common.h b/check/common.h
index 8d93ddbf4afb..3e0a5ebee54b 100644
--- a/check/common.h
+++ b/check/common.h
@@ -20,6 +20,8 @@
  */
 #ifndef __BTRFS_CHECK_COMMON_H__
 #define __BTRFS_CHECK_COMMON_H__
+
+#include <sys/stat.h>
 #include "ctree.h"
 
 /*
@@ -53,4 +55,21 @@ 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
+}
+
 #endif
diff --git a/check/main.c b/check/main.c
index bb927ecc87ee..eaa8e7fbde20 100644
--- a/check/main.c
+++ b/check/main.c
@@ -425,23 +425,6 @@ static void record_root_in_trans(struct btrfs_trans_handle *trans,
 	}
 }
 
-static 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 int device_record_compare(struct rb_node *node1, struct rb_node *node2)
 {
 	struct device_record *rec1;
-- 
2.15.1

--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Filesystem Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux