linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 1/4] uuid: Add inline helpers to import / export UUIDs
@ 2019-07-17 11:36 Andy Shevchenko
  2019-07-17 11:36 ` [PATCH v3 2/4] uuid: Provide a GUID generator for raw buffer Andy Shevchenko
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Andy Shevchenko @ 2019-07-17 11:36 UTC (permalink / raw)
  To: Chris Mason, Josef Bacik, David Sterba, Lu Fengqi, linux-btrfs,
	Christoph Hellwig
  Cc: Andy Shevchenko, David Sterba

Sometimes we may need to import UUID from or export to the raw buffer,
which is provided outside of kernel and can't be declared as UUID type.
With current API this operation will require an explicit casting
to one of UUID types and length, that is always a constant derived as sizeof
the certain UUID type.

Provide a helpful set of inline helpers to minimize developer's effort
in the cases when raw buffers are involved.

Suggested-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/uuid.h | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/include/linux/uuid.h b/include/linux/uuid.h
index 0c631e2a73b6..8e4a5000da03 100644
--- a/include/linux/uuid.h
+++ b/include/linux/uuid.h
@@ -43,6 +43,16 @@ static inline void guid_copy(guid_t *dst, const guid_t *src)
 	memcpy(dst, src, sizeof(guid_t));
 }
 
+static inline void import_guid(guid_t *dst, const __u8 *src)
+{
+	memcpy(dst, src, sizeof(guid_t));
+}
+
+static inline void export_guid(__u8 *dst, const guid_t *src)
+{
+	memcpy(dst, src, sizeof(guid_t));
+}
+
 static inline bool guid_is_null(const guid_t *guid)
 {
 	return guid_equal(guid, &guid_null);
@@ -58,6 +68,16 @@ static inline void uuid_copy(uuid_t *dst, const uuid_t *src)
 	memcpy(dst, src, sizeof(uuid_t));
 }
 
+static inline void import_uuid(uuid_t *dst, const __u8 *src)
+{
+	memcpy(dst, src, sizeof(uuid_t));
+}
+
+static inline void export_uuid(__u8 *dst, const uuid_t *src)
+{
+	memcpy(dst, src, sizeof(uuid_t));
+}
+
 static inline bool uuid_is_null(const uuid_t *uuid)
 {
 	return uuid_equal(uuid, &uuid_null);
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2019-07-23 17:24 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-17 11:36 [PATCH v3 1/4] uuid: Add inline helpers to import / export UUIDs Andy Shevchenko
2019-07-17 11:36 ` [PATCH v3 2/4] uuid: Provide a GUID generator for raw buffer Andy Shevchenko
2019-07-17 11:36 ` [PATCH v3 3/4] Btrfs: Switch to use new generic UUID API Andy Shevchenko
2019-07-18 17:20   ` Johannes Thumshirn
2019-07-18 17:38     ` Andy Shevchenko
2019-07-18 17:44       ` Johannes Thumshirn
2019-07-23 17:24         ` Andy Shevchenko
2019-07-17 11:36 ` [PATCH v3 4/4] uuid: Remove no more needed macro Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).