0
|
1 |
#include <linux/mm.h>
|
|
2 |
#include <linux/mmzone.h>
|
|
3 |
#include <linux/mman.h>
|
|
4 |
#include <linux/ratelimit.h>
|
|
5 |
#include "sim-assert.h"
|
|
6 |
#include "sim-types.h"
|
|
7 |
|
|
8 |
int drop_caches_sysctl_handler(struct ctl_table *table, int write,
|
|
9 |
void *buffer, size_t *length, loff_t *ppos)
|
|
10 |
{
|
|
11 |
sim_assert (false);
|
|
12 |
return 0;
|
|
13 |
}
|
|
14 |
int lowmem_reserve_ratio_sysctl_handler(struct ctl_table *table, int write,
|
|
15 |
void *buffer, size_t *length, loff_t *ppos)
|
|
16 |
{
|
|
17 |
sim_assert (false);
|
|
18 |
return 0;
|
|
19 |
}
|
|
20 |
int min_free_kbytes_sysctl_handler(struct ctl_table *table, int write,
|
|
21 |
void *buffer, size_t *length, loff_t *ppos)
|
|
22 |
{
|
|
23 |
sim_assert (false);
|
|
24 |
return 0;
|
|
25 |
}
|
|
26 |
|
|
27 |
int percpu_pagelist_fraction_sysctl_handler(struct ctl_table *table, int write,
|
|
28 |
void *buffer, size_t *length, loff_t *ppos)
|
|
29 |
{
|
|
30 |
sim_assert (false);
|
|
31 |
return 0;
|
|
32 |
}
|
|
33 |
int dirty_background_ratio_handler(struct ctl_table *table, int write,
|
|
34 |
void *buffer, size_t *lenp,
|
|
35 |
loff_t *ppos)
|
|
36 |
{
|
|
37 |
sim_assert (false);
|
|
38 |
return 0;
|
|
39 |
}
|
|
40 |
int dirty_background_bytes_handler(struct ctl_table *table, int write,
|
|
41 |
void *buffer, size_t *lenp,
|
|
42 |
loff_t *ppos)
|
|
43 |
{
|
|
44 |
sim_assert (false);
|
|
45 |
return 0;
|
|
46 |
}
|
|
47 |
int dirty_ratio_handler(struct ctl_table *table, int write,
|
|
48 |
void *buffer, size_t *lenp,
|
|
49 |
loff_t *ppos)
|
|
50 |
{
|
|
51 |
sim_assert (false);
|
|
52 |
return 0;
|
|
53 |
}
|
|
54 |
int dirty_bytes_handler(struct ctl_table *table, int write,
|
|
55 |
void *buffer, size_t *lenp,
|
|
56 |
loff_t *ppos)
|
|
57 |
{
|
|
58 |
sim_assert (false);
|
|
59 |
return 0;
|
|
60 |
}
|
|
61 |
int dirty_writeback_centisecs_handler(struct ctl_table *table, int write,
|
|
62 |
void *buffer, size_t *length, loff_t *ppos)
|
|
63 |
{
|
|
64 |
sim_assert (false);
|
|
65 |
return 0;
|
|
66 |
}
|
|
67 |
int scan_unevictable_handler(struct ctl_table *table, int write,
|
|
68 |
void __user *buffer,
|
|
69 |
size_t *length, loff_t *ppos)
|
|
70 |
{
|
|
71 |
sim_assert (false);
|
|
72 |
return 0;
|
|
73 |
}
|
|
74 |
int sched_rt_handler(struct ctl_table *table, int write,
|
|
75 |
void __user *buffer, size_t *lenp,
|
|
76 |
loff_t *ppos)
|
|
77 |
{
|
|
78 |
sim_assert (false);
|
|
79 |
return 0;
|
|
80 |
}
|
|
81 |
|
|
82 |
int sysctl_overcommit_memory = OVERCOMMIT_GUESS;
|
|
83 |
int sysctl_overcommit_ratio = 50;
|
|
84 |
int sysctl_panic_on_oom = 0;
|
|
85 |
int sysctl_oom_dump_tasks = 0;
|
|
86 |
int sysctl_oom_kill_allocating_task = 0;
|
|
87 |
int sysctl_nr_open = 1024*1024;
|
|
88 |
int sysctl_nr_open_min = BITS_PER_LONG;
|
|
89 |
int sysctl_nr_open_max = 1024 * 1024;
|
|
90 |
int sysctl_nr_trim_pages = 0;
|
|
91 |
int sysctl_drop_caches = 0;
|
|
92 |
int sysctl_lowmem_reserve_ratio[MAX_NR_ZONES-1] = {32};
|
|
93 |
int sysctl_vfs_cache_pressure = 100;
|
|
94 |
unsigned int sysctl_sched_child_runs_first = 0;
|
|
95 |
unsigned int sysctl_sched_compat_yield = 0;
|
|
96 |
unsigned int sysctl_sched_rt_period = 1000000;
|
|
97 |
int sysctl_sched_rt_runtime = 950000;
|
|
98 |
|
|
99 |
int vm_highmem_is_dirtyable;
|
|
100 |
unsigned long vm_dirty_bytes = 0;
|
|
101 |
int vm_dirty_ratio = 20;
|
|
102 |
int dirty_background_ratio = 10;
|
|
103 |
unsigned int dirty_expire_interval = 30 * 100;
|
|
104 |
unsigned int dirty_writeback_interval = 5 * 100;
|
|
105 |
unsigned long dirty_background_bytes = 0;
|
|
106 |
int percpu_pagelist_fraction = 0;
|
|
107 |
int panic_timeout = 0;
|
|
108 |
int panic_on_oops = 0;
|
|
109 |
int printk_delay_msec = 0;
|
|
110 |
DEFINE_RATELIMIT_STATE(printk_ratelimit_state, 5 * HZ, 10);
|
|
111 |
|
|
112 |
#define RESERVED_PIDS 300
|
|
113 |
int pid_max = PID_MAX_DEFAULT;
|
|
114 |
int pid_max_min = RESERVED_PIDS + 1;
|
|
115 |
int pid_max_max = PID_MAX_LIMIT;
|
|
116 |
int min_free_kbytes = 1024;
|
|
117 |
int max_threads = 100;
|
|
118 |
int laptop_mode = 0;
|
|
119 |
|
|
120 |
#define DEFAULT_MESSAGE_LOGLEVEL 4 /* KERN_WARNING */
|
|
121 |
#define MINIMUM_CONSOLE_LOGLEVEL 1 /* Minimum loglevel we let people use */
|
|
122 |
#define DEFAULT_CONSOLE_LOGLEVEL 7 /* anything MORE serious than KERN_DEBUG */
|
|
123 |
int console_printk[4] = {
|
|
124 |
DEFAULT_CONSOLE_LOGLEVEL, /* console_loglevel */
|
|
125 |
DEFAULT_MESSAGE_LOGLEVEL, /* default_message_loglevel */
|
|
126 |
MINIMUM_CONSOLE_LOGLEVEL, /* minimum_console_loglevel */
|
|
127 |
DEFAULT_CONSOLE_LOGLEVEL, /* default_console_loglevel */
|
|
128 |
};
|
|
129 |
|
|
130 |
int print_fatal_signals = 0;
|
|
131 |
unsigned int core_pipe_limit = 0;
|
|
132 |
int core_uses_pid = 0;
|
|
133 |
int vm_swappiness = 60;
|
|
134 |
int nr_pdflush_threads = 0;
|
|
135 |
unsigned long scan_unevictable_pages = 0;
|
|
136 |
int suid_dumpable = 0;
|
|
137 |
int page_cluster = 0;
|
|
138 |
int block_dump = 0;
|
|
139 |
int C_A_D = 0;
|
|
140 |
#include <linux/nsproxy.h>
|
|
141 |
struct nsproxy init_nsproxy;
|
|
142 |
#include <linux/reboot.h>
|
|
143 |
char poweroff_cmd[POWEROFF_CMD_PATH_LEN] = "/sbin/poweroff";
|
|
144 |
#include <linux/pipe_fs_i.h>
|
|
145 |
unsigned int pipe_max_pages = PIPE_DEF_BUFFERS * 16;
|
|
146 |
unsigned int pipe_max_size = 1048576;
|
|
147 |
unsigned int pipe_min_size = PAGE_SIZE;
|
|
148 |
|
|
149 |
int pipe_proc_fn(struct ctl_table *table, int write, void __user *buf,
|
|
150 |
size_t *lenp, loff_t *ppos)
|
|
151 |
{
|
|
152 |
return -1;
|
|
153 |
}
|
|
154 |
|
|
155 |
#include <linux/fs.h>
|
|
156 |
|
|
157 |
/**
|
|
158 |
* Honestly, I don't understand half of that code.
|
|
159 |
* It was modeled after fs/proc/proc_sysctl.c proc_sys_readdir
|
|
160 |
*/
|
|
161 |
static void iterate_recursive (const struct SimSysIterator *iter, struct ctl_table *table);
|
|
162 |
|
|
163 |
static void iterate_table_recursive (const struct SimSysIterator *iter, struct ctl_table *table)
|
|
164 |
{
|
|
165 |
struct ctl_table *cur_table;
|
|
166 |
for (cur_table = table; cur_table->procname != NULL; cur_table++)
|
|
167 |
{
|
|
168 |
if (table->child == 0)
|
|
169 |
{
|
|
170 |
bool may_read = (table->mode & MAY_READ);
|
|
171 |
bool may_write = (table->mode & MAY_WRITE);
|
|
172 |
int flags = 0;
|
|
173 |
flags |= may_read?SIM_SYS_FILE_READ:0;
|
|
174 |
flags |= may_write?SIM_SYS_FILE_WRITE:0;
|
|
175 |
iter->report_file (iter, cur_table->procname, flags, (struct SimSysFile *)cur_table);
|
|
176 |
}
|
|
177 |
else
|
|
178 |
{
|
|
179 |
iter->report_start_dir (iter, cur_table->procname);
|
|
180 |
iterate_recursive (iter, table->child);
|
|
181 |
iter->report_end_dir (iter);
|
|
182 |
}
|
|
183 |
}
|
|
184 |
}
|
|
185 |
|
|
186 |
static void iterate_recursive (const struct SimSysIterator *iter, struct ctl_table *table)
|
|
187 |
{
|
|
188 |
struct ctl_table_header *root = sysctl_head_next (NULL);
|
|
189 |
struct ctl_table_header *cur;
|
|
190 |
|
|
191 |
iterate_table_recursive (iter, table);
|
|
192 |
for (cur = root; cur != 0; cur = sysctl_head_next (cur))
|
|
193 |
{
|
|
194 |
if (cur->set != table)
|
|
195 |
{
|
|
196 |
continue;
|
|
197 |
}
|
|
198 |
iterate_table_recursive (iter, cur->root);
|
|
199 |
}
|
|
200 |
|
|
201 |
}
|
|
202 |
|
|
203 |
|
|
204 |
|
|
205 |
void sim_sys_iterate_files (const struct SimSysIterator *iter)
|
|
206 |
{
|
|
207 |
// sim_assert (0);
|
|
208 |
return;
|
|
209 |
struct ctl_table_header *root = sysctl_head_next (NULL);
|
|
210 |
iterate_recursive (iter, root->ctl_table);
|
|
211 |
}
|
|
212 |
|
|
213 |
int sim_sys_file_read (const struct SimSysFile *file, char *buffer, int size, int offset)
|
|
214 |
{
|
|
215 |
struct ctl_table *table = (struct ctl_table *)file;
|
|
216 |
loff_t ppos = offset;
|
|
217 |
size_t result = size;
|
|
218 |
int error;
|
|
219 |
error = table->proc_handler (table, 0, buffer, &result, &ppos);
|
|
220 |
return result;
|
|
221 |
}
|
|
222 |
int sim_sys_file_write (const struct SimSysFile *file, const char *buffer, int size, int offset)
|
|
223 |
{
|
|
224 |
struct ctl_table *table = (struct ctl_table *)file;
|
|
225 |
loff_t ppos = offset;
|
|
226 |
size_t result = size;
|
|
227 |
int error;
|
|
228 |
error = table->proc_handler (table, 1, (char *)buffer, &result, &ppos);
|
|
229 |
return result;
|
|
230 |
}
|