Drop support for kernels < 4.4 from ext3 and kvm probes
[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
868e0b6d
MJ
15#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,18,0))
16#include <linux/blkdev.h>
17#else
f0dbdefb 18#include <linux/genhd.h>
868e0b6d 19#endif
f0dbdefb 20
fe72ab45
MJ
21#if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,17,0))
22#define LTTNG_GENHD_FL_HIDDEN GENHD_FL_HIDDEN
23#else
24#define LTTNG_GENHD_FL_HIDDEN GENHD_FL_SUPPRESS_PARTITION_INFO
25#endif
26
ff04d185 27#ifdef CONFIG_KALLSYMS_ALL
f0dbdefb
HD
28
29#include <linux/kallsyms.h>
5a2f5e92 30#include <wrapper/kallsyms.h>
f0dbdefb 31
f0dbdefb
HD
32static inline
33struct class *wrapper_get_block_class(void)
34{
35 struct class *ptr_block_class;
36
37 ptr_block_class = (struct class *) kallsyms_lookup_dataptr("block_class");
38 if (!ptr_block_class) {
e36de50d 39 printk_once(KERN_WARNING "LTTng: block_class symbol lookup failed.\n");
f0dbdefb
HD
40 return NULL;
41 }
42 return ptr_block_class;
43}
44
3dfec228
MJ
45/*
46 * Canary function to check for 'block_class' at compile time.
47 *
82fbf9d3 48 * From 'include/linux/blkdev.h':
3dfec228
MJ
49 *
50 * extern struct class block_class;
51 */
52static inline
53struct class *__canary__get_block_class(void)
54{
55 return &block_class;
56}
57
f0dbdefb
HD
58static inline
59struct device_type *wrapper_get_disk_type(void)
60{
61 struct device_type *ptr_disk_type;
62
63 ptr_disk_type = (struct device_type *) kallsyms_lookup_dataptr("disk_type");
64 if (!ptr_disk_type) {
e36de50d 65 printk_once(KERN_WARNING "LTTng: disk_type symbol lookup failed.\n");
f0dbdefb
HD
66 return NULL;
67 }
68 return ptr_disk_type;
69}
70
3dfec228
MJ
71/*
72 * No canary for 'disk_type', it's only defined in 'block/genhd.c'.
73 *
74 * static inline
75 * struct device_type *__canary__get_disk_type(void)
76 * {
77 * return &disk_type;
78 * }
79 */
80
f0dbdefb
HD
81#else
82
83static inline
84struct class *wrapper_get_block_class(void)
85{
86 /*
87 * Symbol block_class is not exported.
88 * TODO: return &block_class;
89 */
90 /* Feature currently unavailable without KALLSYMS_ALL */
91 return NULL;
92}
93
94static inline
95struct device_type *wrapper_get_disk_type(void)
96{
97 /*
98 * Symbol disk_type is not exported.
99 * TODO: return &disk_type;
100 */
101 /* Feature currently unavailable without KALLSYMS_ALL */
102 return NULL;
103}
104
105#endif
106
82fbf9d3 107#endif /* _LTTNG_WRAPPER_BLKDEV_H */
This page took 0.054864 seconds and 4 git commands to generate.