0
LKMを使用して擬似Hello Worldエントリを作成しました。 /procにエントリを作成する
http://pointer-overloading.blogspot.co.at/2013/09/linux-creating-entry-in-proc-file.html
は、しかし、私のinit関数では、私は「猫の/ proc /例」に戻りたい1つの整数値を持っています。このコードでこれを行う方法はありますか?
#include <linux/module.h>
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
static int hello_proc_show(struct seq_file *m, void *v) {
seq_printf(m, "Hello proc!\n");
return 0;
}
static int hello_proc_open(struct inode *inode, struct file *file) {
return single_open(file, hello_proc_show, NULL);
}
static const struct file_operations hello_proc_fops = {
.owner = THIS_MODULE,
.open = hello_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};
static int __init hello_proc_init(void) {
proc_create("hello_proc", 0, NULL, &hello_proc_fops);
return 0;
}
static void __exit hello_proc_exit(void) {
remove_proc_entry("hello_proc", NULL);
}
MODULE_LICENSE("GPL");
module_init(hello_proc_init);
module_exit(hello_proc_exit);
ご提供されたコードは 'init'関数内の任意の整数値が表示されませんか? –
私のコードには、CPUの温度の整数値があります。私はちょうど "こんにちは世界"の代わりにこの値を返すしたい。私は私の構造体に別のデータを追加する必要がありますか私はちょうど提供された関数に与えることができますか? –
seq_printf(m、 "CPU Temp:%d \ n"、cpu_temp); ? – Mali