X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=wrapper%2Fgenhd.h;h=cacf3275ca628acfa6f2bf5945c683e94a58b1ff;hb=edee4485348d15198bc76a4fb4ae2d27e9872364;hp=4184bd011d3e9dc8c23c607cbf7f379abe4f3bf2;hpb=5a2f5e92e422d87a28581ba97e6b1789ff743bc6;p=lttng-modules.git diff --git a/wrapper/genhd.h b/wrapper/genhd.h index 4184bd01..cacf3275 100644 --- a/wrapper/genhd.h +++ b/wrapper/genhd.h @@ -1,7 +1,5 @@ -#ifndef _LTTNG_WRAPPER_GENHD_H -#define _LTTNG_WRAPPER_GENHD_H - -/* +/* SPDX-License-Identifier: (GPL-2.0 or LGPL-2.1) + * * wrapper/genhd.h * * wrapper around block layer functions and data structures. Using @@ -9,55 +7,30 @@ * kernel that exports this function to GPL modules. * * Copyright (C) 2011-2014 Mathieu Desnoyers - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; only - * version 2.1 of the License. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include - -#ifdef CONFIG_KALLSYMS - -#include -#include - -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(KERN_WARNING "LTTng: disk_name symbol lookup failed.\n"); - return NULL; - } -} +#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 #else +#include +#endif -static inline -char *wrapper_disk_name(struct gendisk *hd, int partno, char *buf) -{ - return disk_name(hd, partno, buf); -} - +#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 +#define LTTNG_GENHD_FL_HIDDEN GENHD_FL_SUPPRESS_PARTITION_INFO #endif #ifdef CONFIG_KALLSYMS_ALL +#include +#include + static inline struct class *wrapper_get_block_class(void) { @@ -65,12 +38,25 @@ struct class *wrapper_get_block_class(void) ptr_block_class = (struct class *) kallsyms_lookup_dataptr("block_class"); if (!ptr_block_class) { - printk(KERN_WARNING "LTTng: block_class symbol lookup failed.\n"); + printk_once(KERN_WARNING "LTTng: block_class symbol lookup failed.\n"); return NULL; } 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) { @@ -78,12 +64,22 @@ struct device_type *wrapper_get_disk_type(void) ptr_disk_type = (struct device_type *) kallsyms_lookup_dataptr("disk_type"); if (!ptr_disk_type) { - printk(KERN_WARNING "LTTng: disk_type symbol lookup failed.\n"); + printk_once(KERN_WARNING "LTTng: disk_type symbol lookup failed.\n"); return NULL; } 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