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