btrfs-progs: check: Move imode_to_type function to check/common.h
This function is shared between original and lowmem mode, and it's small enough, so move it to check/common.h. Reviewed-by: Su Yue <suy.fnst@cn.fujitsu.com> Signed-off-by: Qu Wenruo <wqu@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
96c6e1f0aa
commit
58a19f1ea7
|
@ -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
|
||||
|
|
17
check/main.c
17
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;
|
||||
|
|
Loading…
Reference in New Issue