이 코드를 고려 sysctl을합니다 :동적으로 추가 항목은
int procmon_state = 0;
static struct ctl_table_header *procmon_table_header;
static ctl_table state_table[] = {
{
.procname = "state", .mode = 0666,
.proc_handler = &proc_dointvec_minmax,
.data = &procmon_state, .maxlen = sizeof(int),
.extra1 = "\x00\x00\x00\x00" /*0*/, .extra2 = "\x01\x00\x00\x00" /*1*/
},
{ 0 }
};
static ctl_table procmon_table[] = {
{
.procname = "procmon", .mode = 0555,
.child = state_table
},
{ 0 }
};
procmon_table_header = register_sysctl_table(procmon_table);
이 /proc/sys
에 항목을 작성합니다 (그래서 할 수 그럼 그냥 sysctl procmon.state=1
).
내 질문은 : 해당 항목이 만들어지면 어떻게 항목을 추가 할 수 있습니까?
편집 : 더 많은 항목이 procmon
안에 있습니다. 예 : procmon.another_state
될 수'register_sysctl_paths' 여기에 도움이? –
나는'proc_create_data()'를 볼 것입니다. –
사실,'''register_sysctl_paths'''가 도움이 될 수 있습니다. 나는 그것을 볼 것이다, 고마워! 다른면에서는,''proc_create_data''가 너무 최근 (3.10+ 만)입니다. – alexandernst