Skip to content

Commit 6f40ee2

Browse files
committed
fix mem_reserver in 5.10.35.bsk.1-amd64 bytedance#225
1 parent fa75757 commit 6f40ee2

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

terark-tools/mem_reserve/mem_reserve.c

+11-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/kallsyms.h>
1616
#include <linux/mmzone.h>
1717
#include <linux/nodemask.h>
18+
#include <linux/version.h>
1819

1920
struct mem_reserve {
2021
unsigned long size;
@@ -93,14 +94,23 @@ static ssize_t size_write(struct file *file, const char __user *buf,
9394

9495
return count;
9596
}
96-
97+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5,4,56)
9798
static const struct file_operations size_fops = {
9899
.open = size_open,
99100
.read = seq_read,
100101
.write = size_write,
101102
.llseek = seq_lseek,
102103
.release = single_release,
103104
};
105+
#else
106+
static const struct proc_ops size_fops = {
107+
.proc_open = size_open,
108+
.proc_read = seq_read,
109+
.proc_write = size_write,
110+
.proc_lseek = seq_lseek,
111+
.proc_release = single_release,
112+
};
113+
#endif
104114

105115
static __init int mem_reserve_init(void)
106116
{

0 commit comments

Comments
 (0)