1 /* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1)
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.
9 * Copyright (C) 2011-2014 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
12 #ifndef _LTTNG_WRAPPER_GENHD_H
13 #define _LTTNG_WRAPPER_GENHD_H
15 #include <linux/genhd.h>
16 #include <lttng-kernel-version.h>
18 #if (LTTNG_LINUX_VERSION_CODE >= LTTNG_KERNEL_VERSION(5,11,0))
19 #define LTTNG_DISK_PART_TYPE struct block_device
21 #define LTTNG_DISK_PART_TYPE struct hd_struct
24 #ifdef CONFIG_KALLSYMS_ALL
26 #include <linux/kallsyms.h>
27 #include <wrapper/kallsyms.h>
30 struct class *wrapper_get_block_class(void)
32 struct class *ptr_block_class
;
34 ptr_block_class
= (struct class *) kallsyms_lookup_dataptr("block_class");
35 if (!ptr_block_class
) {
36 printk_once(KERN_WARNING
"LTTng: block_class symbol lookup failed.\n");
39 return ptr_block_class
;
43 * Canary function to check for 'block_class' at compile time.
45 * From 'include/linux/genhd.h':
47 * extern struct class block_class;
50 struct class *__canary__get_block_class(void)
56 struct device_type
*wrapper_get_disk_type(void)
58 struct device_type
*ptr_disk_type
;
60 ptr_disk_type
= (struct device_type
*) kallsyms_lookup_dataptr("disk_type");
62 printk_once(KERN_WARNING
"LTTng: disk_type symbol lookup failed.\n");
69 * No canary for 'disk_type', it's only defined in 'block/genhd.c'.
72 * struct device_type *__canary__get_disk_type(void)
81 struct class *wrapper_get_block_class(void)
84 * Symbol block_class is not exported.
85 * TODO: return &block_class;
87 /* Feature currently unavailable without KALLSYMS_ALL */
92 struct device_type
*wrapper_get_disk_type(void)
95 * Symbol disk_type is not exported.
96 * TODO: return &disk_type;
98 /* Feature currently unavailable without KALLSYMS_ALL */
105 * This wrapper has an 'int' return type instead of the original 'void', to be
106 * able to report the symbol lookup failure to the caller.
108 * Return 0 on success, -1 on error.
110 int wrapper_disk_part_iter_init(struct disk_part_iter
*piter
, struct gendisk
*disk
,
112 LTTNG_DISK_PART_TYPE
*wrapper_disk_part_iter_next(struct disk_part_iter
*piter
);
113 void wrapper_disk_part_iter_exit(struct disk_part_iter
*piter
);
116 * Canary function to check for 'disk_part_iter_init()' at compile time.
118 * From 'include/linux/genhd.h':
120 * extern void disk_part_iter_init(struct disk_part_iter *piter,
121 * struct gendisk *disk, unsigned int flags);
125 void __canary__disk_part_iter_init(struct disk_part_iter
*piter
, struct gendisk
*disk
,
128 disk_part_iter_init(piter
, disk
, flags
);
132 * Canary function to check for 'disk_part_iter_next()' at compile time.
134 * From 'include/linux/genhd.h':
136 * struct block_device *disk_part_iter_next(struct disk_part_iter *piter);
140 LTTNG_DISK_PART_TYPE
*__canary__disk_part_iter_next(struct disk_part_iter
*piter
)
142 return disk_part_iter_next(piter
);
146 * Canary function to check for 'disk_part_iter_exit()' at compile time.
148 * From 'include/linux/genhd.h':
150 * extern void disk_part_iter_exit(struct disk_part_iter *piter);
154 void __canary__disk_part_iter_exit(struct disk_part_iter
*piter
)
156 return disk_part_iter_exit(piter
);
159 #endif /* _LTTNG_WRAPPER_GENHD_H */
This page took 0.050773 seconds and 5 git commands to generate.