分类: 嵌入式
2009-11-17 21:47:29
pydeng@pydeng-laptop:~$ file /proc/meminfo
/proc/meminfo: empty
pydeng@pydeng-laptop:~$ cat /proc/meminfo
MemTotal: 493268 kB
MemFree: 6124 kB
Buffers: 15960 kB
Cached: 250204 kB
SwapCached: 888 kB
...... |
struct proc_dir_entry *create_proc_entry(const char *name, mode_t mode,
struct proc_dir_entry *parent) |
struct proc_dir_entry *proc_mkdir(const char * name, struct proc_dir_entry *parent) |
int (*read_proc)(char *page, char **start, off_t offset, int count, int *eof, void *data);
struct proc_dir_entry *res;
……
res->read_proc=&read_proc; |
struct proc_dir_entry *create_proc_read_entry(const char *name, mode_t mode,
struct proc_dir_entry *base,
read_proc_t *read_proc, void *data); |
int (*write_proc)(struct file *file, const char __user *buffer, unsigned long count, void *data) |
struct seq_operations {
void * (*start) (struct seq_file *sfile, loff_t *pos);
void (*stop) (struct seq_file * sfile, void *v);
void * (*next) (struct seq_file * sfile, void *v, loff_t *pos);
int (*show) (struct seq_file * sfile, void *v);
}; |
int seq_printf(struct seq_file *sfile, const char *fmt, ...);
int seq_putc(struct seq_file *sfile, char c);
int seq_puts(struct seq_file *sfile, const char *s);
int seq_escape(struct seq_file *m, const char *s, const char *esc);
int seq_path(struct seq_file *sfile, struct vfsmount *m, struct dentry *dentry, char *esc); |
static int scull_proc_open(struct inode *inode, struct file *file)
{
return seq_open(file, &scull_seq_ops);
}
static struct file_operations scull_proc_ops = {
.owner = THIS_MODULE,
.open = scull_proc_open,
.read = seq_read,
.llseek = seq_lseek,
.release = seq_release
}; |
entry = create_proc_entry("scullseq", 0, NULL);
if (entry)
entry->proc_fops = &scull_proc_ops; |
root@pydeng-laptop:/home/pydeng/ldd3_examples/scull# make clean > /dev/null
root@pydeng-laptop:/home/pydeng/ldd3_examples/scull# make > /dev/null
root@pydeng-laptop:/home/pydeng/ldd3_examples/scull# ./scull_load
root@pydeng-laptop:/home/pydeng/ldd3_examples/scull# cat /proc/scullseq
Device 0: qset 1000, q 4000, sz 0
Device 1: qset 1000, q 4000, sz 0
Device 2: qset 1000, q 4000, sz 0
Device 3: qset 1000, q 4000, sz 0
root@pydeng-laptop:/home/pydeng/ldd3_examples/scull# dmesg
......
[ 505.199261] pyd_debug:seq_start().
[ 505.199270] pyd_debug:seq_show().
[ 505.199275] pyd_debug:seq_next().
[ 505.199277] pyd_debug:seq_show().
[ 505.199280] pyd_debug:seq_next().
[ 505.199282] pyd_debug:seq_show().
[ 505.199285] pyd_debug:seq_next().
[ 505.199287] pyd_debug:seq_show().
[ 505.199290] pyd_debug:seq_next().
[ 505.199292] pyd_debug:seq_next():after if, *pos=4.
[ 505.199294] pyd_debug:seq_stop().
[ 505.199326] pyd_debug:seq_start().
[ 505.199329] pyd_debug:seq_start():after if, *pos=4.
[ 505.199331] pyd_debug:seq_stop(). |