Add support for RHEL 9.1
[lttng-modules.git] / wrapper / genhd.h
index a44198a7eb138f6698c7495ccb059a0370a91026..cacf3275ca628acfa6f2bf5945c683e94a58b1ff 100644 (file)
 #ifndef _LTTNG_WRAPPER_GENHD_H
 #define _LTTNG_WRAPPER_GENHD_H
 
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,18,0) \
+       || LTTNG_RHEL_KERNEL_RANGE(5,14,0,162,0,0, 5,15,0,0,0,0))
+#include <linux/blkdev.h>
+#else
 #include <linux/genhd.h>
+#endif
 
-#ifdef CONFIG_KALLSYMS
-
-#include <linux/kallsyms.h>
-#include <wrapper/kallsyms.h>
-
-static inline
-char *wrapper_disk_name(struct gendisk *hd, int partno, char *buf)
-{
-       char *(*disk_name_sym)(struct gendisk *hd, int partno, char *buf);
-
-       disk_name_sym = (void *) kallsyms_lookup_funcptr("disk_name");
-       if (disk_name_sym) {
-               return disk_name_sym(hd, partno, buf);
-       } else {
-               printk_once(KERN_WARNING "LTTng: disk_name symbol lookup failed.\n");
-               return NULL;
-       }
-}
-
+#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,17,0) \
+       || LTTNG_RHEL_KERNEL_RANGE(5,14,0,162,0,0, 5,15,0,0,0,0))
+#define LTTNG_GENHD_FL_HIDDEN GENHD_FL_HIDDEN
 #else
-
-static inline
-char *wrapper_disk_name(struct gendisk *hd, int partno, char *buf)
-{
-       return disk_name(hd, partno, buf);
-}
-
+#define LTTNG_GENHD_FL_HIDDEN GENHD_FL_SUPPRESS_PARTITION_INFO
 #endif
 
 #ifdef CONFIG_KALLSYMS_ALL
 
+#include <linux/kallsyms.h>
+#include <wrapper/kallsyms.h>
+
 static inline
 struct class *wrapper_get_block_class(void)
 {
@@ -58,6 +44,19 @@ struct class *wrapper_get_block_class(void)
        return ptr_block_class;
 }
 
+/*
+ * Canary function to check for 'block_class' at compile time.
+ *
+ * From 'include/linux/genhd.h':
+ *
+ *   extern struct class block_class;
+ */
+static inline
+struct class *__canary__get_block_class(void)
+{
+       return &block_class;
+}
+
 static inline
 struct device_type *wrapper_get_disk_type(void)
 {
@@ -71,6 +70,16 @@ struct device_type *wrapper_get_disk_type(void)
        return ptr_disk_type;
 }
 
+/*
+ * No canary for 'disk_type', it's only defined in 'block/genhd.c'.
+ *
+ * static inline
+ * struct device_type *__canary__get_disk_type(void)
+ * {
+ *     return &disk_type;
+ * }
+ */
+
 #else
 
 static inline
This page took 0.027026 seconds and 4 git commands to generate.