]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid: (superblocks) add helper blkid32_to_cpu()
authorThomas Weißschuh <thomas@t-8ch.de>
Sat, 14 Oct 2023 10:56:04 +0000 (12:56 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Sat, 14 Oct 2023 10:57:26 +0000 (12:57 +0200)
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
libblkid/src/superblocks/superblocks.h

index a99005861d38c1a772b9a79097ad6567c732e783..b02c9c6f035daf1d0dd9a85d812b46ae3c5bf37f 100644 (file)
@@ -133,4 +133,16 @@ int blkid_probe_set_fsendianness(blkid_probe pr, enum BLKID_ENDIANNESS endiannes
 extern int blkid_probe_is_bitlocker(blkid_probe pr);
 extern int blkid_probe_is_ntfs(blkid_probe pr);
 
+/*
+ * utility functions
+ */
+static inline int blkid32_to_cpu(enum BLKID_ENDIANNESS e, uint32_t i)
+{
+       if (e == BLKID_ENDIANNESS_LITTLE)
+               return le32_to_cpu(i);
+       else if (e == BLKID_ENDIANNESS_BIG)
+               return be32_to_cpu(i);
+       abort();
+}
+
 #endif /* _BLKID_SUPERBLOCKS_H */