--- a/profiler/profile.c +++ b/profiler/profile.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -937,12 +938,26 @@ static ssize_t debug_if(struct file *fil return count; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,6,0) +#define HAVE_PROC_OPS +#endif + +#ifdef HAVE_PROC_OPS +static const struct proc_ops profile_fops = { + .proc_open = profile_open, + .proc_read = profile_read, + .proc_lseek = seq_lseek, + .proc_release = profile_release, + .proc_write = debug_if, +}; +#else static const struct file_operations profile_fops = { .open = profile_open, .read = profile_read, .release = profile_release, .write = debug_if, }; +#endif /* * showing sample status on Linux console @@ -971,6 +986,15 @@ static ssize_t profile_rate_write(struct return 0; } +#ifdef HAVE_PROC_OPS +static const struct proc_ops profile_rate_fops = { + .proc_open = profile_rate_open, + .proc_read = seq_read, + .proc_lseek = seq_lseek, + .proc_release = single_release, + .proc_write = profile_rate_write, +}; +#else static const struct file_operations profile_rate_fops = { .open = profile_rate_open, .read = seq_read, @@ -978,6 +1002,7 @@ static const struct file_operations prof .release = single_release, .write = profile_rate_write, }; +#endif /* * hexdump