btrfs-progs: convert: move and rename dev_t helpers to common file

Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
David Sterba 2017-08-22 20:43:49 +02:00
parent c05c70c77c
commit 4856215f51
5 changed files with 19 additions and 22 deletions

View File

@ -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));

View File

@ -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;

View File

@ -18,9 +18,9 @@
#define __BTRFS_CONVERT_SOURCE_FS_H__
#include "kerncompat.h"
#include <linux/kdev_t.h>
#include <pthread.h>
#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);

View File

@ -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);

View File

@ -24,19 +24,10 @@
#include <reiserfs/io.h>
#include <reiserfs/reiserfs_lib.h>
#include <reiserfs/reiserfs_fs.h>
#include <linux/kdev_t.h>
#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