Add support for RHEL 9.1
[lttng-modules.git] / include / wrapper / blkdev.h
CommitLineData
b7cdc182 1/* SPDX-License-Identifier: (GPL-2.0-only or LGPL-2.1-only)
9f36eaed 2 *
82fbf9d3 3 * wrapper/blkdev.h
f0dbdefb
HD
4 *
5 * wrapper around block layer functions and data structures. Using
6 * KALLSYMS to get its address when available, else we need to have a
7 * kernel that exports this function to GPL modules.
8 *
9 * Copyright (C) 2011-2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
f0dbdefb
HD
10 */
11
82fbf9d3
MJ
12#ifndef _LTTNG_WRAPPER_BLKDEV_H
13#define _LTTNG_WRAPPER_BLKDEV_H
9f36eaed 14
9f2d2694
MJ
15#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,18,0) \
16 || LTTNG_RHEL_KERNEL_RANGE(5,14,0,162,0,0, 5,15,0,0,0,0))
868e0b6d
MJ
17#include <linux/blkdev.h>
18#else
f0dbdefb 19#include <linux/genhd.h>
868e0b6d 20#endif
f0dbdefb 21
9f2d2694
MJ
22#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,17,0) \
23 || LTTNG_RHEL_KERNEL_RANGE(5,14,0,162,0,0, 5,15,0,0,0,0))
fe72ab45
MJ
24#define LTTNG_GENHD_FL_HIDDEN GENHD_FL_HIDDEN
25#else
26#define LTTNG_GENHD_FL_HIDDEN GENHD_FL_SUPPRESS_PARTITION_INFO
27#endif
28
ff04d185 29#ifdef CONFIG_KALLSYMS_ALL
f0dbdefb
HD
30
31#include <linux/kallsyms.h>
5a2f5e92 32#include <wrapper/kallsyms.h>
f0dbdefb 33
f0dbdefb
HD
34static inline
35struct class *wrapper_get_block_class(void)
36{
37 struct class *ptr_block_class;
38
39 ptr_block_class = (struct class *) kallsyms_lookup_dataptr("block_class");
40 if (!ptr_block_class) {
e36de50d 41 printk_once(KERN_WARNING "LTTng: block_class symbol lookup failed.\n");
f0dbdefb
HD
42 return NULL;
43 }
44 return ptr_block_class;
45}
46
3dfec228
MJ
47/*
48 * Canary function to check for 'block_class' at compile time.
49 *
82fbf9d3 50 * From 'include/linux/blkdev.h':
3dfec228
MJ
51 *
52 * extern struct class block_class;
53 */
54static inline
55struct class *__canary__get_block_class(void)
56{
57 return &block_class;
58}
59
f0dbdefb
HD
60static inline
61struct device_type *wrapper_get_disk_type(void)
62{
63 struct device_type *ptr_disk_type;
64
65 ptr_disk_type = (struct device_type *) kallsyms_lookup_dataptr("disk_type");
66 if (!ptr_disk_type) {
e36de50d 67 printk_once(KERN_WARNING "LTTng: disk_type symbol lookup failed.\n");
f0dbdefb
HD
68 return NULL;
69 }
70 return ptr_disk_type;
71}
72
3dfec228
MJ
73/*
74 * No canary for 'disk_type', it's only defined in 'block/genhd.c'.
75 *
76 * static inline
77 * struct device_type *__canary__get_disk_type(void)
78 * {
79 * return &disk_type;
80 * }
81 */
82
f0dbdefb
HD
83#else
84
85static inline
86struct class *wrapper_get_block_class(void)
87{
88 /*
89 * Symbol block_class is not exported.
90 * TODO: return &block_class;
91 */
92 /* Feature currently unavailable without KALLSYMS_ALL */
93 return NULL;
94}
95
96static inline
97struct device_type *wrapper_get_disk_type(void)
98{
99 /*
100 * Symbol disk_type is not exported.
101 * TODO: return &disk_type;
102 */
103 /* Feature currently unavailable without KALLSYMS_ALL */
104 return NULL;
105}
106
107#endif
108
82fbf9d3 109#endif /* _LTTNG_WRAPPER_BLKDEV_H */
This page took 0.053828 seconds and 4 git commands to generate.