Commit 64720771 authored by Igor Sukhih's avatar Igor Sukhih Committed by Pavel Emelyanov

util: Update kdev_to_odev to respect BITS_PER_LONG

Depending on BITS_PER_LONG userspace representation of dev_t
may vary, so we need to choose proper encoding.
Signed-off-by: 's avatarIgor Sukhih <igor@parallels.com>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 59c43e48
...@@ -220,9 +220,17 @@ static inline u32 kdev_minor(u32 kdev) ...@@ -220,9 +220,17 @@ static inline u32 kdev_minor(u32 kdev)
static inline dev_t kdev_to_odev(u32 kdev) static inline dev_t kdev_to_odev(u32 kdev)
{ {
/* /*
* New kernels envcode devices in a new form * New kernels encode devices in a new form.
* See kernel's fs/stat.c for details, there
* choose_32_64 helpers which are the key.
*/ */
return (kdev_major(kdev) << 8) | kdev_minor(kdev); unsigned major = kdev_major(kdev);
unsigned minor = kdev_minor(kdev);
#if BITS_PER_LONG == 32
return (major << 8) | minor;
#else
return (minor & 0xff) | (major << 8) | ((minor & ~0xff) << 12);
#endif
} }
int copy_file(int fd_in, int fd_out, size_t bytes); int copy_file(int fd_in, int fd_out, size_t bytes);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment