]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - mdadm.h
mdadm.h: Introduced unaligned {get,put}_unaligned{16,32}()
[thirdparty/mdadm.git] / mdadm.h
diff --git a/mdadm.h b/mdadm.h
index 705bd9b53b3ae28e9cd403640a81e4705d4d467e..0fa9e1bd3080de51597ee26898f32f95f8aa3f72 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -191,6 +191,36 @@ struct dlm_lksb {
 #endif
 #endif /* __KLIBC__ */
 
+/*
+ * Partially stolen from include/linux/unaligned/packed_struct.h
+ */
+struct __una_u16 { __u16 x; } __attribute__ ((packed));
+struct __una_u32 { __u32 x; } __attribute__ ((packed));
+
+static inline __u16 __get_unaligned16(const void *p)
+{
+       const struct __una_u16 *ptr = (const struct __una_u16 *)p;
+       return ptr->x;
+}
+
+static inline __u32 __get_unaligned32(const void *p)
+{
+       const struct __una_u32 *ptr = (const struct __una_u32 *)p;
+       return ptr->x;
+}
+
+static inline void __put_unaligned16(__u16 val, void *p)
+{
+       struct __una_u16 *ptr = (struct __una_u16 *)p;
+       ptr->x = val;
+}
+
+static inline void __put_unaligned32(__u32 val, void *p)
+{
+       struct __una_u32 *ptr = (struct __una_u32 *)p;
+       ptr->x = val;
+}
+
 /*
   * Check at compile time that something is of a particular type.
   * Always evaluates to 1 so you may use it easily in comparisons.
@@ -647,6 +677,7 @@ enum sysfs_read_flags {
        GET_ERROR       = (1 << 24),
        GET_ARRAY_STATE = (1 << 25),
        GET_CONSISTENCY_POLICY  = (1 << 26),
+       GET_DEVS_ALL    = (1 << 27),
 };
 
 /* If fd >= 0, get the array it is open on,