diff options
Diffstat (limited to 'common/utils.h')
-rw-r--r-- | common/utils.h | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/common/utils.h b/common/utils.h index fb605f34..56d00ed8 100644 --- a/common/utils.h +++ b/common/utils.h @@ -22,6 +22,7 @@ #include "kerncompat.h" #include <stdbool.h> #include <stddef.h> +#include <sys/stat.h> #include "kernel-lib/list.h" #include "kernel-shared/volumes.h" #include "common/fsfeatures.h" @@ -40,6 +41,21 @@ enum exclusive_operation { BTRFS_EXCLOP_UNKNOWN = -1, }; +static inline u32 btrfs_type_to_imode(u8 type) +{ + static u32 imode_by_btrfs_type[] = { + [BTRFS_FT_REG_FILE] = S_IFREG, + [BTRFS_FT_DIR] = S_IFDIR, + [BTRFS_FT_CHRDEV] = S_IFCHR, + [BTRFS_FT_BLKDEV] = S_IFBLK, + [BTRFS_FT_FIFO] = S_IFIFO, + [BTRFS_FT_SOCK] = S_IFSOCK, + [BTRFS_FT_SYMLINK] = S_IFLNK, + }; + + return imode_by_btrfs_type[(type)]; +} + /* 2 for "0x", 2 for each byte, plus nul */ #define BTRFS_CSUM_STRING_LEN (2 + 2 * BTRFS_CSUM_SIZE + 1) void btrfs_format_csum(u16 csum_type, const u8 *data, char *output); |