diff options
author | Amir Goldstein <amir73il@gmail.com> | 2021-03-22 20:39:43 +0300 |
---|---|---|
committer | Jan Kara <jack@suse.cz> | 2021-04-19 17:03:15 +0300 |
commit | 9591c3a34f7722bd77f42c98d76fd5a5bad465f0 (patch) | |
tree | 44001867b11da3de1fa029e50ab636ea381c0c7a /include/linux/statfs.h | |
parent | 22d483b99863202e3631ff66fa0f3c2302c0f96f (diff) | |
download | linux-9591c3a34f7722bd77f42c98d76fd5a5bad465f0.tar.xz |
fs: introduce a wrapper uuid_to_fsid()
Some filesystem's use a digest of their uuid for f_fsid.
Create a simple wrapper for this open coded folding.
Filesystems that have a non null uuid but use the block device
number for f_fsid may also consider using this helper.
[JK: Added missing asm/byteorder.h include]
Link: https://lore.kernel.org/r/20210322173944.449469-2-amir73il@gmail.com
Acked-by: Damien Le Moal <damien.lemoal@wdc.com>
Reviewed-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
Diffstat (limited to 'include/linux/statfs.h')
-rw-r--r-- | include/linux/statfs.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/include/linux/statfs.h b/include/linux/statfs.h index 20f695b90aab..02c862686ea3 100644 --- a/include/linux/statfs.h +++ b/include/linux/statfs.h @@ -4,6 +4,7 @@ #include <linux/types.h> #include <asm/statfs.h> +#include <asm/byteorder.h> struct kstatfs { long f_type; @@ -50,4 +51,11 @@ static inline __kernel_fsid_t u64_to_fsid(u64 v) return (__kernel_fsid_t){.val = {(u32)v, (u32)(v>>32)}}; } +/* Fold 16 bytes uuid to 64 bit fsid */ +static inline __kernel_fsid_t uuid_to_fsid(__u8 *uuid) +{ + return u64_to_fsid(le64_to_cpup((void *)uuid) ^ + le64_to_cpup((void *)(uuid + sizeof(u64)))); +} + #endif |