首页 > 代码库 > todo:proc_create

todo:proc_create


static int nvram_proc_read(struct seq_file *seq, void *offset)
{
unsigned char contents[NVRAM_BYTES];
int i = 0;

spin_lock_irq(&rtc_lock);
for (i = 0; i < NVRAM_BYTES; ++i)
contents[i] = __nvram_read_byte(i);
spin_unlock_irq(&rtc_lock);

mach_proc_infos(contents, seq, offset);

return 0;
}

static int nvram_proc_open(struct inode *inode, struct file *file)
{
return single_open(file, nvram_proc_read, NULL);
}

static const struct file_operations nvram_proc_fops = {
.owner = THIS_MODULE,
.open = nvram_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = single_release,
};

static int nvram_add_proc_fs(void)
{
if (!proc_create("driver/nvram", 0, NULL, &nvram_proc_fops))
return -ENOMEM;
return 0;
}

todo:proc_create