diff --git a/convert/source-ext2.c b/convert/source-ext2.c index cdaf6698..f1075da5 100644 --- a/convert/source-ext2.c +++ b/convert/source-ext2.c @@ -638,21 +638,12 @@ out: free(ext2_inode); return ret; } -#define MINORBITS 20 -#define MKDEV(ma, mi) (((ma) << MINORBITS) | (mi)) static inline dev_t old_decode_dev(u16 val) { return MKDEV((val >> 8) & 255, val & 255); } -static inline dev_t new_decode_dev(u32 dev) -{ - unsigned major = (dev & 0xfff00) >> 8; - unsigned minor = (dev & 0xff) | ((dev >> 12) & 0xfff00); - return MKDEV(major, minor); -} - static void ext2_copy_inode_item(struct btrfs_inode_item *dst, struct ext2_inode *src, u32 blocksize) { @@ -692,7 +683,7 @@ static void ext2_copy_inode_item(struct btrfs_inode_item *dst, old_decode_dev(src->i_block[0])); } else { btrfs_set_stack_inode_rdev(dst, - new_decode_dev(src->i_block[1])); + decode_dev(src->i_block[1])); } } memset(&dst->reserved, 0, sizeof(dst->reserved)); diff --git a/convert/source-fs.c b/convert/source-fs.c index d6dfc077..b6d08370 100644 --- a/convert/source-fs.c +++ b/convert/source-fs.c @@ -28,6 +28,14 @@ const struct simple_range btrfs_reserved_ranges[3] = { { BTRFS_SB_MIRROR_OFFSET(2), SZ_64K } }; +dev_t decode_dev(u32 dev) +{ + unsigned major = (dev & 0xfff00) >> 8; + unsigned minor = (dev & 0xff) | ((dev >> 12) & 0xfff00); + + return MKDEV(major, minor); +} + int ext2_acl_count(size_t size) { ssize_t s; diff --git a/convert/source-fs.h b/convert/source-fs.h index bc693162..23f33567 100644 --- a/convert/source-fs.h +++ b/convert/source-fs.h @@ -18,9 +18,9 @@ #define __BTRFS_CONVERT_SOURCE_FS_H__ #include "kerncompat.h" +#include #include - #define CONV_IMAGE_SUBVOL_OBJECTID BTRFS_FIRST_FREE_OBJECTID /* @@ -104,6 +104,13 @@ static inline size_t acl_ea_size(int count) int ext2_acl_count(size_t size); +#ifndef MKDEV +#define MINORBITS 20 +#define MKDEV(ma, mi) (((ma) << MINORBITS) | (mi)) +#endif + +dev_t decode_dev(u32 dev); + struct btrfs_convert_operations { const char name[SOURCE_FS_NAME_LEN]; int (*open_fs)(struct btrfs_convert_context *cctx, const char *devname); diff --git a/convert/source-reiserfs.c b/convert/source-reiserfs.c index 8b3286f6..22a35904 100644 --- a/convert/source-reiserfs.c +++ b/convert/source-reiserfs.c @@ -251,7 +251,7 @@ static void reiserfs_copy_inode_item(struct btrfs_inode_item *inode, btrfs_set_stack_timespec_sec(&inode->mtime, sd_v1_mtime(sd)); if (!S_ISREG(mode) && !S_ISDIR(mode) && !S_ISLNK(mode)) - rdev = new_decode_dev(sd_v1_rdev(sd)); + rdev = decode_dev(sd_v1_rdev(sd)); } else { struct stat_data *sd = stat_data; @@ -265,7 +265,7 @@ static void reiserfs_copy_inode_item(struct btrfs_inode_item *inode, btrfs_set_stack_timespec_sec(&inode->mtime, sd_v2_mtime(sd)); if (!S_ISREG(mode) && !S_ISDIR(mode) && !S_ISLNK(mode)) - rdev = new_decode_dev(sd_v2_rdev(sd)); + rdev = decode_dev(sd_v2_rdev(sd)); if (copy_inode_flags) reiserfs_convert_inode_flags(inode, sd); diff --git a/convert/source-reiserfs.h b/convert/source-reiserfs.h index 0fa476a9..8de11b9c 100644 --- a/convert/source-reiserfs.h +++ b/convert/source-reiserfs.h @@ -24,19 +24,10 @@ #include #include #include -#include #include "convert/source-fs.h" #define REISERFS_ACL_VERSION 0x0001 -static inline dev_t new_decode_dev(u32 dev) -{ - unsigned major = (dev & 0xfff00) >> 8; - unsigned minor = (dev & 0xff) | ((dev >> 12) & 0xfff00); - - return MKDEV(major, minor); -} - #endif /* BTRFSCONVERT_REISERFS */ #endif